~suaweb/nginx/nginx-recipe

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/htmlparse/public/file_driver.h

  • Committer: Frans Elliott
  • Date: 2015-06-12 21:15:13 UTC
  • Revision ID: mastergeek.elliott@gmail.com-20150612211513-un4vguj32deibvb0
Added the actual pagespeed library to the ngx_pagespeed module dir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Google Inc.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
// Author: jmarantz@google.com (Joshua Marantz)
 
18
 
 
19
#ifndef NET_INSTAWEB_HTMLPARSE_PUBLIC_FILE_DRIVER_H_
 
20
#define NET_INSTAWEB_HTMLPARSE_PUBLIC_FILE_DRIVER_H_
 
21
 
 
22
#include "net/instaweb/htmlparse/public/html_writer_filter.h"
 
23
#include "net/instaweb/htmlparse/public/logging_html_filter.h"
 
24
#include "pagespeed/kernel/base/basictypes.h"
 
25
#include "pagespeed/kernel/base/string.h"
 
26
 
 
27
namespace net_instaweb {
 
28
 
 
29
class FileSystem;
 
30
class HtmlParse;
 
31
class MessageHandler;
 
32
class StatisticsLog;
 
33
 
 
34
// Framework for reading an input HTML file, running it through
 
35
// a chain of HTML filters, and writing an output file.
 
36
class FileDriver {
 
37
 public:
 
38
  FileDriver(HtmlParse* html_parse, FileSystem* file_system);
 
39
 
 
40
  // Return the parser.  This can be used to add filters.
 
41
  HtmlParse* html_parse() { return html_parse_; }
 
42
 
 
43
  // Helper function to generate an output .html filename from
 
44
  // an input filename.  Given "/a/b/c.html" returns "a/b/c.out.html".
 
45
  // Returns false if the input file does not contain a "."
 
46
  static bool GenerateOutputFilename(
 
47
      const char* infilename, GoogleString* outfilename);
 
48
 
 
49
  // Helper function to generate an output .stats filename from
 
50
  // an input filename.  Given "/a/b/c.html" returns "a/b/c.stats".
 
51
  // Returns false if the input file does not contain a "."
 
52
  static bool GenerateStatsFilename(
 
53
      const char* infilename, GoogleString* statsfilename);
 
54
 
 
55
  // Error messages are sent to the message file, true is returned
 
56
  // if the file was parsed successfully.
 
57
  bool ParseFile(const char* infilename,
 
58
                 const char* outfilename,
 
59
                 const char* statsfilename,
 
60
                 MessageHandler* handler);
 
61
 
 
62
  // Indicates that we should Flush the parser every x bytes.  Disabled if x<=0.
 
63
  void set_flush_byte_count(int x) { flush_byte_count_ = x; }
 
64
 
 
65
 private:
 
66
  HtmlParse* html_parse_;
 
67
  LoggingFilter logging_filter_;
 
68
  StatisticsLog* stats_log_;
 
69
  HtmlWriterFilter html_write_filter_;
 
70
  bool filters_added_;
 
71
  FileSystem* file_system_;
 
72
  int flush_byte_count_;
 
73
 
 
74
  DISALLOW_COPY_AND_ASSIGN(FileDriver);
 
75
};
 
76
 
 
77
}  // namespace net_instaweb
 
78
 
 
79
#endif  // NET_INSTAWEB_HTMLPARSE_PUBLIC_FILE_DRIVER_H_