Page Speed Optimization Libraries  1.4.26.1
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 AbstractMutex;
00033 class ApacheRewriteDriverFactory;
00034 class Histogram;
00035 class ProxyFetchFactory;
00036 class RewriteDriverPool;
00037 class RewriteDriver;
00038 class RewriteStats;
00039 class SharedMemStatistics;
00040 class Statistics;
00041 class UrlAsyncFetcherStats;
00042 class Variable;
00043 
00050 class ApacheServerContext : public SystemServerContext {
00051  public:
00052   ApacheServerContext(ApacheRewriteDriverFactory* factory,
00053                       server_rec* server,
00054                       const StringPiece& version);
00055   virtual ~ApacheServerContext();
00056 
00057   GoogleString hostname_identifier() { return hostname_identifier_; }
00058   ApacheRewriteDriverFactory* apache_factory() { return apache_factory_; }
00059   ApacheConfig* config();
00060   bool InitFileCachePath();
00061 
00069   ApacheConfig* SpdyConfigOverlay();
00070   ApacheConfig* NonSpdyConfigOverlay();
00071 
00074   bool has_spdy_config_overlay() const {
00075     return spdy_config_overlay_.get() != NULL;
00076   }
00077 
00078   bool has_non_spdy_config_overlay() const {
00079     return non_spdy_config_overlay_.get() != NULL;
00080   }
00081 
00083   void set_spdy_config_overlay(ApacheConfig* x) {
00084     spdy_config_overlay_.reset(x);
00085   }
00086 
00087   void set_non_spdy_config_overlay(ApacheConfig* x) {
00088     non_spdy_config_overlay_.reset(x);
00089   }
00090 
00093   ApacheConfig* SpdyConfig() { return spdy_specific_config_.get(); }
00094 
00098   RewriteDriverPool* spdy_driver_pool() { return spdy_driver_pool_; }
00099 
00103   void CollapseConfigOverlaysAndComputeSignatures();
00104 
00108   void CreateLocalStatistics(Statistics* global_statistics);
00109 
00111   void ChildInit();
00112 
00113   bool initialized() const { return initialized_; }
00114 
00117   bool PoolDestroyed();
00118 
00132   void PollFilesystemForCacheFlush();
00133 
00136   void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
00137 
00138   static void InitStats(Statistics* statistics);
00139 
00140   const server_rec* server() const { return server_rec_; }
00141 
00142   virtual RewriteDriverPool* SelectDriverPool(bool using_spdy);
00143 
00144   virtual void ApplySessionFetchers(const RequestContextPtr& req,
00145                                     RewriteDriver* driver);
00146 
00147   ProxyFetchFactory* proxy_fetch_factory() {
00148     return proxy_fetch_factory_.get();
00149   }
00150 
00151   void InitProxyFetchFactory();
00152 
00156   virtual bool ProxiesHtml() const { return false; }
00157 
00158  private:
00159   bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00160 
00161   ApacheRewriteDriverFactory* apache_factory_;
00162   server_rec* server_rec_;
00163   GoogleString version_;
00164 
00168   GoogleString hostname_identifier_;
00169 
00170   bool initialized_;
00171 
00173   scoped_ptr<Statistics> split_statistics_;
00174 
00176   SharedMemStatistics* local_statistics_;
00177 
00179   scoped_ptr<RewriteStats> local_rewrite_stats_;
00180   scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
00181 
00184   scoped_ptr<ApacheConfig> spdy_config_overlay_;
00185   scoped_ptr<ApacheConfig> non_spdy_config_overlay_;
00186 
00188   scoped_ptr<ApacheConfig> spdy_specific_config_;
00189 
00192   RewriteDriverPool* spdy_driver_pool_;
00193 
00194   Histogram* html_rewrite_time_us_histogram_;
00195 
00199   scoped_ptr<AbstractMutex> cache_flush_mutex_;
00200   int64 last_cache_flush_check_sec_; 
00201 
00202   Variable* cache_flush_count_;
00203   Variable* cache_flush_timestamp_ms_;
00204 
00205   scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
00206 
00207   DISALLOW_COPY_AND_ASSIGN(ApacheServerContext);
00208 };
00209 
00210 }  
00211 
00212 #endif  ///< NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines