Page Speed Optimization Libraries  1.7.30.3
net/instaweb/apache/apache_rewrite_driver_factory.h
Go to the documentation of this file.
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 QueuedWorkerPool;
00041 class ServerContext;
00042 class SharedCircularBuffer;
00043 class SlowWorker;
00044 class StaticAssetManager;
00045 class Statistics;
00046 class Timer;
00047 
00049 class ApacheRewriteDriverFactory : public SystemRewriteDriverFactory {
00050  public:
00053   static const char kStaticAssetPrefix[];
00054 
00055   ApacheRewriteDriverFactory(server_rec* server, const StringPiece& version);
00056   virtual ~ApacheRewriteDriverFactory();
00057 
00062   ApacheMessageHandler* apache_message_handler() {
00063     return apache_message_handler_;
00064   }
00065 
00066   virtual void ChildInit();
00067 
00068   virtual void NonStaticInitStats(Statistics* statistics) {
00069     InitStats(statistics);
00070   }
00071 
00072   ApacheServerContext* MakeApacheServerContext(server_rec* server);
00073 
00074   void set_num_rewrite_threads(int x) { num_rewrite_threads_ = x; }
00075   int num_rewrite_threads() const { return num_rewrite_threads_; }
00076   void set_num_expensive_rewrite_threads(int x) {
00077     num_expensive_rewrite_threads_ = x;
00078   }
00079   int num_expensive_rewrite_threads() const {
00080     return num_expensive_rewrite_threads_;
00081   }
00082 
00083   virtual bool use_per_vhost_statistics() const {
00084     return use_per_vhost_statistics_;
00085   }
00086 
00087   void set_use_per_vhost_statistics(bool x) {
00088     use_per_vhost_statistics_ = x;
00089   }
00090 
00091   virtual bool enable_property_cache() const {
00092     return enable_property_cache_;
00093   }
00094 
00095   void set_enable_property_cache(bool x) {
00096     enable_property_cache_ = x;
00097   }
00098 
00100   bool inherit_vhost_config() const {
00101     return inherit_vhost_config_;
00102   }
00103 
00104   void set_inherit_vhost_config(bool x) {
00105     inherit_vhost_config_ = x;
00106   }
00107 
00108   bool install_crash_handler() const {
00109     return install_crash_handler_;
00110   }
00111 
00112   void set_install_crash_handler(bool x) {
00113     install_crash_handler_ = x;
00114   }
00115 
00118   virtual bool UseBeaconResultsInFilters() const {
00119     return true;
00120   }
00121 
00125   bool PoolDestroyed(ApacheServerContext* rm);
00126 
00127   virtual ApacheConfig* NewRewriteOptions();
00128 
00131   virtual ApacheConfig* NewRewriteOptionsForQuery();
00132 
00136   static void InitStats(Statistics* statistics);
00137   static void Initialize();
00138   static void Terminate();
00139 
00140   ModSpdyFetchController* mod_spdy_fetch_controller() {
00141     return mod_spdy_fetch_controller_.get();
00142   }
00143 
00145   virtual void set_message_buffer_size(int x) {
00146     SystemRewriteDriverFactory::set_message_buffer_size(x);
00147   }
00148 
00150   virtual int requests_per_host();
00151 
00152  protected:
00154   virtual MessageHandler* DefaultHtmlParseMessageHandler();
00155   virtual MessageHandler* DefaultMessageHandler();
00156   virtual Timer* DefaultTimer();
00157   virtual void SetupCaches(ServerContext* server_context);
00158   virtual QueuedWorkerPool* CreateWorkerPool(WorkerPoolCategory pool,
00159                                              StringPiece name);
00160 
00163   virtual bool ShouldWriteResourcesToFileSystem() { return false; }
00164 
00165   virtual void ParentOrChildInit();
00166 
00167   virtual void SetupMessageHandlers();
00168   virtual void ShutDownMessageHandlers();
00169   virtual void ShutDownFetchers();
00170 
00171   virtual void SetCircularBuffer(SharedCircularBuffer* buffer);
00172 
00174   virtual void InitStaticAssetManager(StaticAssetManager* static_asset_manager);
00175 
00176  private:
00179   void AutoDetectThreadCounts();
00180 
00181   apr_pool_t* pool_;
00182   server_rec* server_rec_;
00183   scoped_ptr<SlowWorker> slow_worker_;
00184 
00189   GoogleString version_;
00190 
00196   ApacheMessageHandler* apache_message_handler_;
00201   ApacheMessageHandler* apache_html_parse_message_handler_;
00202 
00206   bool use_per_vhost_statistics_;
00207 
00209   bool enable_property_cache_;
00210 
00212   bool inherit_vhost_config_;
00213 
00215   bool install_crash_handler_;
00216 
00218   bool thread_counts_finalized_;
00219 
00221   int num_rewrite_threads_;
00222   int num_expensive_rewrite_threads_;
00223 
00224   int max_mod_spdy_fetch_threads_;
00225 
00227   scoped_ptr<ModSpdyFetchController> mod_spdy_fetch_controller_;
00228 
00229   DISALLOW_COPY_AND_ASSIGN(ApacheRewriteDriverFactory);
00230 };
00231 
00232 }  
00233 
00234 #endif  ///< NET_INSTAWEB_APACHE_APACHE_REWRITE_DRIVER_FACTORY_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines