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