Page Speed Optimization Libraries
1.8.31.2
|
00001 // Copyright 2010 Google Inc. 00017 00018 #ifndef NET_INSTAWEB_APACHE_APACHE_REWRITE_DRIVER_FACTORY_H_ 00019 #define NET_INSTAWEB_APACHE_APACHE_REWRITE_DRIVER_FACTORY_H_ 00020 00023 #include "net/instaweb/apache/apache_config.h" 00024 #include "net/instaweb/rewriter/public/rewrite_driver_factory.h" 00025 #include "net/instaweb/system/public/system_rewrite_driver_factory.h" 00026 #include "net/instaweb/util/public/basictypes.h" 00027 #include "net/instaweb/util/public/scoped_ptr.h" 00028 #include "net/instaweb/util/public/string.h" 00029 #include "net/instaweb/util/public/string_util.h" 00030 00031 struct apr_pool_t; 00032 struct server_rec; 00033 00034 namespace net_instaweb { 00035 00036 class ApacheMessageHandler; 00037 class ApacheServerContext; 00038 class MessageHandler; 00039 class ModSpdyFetchController; 00040 class ProcessContext; 00041 class QueuedWorkerPool; 00042 class ServerContext; 00043 class SharedCircularBuffer; 00044 class SlowWorker; 00045 class Statistics; 00046 class Timer; 00047 00049 class ApacheRewriteDriverFactory : public SystemRewriteDriverFactory { 00050 public: 00051 ApacheRewriteDriverFactory(const ProcessContext& process_context, 00052 server_rec* server, const StringPiece& version); 00053 virtual ~ApacheRewriteDriverFactory(); 00054 00059 ApacheMessageHandler* apache_message_handler() { 00060 return apache_message_handler_; 00061 } 00062 00063 virtual void ChildInit(); 00064 00065 virtual void NonStaticInitStats(Statistics* statistics) { 00066 InitStats(statistics); 00067 } 00068 00069 ApacheServerContext* MakeApacheServerContext(server_rec* server); 00070 00071 void set_num_rewrite_threads(int x) { num_rewrite_threads_ = x; } 00072 int num_rewrite_threads() const { return num_rewrite_threads_; } 00073 void set_num_expensive_rewrite_threads(int x) { 00074 num_expensive_rewrite_threads_ = x; 00075 } 00076 int num_expensive_rewrite_threads() const { 00077 return num_expensive_rewrite_threads_; 00078 } 00079 00080 virtual bool use_per_vhost_statistics() const { 00081 return use_per_vhost_statistics_; 00082 } 00083 00084 void set_use_per_vhost_statistics(bool x) { 00085 use_per_vhost_statistics_ = x; 00086 } 00087 00088 virtual bool enable_property_cache() const { 00089 return enable_property_cache_; 00090 } 00091 00092 void set_enable_property_cache(bool x) { 00093 enable_property_cache_ = x; 00094 } 00095 00097 bool inherit_vhost_config() const { 00098 return inherit_vhost_config_; 00099 } 00100 00101 void set_inherit_vhost_config(bool x) { 00102 inherit_vhost_config_ = x; 00103 } 00104 00105 bool install_crash_handler() const { 00106 return install_crash_handler_; 00107 } 00108 00109 void set_install_crash_handler(bool x) { 00110 install_crash_handler_ = x; 00111 } 00112 00115 virtual bool UseBeaconResultsInFilters() const { 00116 return true; 00117 } 00118 00122 bool PoolDestroyed(ApacheServerContext* rm); 00123 00124 virtual ApacheConfig* NewRewriteOptions(); 00125 00128 virtual ApacheConfig* NewRewriteOptionsForQuery(); 00129 00133 static void InitStats(Statistics* statistics); 00134 static void Initialize(); 00135 static void Terminate(); 00136 00137 ModSpdyFetchController* mod_spdy_fetch_controller() { 00138 return mod_spdy_fetch_controller_.get(); 00139 } 00140 00142 virtual void set_message_buffer_size(int x) { 00143 SystemRewriteDriverFactory::set_message_buffer_size(x); 00144 } 00145 00147 virtual int requests_per_host(); 00148 00149 protected: 00151 virtual MessageHandler* DefaultHtmlParseMessageHandler(); 00152 virtual MessageHandler* DefaultMessageHandler(); 00153 virtual Timer* DefaultTimer(); 00154 virtual void SetupCaches(ServerContext* server_context); 00155 virtual QueuedWorkerPool* CreateWorkerPool(WorkerPoolCategory pool, 00156 StringPiece name); 00157 00160 virtual bool ShouldWriteResourcesToFileSystem() { return false; } 00161 00162 virtual void ParentOrChildInit(); 00163 00164 virtual void SetupMessageHandlers(); 00165 virtual void ShutDownMessageHandlers(); 00166 virtual void ShutDownFetchers(); 00167 00168 virtual void SetCircularBuffer(SharedCircularBuffer* buffer); 00169 00170 virtual ServerContext* NewDecodingServerContext(); 00171 00172 private: 00175 void AutoDetectThreadCounts(); 00176 00177 apr_pool_t* pool_; 00178 server_rec* server_rec_; 00179 scoped_ptr<SlowWorker> slow_worker_; 00180 00185 GoogleString version_; 00186 00192 ApacheMessageHandler* apache_message_handler_; 00197 ApacheMessageHandler* apache_html_parse_message_handler_; 00198 00202 bool use_per_vhost_statistics_; 00203 00205 bool enable_property_cache_; 00206 00208 bool inherit_vhost_config_; 00209 00211 bool install_crash_handler_; 00212 00214 bool thread_counts_finalized_; 00215 00217 int num_rewrite_threads_; 00218 int num_expensive_rewrite_threads_; 00219 00220 int max_mod_spdy_fetch_threads_; 00221 00223 scoped_ptr<ModSpdyFetchController> mod_spdy_fetch_controller_; 00224 00225 DISALLOW_COPY_AND_ASSIGN(ApacheRewriteDriverFactory); 00226 }; 00227 00228 } 00229 00230 #endif ///< NET_INSTAWEB_APACHE_APACHE_REWRITE_DRIVER_FACTORY_H_