Page Speed Optimization Libraries  1.7.30.4
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 ProcessContext;
00041 class QueuedWorkerPool;
00042 class ServerContext;
00043 class SharedCircularBuffer;
00044 class SlowWorker;
00045 class StaticAssetManager;
00046 class Statistics;
00047 class Timer;
00048 
00050 class ApacheRewriteDriverFactory : public SystemRewriteDriverFactory {
00051  public:
00054   static const char kStaticAssetPrefix[];
00055 
00056   ApacheRewriteDriverFactory(const ProcessContext& process_context,
00057                              server_rec* server, const StringPiece& version);
00058   virtual ~ApacheRewriteDriverFactory();
00059 
00064   ApacheMessageHandler* apache_message_handler() {
00065     return apache_message_handler_;
00066   }
00067 
00068   virtual void ChildInit();
00069 
00070   virtual void NonStaticInitStats(Statistics* statistics) {
00071     InitStats(statistics);
00072   }
00073 
00074   ApacheServerContext* MakeApacheServerContext(server_rec* server);
00075 
00076   void set_num_rewrite_threads(int x) { num_rewrite_threads_ = x; }
00077   int num_rewrite_threads() const { return num_rewrite_threads_; }
00078   void set_num_expensive_rewrite_threads(int x) {
00079     num_expensive_rewrite_threads_ = x;
00080   }
00081   int num_expensive_rewrite_threads() const {
00082     return num_expensive_rewrite_threads_;
00083   }
00084 
00085   virtual bool use_per_vhost_statistics() const {
00086     return use_per_vhost_statistics_;
00087   }
00088 
00089   void set_use_per_vhost_statistics(bool x) {
00090     use_per_vhost_statistics_ = x;
00091   }
00092 
00093   virtual bool enable_property_cache() const {
00094     return enable_property_cache_;
00095   }
00096 
00097   void set_enable_property_cache(bool x) {
00098     enable_property_cache_ = x;
00099   }
00100 
00102   bool inherit_vhost_config() const {
00103     return inherit_vhost_config_;
00104   }
00105 
00106   void set_inherit_vhost_config(bool x) {
00107     inherit_vhost_config_ = x;
00108   }
00109 
00110   bool install_crash_handler() const {
00111     return install_crash_handler_;
00112   }
00113 
00114   void set_install_crash_handler(bool x) {
00115     install_crash_handler_ = x;
00116   }
00117 
00120   virtual bool UseBeaconResultsInFilters() const {
00121     return true;
00122   }
00123 
00127   bool PoolDestroyed(ApacheServerContext* rm);
00128 
00129   virtual ApacheConfig* NewRewriteOptions();
00130 
00133   virtual ApacheConfig* NewRewriteOptionsForQuery();
00134 
00138   static void InitStats(Statistics* statistics);
00139   static void Initialize();
00140   static void Terminate();
00141 
00142   ModSpdyFetchController* mod_spdy_fetch_controller() {
00143     return mod_spdy_fetch_controller_.get();
00144   }
00145 
00147   virtual void set_message_buffer_size(int x) {
00148     SystemRewriteDriverFactory::set_message_buffer_size(x);
00149   }
00150 
00152   virtual int requests_per_host();
00153 
00154  protected:
00156   virtual MessageHandler* DefaultHtmlParseMessageHandler();
00157   virtual MessageHandler* DefaultMessageHandler();
00158   virtual Timer* DefaultTimer();
00159   virtual void SetupCaches(ServerContext* server_context);
00160   virtual QueuedWorkerPool* CreateWorkerPool(WorkerPoolCategory pool,
00161                                              StringPiece name);
00162 
00165   virtual bool ShouldWriteResourcesToFileSystem() { return false; }
00166 
00167   virtual void ParentOrChildInit();
00168 
00169   virtual void SetupMessageHandlers();
00170   virtual void ShutDownMessageHandlers();
00171   virtual void ShutDownFetchers();
00172 
00173   virtual void SetCircularBuffer(SharedCircularBuffer* buffer);
00174 
00176   virtual void InitStaticAssetManager(StaticAssetManager* static_asset_manager);
00177 
00178   virtual ServerContext* NewDecodingServerContext();
00179 
00180  private:
00183   void AutoDetectThreadCounts();
00184 
00185   apr_pool_t* pool_;
00186   server_rec* server_rec_;
00187   scoped_ptr<SlowWorker> slow_worker_;
00188 
00193   GoogleString version_;
00194 
00200   ApacheMessageHandler* apache_message_handler_;
00205   ApacheMessageHandler* apache_html_parse_message_handler_;
00206 
00210   bool use_per_vhost_statistics_;
00211 
00213   bool enable_property_cache_;
00214 
00216   bool inherit_vhost_config_;
00217 
00219   bool install_crash_handler_;
00220 
00222   bool thread_counts_finalized_;
00223 
00225   int num_rewrite_threads_;
00226   int num_expensive_rewrite_threads_;
00227 
00228   int max_mod_spdy_fetch_threads_;
00229 
00231   scoped_ptr<ModSpdyFetchController> mod_spdy_fetch_controller_;
00232 
00233   DISALLOW_COPY_AND_ASSIGN(ApacheRewriteDriverFactory);
00234 };
00235 
00236 }  
00237 
00238 #endif  ///< NET_INSTAWEB_APACHE_APACHE_REWRITE_DRIVER_FACTORY_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines