Page Speed Optimization Libraries
1.7.30.1
|
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 ServerContext; 00034 class Statistics; 00035 class UrlAsyncFetcher; 00036 class Writer; 00037 00044 class FileRewriter : public RewriteDriverFactory { 00045 public: 00046 FileRewriter(const RewriteGflags* gflags, 00047 bool echo_errors_to_stdout); 00048 virtual ~FileRewriter(); 00049 virtual Hasher* NewHasher(); 00050 virtual UrlAsyncFetcher* DefaultAsyncUrlFetcher(); 00051 virtual MessageHandler* DefaultHtmlParseMessageHandler(); 00052 virtual MessageHandler* DefaultMessageHandler(); 00053 virtual FileSystem* DefaultFileSystem(); 00054 virtual void SetupCaches(ServerContext* server_context); 00055 virtual Statistics* statistics(); 00056 virtual ServerContext* NewServerContext(); 00057 virtual bool UseBeaconResultsInFilters() const { return false; } 00058 00059 private: 00060 const RewriteGflags* gflags_; 00061 SimpleStats simple_stats_; 00062 bool echo_errors_to_stdout_; 00063 00064 DISALLOW_COPY_AND_ASSIGN(FileRewriter); 00065 }; 00066 00069 class StaticRewriter { 00070 public: 00071 StaticRewriter(int* argc, char*** argv); 00072 StaticRewriter(); 00073 ~StaticRewriter(); 00074 00075 bool ParseText(const StringPiece& text, 00076 const StringPiece& url, 00077 const StringPiece& id, 00078 const StringPiece& output_dir, 00079 Writer* writer); 00080 00081 FileSystem* file_system(); 00082 MessageHandler* message_handler(); 00083 00084 private: 00085 RewriteGflags gflags_; 00086 FileRewriter file_rewriter_; 00087 ServerContext* server_context_; 00088 00089 DISALLOW_COPY_AND_ASSIGN(StaticRewriter); 00090 }; 00091 00092 } 00093 00094 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_