Page Speed Optimization Libraries  1.6.29.3
net/instaweb/apache/apache_server_context.h
Go to the documentation of this file.
00001 // Copyright 2011 Google Inc.
00016 
00017 #ifndef NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
00018 #define NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
00019 
00020 #include "net/instaweb/apache/apache_config.h"
00021 #include "net/instaweb/http/public/request_context.h"
00022 #include "net/instaweb/system/public/system_server_context.h"
00023 #include "net/instaweb/util/public/basictypes.h"
00024 #include "net/instaweb/util/public/scoped_ptr.h"
00025 #include "net/instaweb/util/public/string.h"
00026 #include "net/instaweb/util/public/string_util.h"
00027 
00028 struct server_rec;
00029 
00030 namespace net_instaweb {
00031 
00032 class ApacheRewriteDriverFactory;
00033 class Histogram;
00034 class ProxyFetchFactory;
00035 class RewriteDriverPool;
00036 class RewriteDriver;
00037 class RewriteStats;
00038 class SharedMemStatistics;
00039 class Statistics;
00040 class UrlAsyncFetcherStats;
00041 
00048 class ApacheServerContext : public SystemServerContext {
00049  public:
00050   ApacheServerContext(ApacheRewriteDriverFactory* factory,
00051                       server_rec* server,
00052                       const StringPiece& version);
00053   virtual ~ApacheServerContext();
00054 
00055   GoogleString hostname_identifier() { return hostname_identifier_; }
00056   ApacheRewriteDriverFactory* apache_factory() { return apache_factory_; }
00057   ApacheConfig* config();
00058   bool InitPath(const GoogleString& path);
00059 
00067   ApacheConfig* SpdyConfigOverlay();
00068   ApacheConfig* NonSpdyConfigOverlay();
00069 
00072   bool has_spdy_config_overlay() const {
00073     return spdy_config_overlay_.get() != NULL;
00074   }
00075 
00076   bool has_non_spdy_config_overlay() const {
00077     return non_spdy_config_overlay_.get() != NULL;
00078   }
00079 
00081   void set_spdy_config_overlay(ApacheConfig* x) {
00082     spdy_config_overlay_.reset(x);
00083   }
00084 
00085   void set_non_spdy_config_overlay(ApacheConfig* x) {
00086     non_spdy_config_overlay_.reset(x);
00087   }
00088 
00091   ApacheConfig* SpdyConfig() { return spdy_specific_config_.get(); }
00092 
00096   RewriteDriverPool* spdy_driver_pool() { return spdy_driver_pool_; }
00097 
00101   void CollapseConfigOverlaysAndComputeSignatures();
00102 
00106   void CreateLocalStatistics(Statistics* global_statistics);
00107 
00109   void ChildInit();
00110 
00111   bool initialized() const { return initialized_; }
00112 
00115   bool PoolDestroyed();
00116 
00119   void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
00120 
00121   static void InitStats(Statistics* statistics);
00122 
00123   const server_rec* server() const { return server_rec_; }
00124 
00125   virtual RewriteDriverPool* SelectDriverPool(bool using_spdy);
00126 
00127   virtual void ApplySessionFetchers(const RequestContextPtr& req,
00128                                     RewriteDriver* driver);
00129 
00130   ProxyFetchFactory* proxy_fetch_factory() {
00131     return proxy_fetch_factory_.get();
00132   }
00133 
00134   void InitProxyFetchFactory();
00135 
00139   virtual bool ProxiesHtml() const { return false; }
00140 
00141  private:
00142   virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00143 
00144   ApacheRewriteDriverFactory* apache_factory_;
00145   server_rec* server_rec_;
00146   GoogleString version_;
00147 
00151   GoogleString hostname_identifier_;
00152 
00153   bool initialized_;
00154 
00156   scoped_ptr<Statistics> split_statistics_;
00157 
00159   SharedMemStatistics* local_statistics_;
00160 
00162   scoped_ptr<RewriteStats> local_rewrite_stats_;
00163   scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
00164 
00167   scoped_ptr<ApacheConfig> spdy_config_overlay_;
00168   scoped_ptr<ApacheConfig> non_spdy_config_overlay_;
00169 
00171   scoped_ptr<ApacheConfig> spdy_specific_config_;
00172 
00175   RewriteDriverPool* spdy_driver_pool_;
00176 
00177   Histogram* html_rewrite_time_us_histogram_;
00178 
00179   scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
00180 
00181   DISALLOW_COPY_AND_ASSIGN(ApacheServerContext);
00182 };
00183 
00184 }  
00185 
00186 #endif  ///< NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines