Page Speed Optimization Libraries
1.7.30.4
|
00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_ 00020 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_ 00021 00022 #include "net/instaweb/rewriter/public/rewrite_driver_factory.h" 00023 #include "net/instaweb/rewriter/public/rewrite_gflags.h" 00024 #include "net/instaweb/util/public/basictypes.h" 00025 #include "net/instaweb/util/public/simple_stats.h" 00026 #include "net/instaweb/util/public/string_util.h" 00027 00028 namespace net_instaweb { 00029 00030 class FileSystem; 00031 class Hasher; 00032 class MessageHandler; 00033 class ProcessContext; 00034 class ServerContext; 00035 class Statistics; 00036 class UrlAsyncFetcher; 00037 class Writer; 00038 00045 class FileRewriter : public RewriteDriverFactory { 00046 public: 00047 FileRewriter(const ProcessContext& process_context, 00048 const RewriteGflags* gflags, 00049 bool echo_errors_to_stdout); 00050 virtual ~FileRewriter(); 00051 virtual Hasher* NewHasher(); 00052 virtual UrlAsyncFetcher* DefaultAsyncUrlFetcher(); 00053 virtual MessageHandler* DefaultHtmlParseMessageHandler(); 00054 virtual MessageHandler* DefaultMessageHandler(); 00055 virtual FileSystem* DefaultFileSystem(); 00056 virtual void SetupCaches(ServerContext* server_context); 00057 virtual Statistics* statistics(); 00058 virtual ServerContext* NewServerContext(); 00059 virtual ServerContext* NewDecodingServerContext(); 00060 virtual bool UseBeaconResultsInFilters() const { return false; } 00061 00062 private: 00063 const RewriteGflags* gflags_; 00064 SimpleStats simple_stats_; 00065 bool echo_errors_to_stdout_; 00066 00067 DISALLOW_COPY_AND_ASSIGN(FileRewriter); 00068 }; 00069 00072 class StaticRewriter { 00073 public: 00074 StaticRewriter(const ProcessContext& process_context, 00075 int* argc, char*** argv); 00076 explicit StaticRewriter(const ProcessContext& process_context); 00077 ~StaticRewriter(); 00078 00079 bool ParseText(const StringPiece& text, 00080 const StringPiece& url, 00081 const StringPiece& id, 00082 const StringPiece& output_dir, 00083 Writer* writer); 00084 00085 FileSystem* file_system(); 00086 MessageHandler* message_handler(); 00087 00088 private: 00089 RewriteGflags gflags_; 00090 FileRewriter file_rewriter_; 00091 ServerContext* server_context_; 00092 00093 DISALLOW_COPY_AND_ASSIGN(StaticRewriter); 00094 }; 00095 00096 } 00097 00098 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_