~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/automatic/public/static_rewriter.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2011 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_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_
20
 
#define NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_
21
 
 
22
 
#include "net/instaweb/rewriter/public/rewrite_driver_factory.h"
23
 
#include "net/instaweb/rewriter/public/rewrite_gflags.h"
24
 
#include "net/instaweb/util/public/basictypes.h"
25
 
#include "net/instaweb/util/public/simple_stats.h"
26
 
#include "net/instaweb/util/public/string_util.h"
27
 
 
28
 
namespace net_instaweb {
29
 
 
30
 
class FileSystem;
31
 
class Hasher;
32
 
class MessageHandler;
33
 
class ProcessContext;
34
 
class ServerContext;
35
 
class Statistics;
36
 
class UrlAsyncFetcher;
37
 
class Writer;
38
 
 
39
 
// Implements a baseline RewriteDriverFactory with the simplest possible
40
 
// options for cache, fetchers, & system interface.
41
 
//
42
 
// TODO(jmarantz): fill out enough functionality so that this will be
43
 
// a functional static rewriter that could optimize an HTML file
44
 
// passed as a command-line parameter or via stdin.
45
 
class FileRewriter : public RewriteDriverFactory {
46
 
 public:
47
 
  FileRewriter(const ProcessContext& process_context,
48
 
               const RewriteGflags* gflags,
49
 
               bool echo_errors_to_stdout);
50
 
  virtual ~FileRewriter();
51
 
  virtual Hasher* NewHasher();
52
 
  virtual UrlAsyncFetcher* DefaultAsyncUrlFetcher();
53
 
  virtual MessageHandler* DefaultHtmlParseMessageHandler();
54
 
  virtual MessageHandler* DefaultMessageHandler();
55
 
  virtual FileSystem* DefaultFileSystem();
56
 
  virtual void SetupCaches(ServerContext* server_context);
57
 
  virtual Statistics* statistics();
58
 
  virtual ServerContext* NewServerContext();
59
 
  virtual ServerContext* NewDecodingServerContext();
60
 
  virtual bool UseBeaconResultsInFilters() const { return false; }
61
 
 
62
 
 private:
63
 
  const RewriteGflags* gflags_;
64
 
  SimpleStats simple_stats_;
65
 
  bool echo_errors_to_stdout_;
66
 
 
67
 
  DISALLOW_COPY_AND_ASSIGN(FileRewriter);
68
 
};
69
 
 
70
 
// Encapsulates the instantiation of a FileRewriter & a simple one-shot
71
 
// interface to rewrite some HTML text.
72
 
class StaticRewriter {
73
 
 public:
74
 
  StaticRewriter(const ProcessContext& process_context,
75
 
                 int* argc, char*** argv);
76
 
  explicit StaticRewriter(const ProcessContext& process_context);
77
 
  ~StaticRewriter();
78
 
 
79
 
  bool ParseText(const StringPiece& text,
80
 
                 const StringPiece& url,
81
 
                 const StringPiece& id,
82
 
                 const StringPiece& output_dir,
83
 
                 Writer* writer);
84
 
 
85
 
  FileSystem* file_system();
86
 
  MessageHandler* message_handler();
87
 
 
88
 
 private:
89
 
  RewriteGflags gflags_;
90
 
  FileRewriter file_rewriter_;
91
 
  ServerContext* server_context_;
92
 
 
93
 
  DISALLOW_COPY_AND_ASSIGN(StaticRewriter);
94
 
};
95
 
 
96
 
}  // namespace net_instaweb
97
 
 
98
 
#endif  // NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_