Page Speed Optimization Libraries  1.3.25.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/rewriter/public/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 RewriteDriverPool;
00036 class RewriteDriver;
00037 class RewriteStats;
00038 class SharedMemStatistics;
00039 class Statistics;
00040 class UrlAsyncFetcherStats;
00041 class Variable;
00042 
00049 class ApacheServerContext : public ServerContext {
00050  public:
00051   ApacheServerContext(ApacheRewriteDriverFactory* factory,
00052                       server_rec* server,
00053                       const StringPiece& version);
00054   virtual ~ApacheServerContext();
00055 
00056   GoogleString hostname_identifier() { return hostname_identifier_; }
00057   ApacheRewriteDriverFactory* apache_factory() { return apache_factory_; }
00058   ApacheConfig* config();
00059   bool InitFileCachePath();
00060 
00068   ApacheConfig* SpdyConfigOverlay();
00069   ApacheConfig* NonSpdyConfigOverlay();
00070 
00073   bool has_spdy_config_overlay() const {
00074     return spdy_config_overlay_.get() != NULL;
00075   }
00076 
00077   bool has_non_spdy_config_overlay() const {
00078     return non_spdy_config_overlay_.get() != NULL;
00079   }
00080 
00082   void set_spdy_config_overlay(ApacheConfig* x) {
00083     spdy_config_overlay_.reset(x);
00084   }
00085 
00086   void set_non_spdy_config_overlay(ApacheConfig* x) {
00087     non_spdy_config_overlay_.reset(x);
00088   }
00089 
00092   ApacheConfig* SpdyConfig() { return spdy_specific_config_.get(); }
00093 
00097   RewriteDriverPool* spdy_driver_pool() { return spdy_driver_pool_; }
00098 
00102   void CollapseConfigOverlaysAndComputeSignatures();
00103 
00107   void CreateLocalStatistics(Statistics* global_statistics);
00108 
00110   void ChildInit();
00111 
00112   bool initialized() const { return initialized_; }
00113 
00116   bool PoolDestroyed();
00117 
00131   void PollFilesystemForCacheFlush();
00132 
00135   void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
00136 
00137   static void InitStats(Statistics* statistics);
00138 
00139   const server_rec* server() const { return server_rec_; }
00140 
00141   virtual RewriteDriverPool* SelectDriverPool(bool using_spdy);
00142 
00143   virtual void ApplySessionFetchers(const RequestContextPtr& req,
00144                                     RewriteDriver* driver);
00145 
00146  private:
00147   bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00148 
00149   ApacheRewriteDriverFactory* apache_factory_;
00150   server_rec* server_rec_;
00151   GoogleString version_;
00152 
00156   GoogleString hostname_identifier_;
00157 
00158   bool initialized_;
00159 
00161   scoped_ptr<Statistics> split_statistics_;
00162 
00164   SharedMemStatistics* local_statistics_;
00165 
00167   scoped_ptr<RewriteStats> local_rewrite_stats_;
00168   scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
00169 
00172   scoped_ptr<ApacheConfig> spdy_config_overlay_;
00173   scoped_ptr<ApacheConfig> non_spdy_config_overlay_;
00174 
00176   scoped_ptr<ApacheConfig> spdy_specific_config_;
00177 
00180   RewriteDriverPool* spdy_driver_pool_;
00181 
00182   Histogram* html_rewrite_time_us_histogram_;
00183 
00187   scoped_ptr<AbstractMutex> cache_flush_mutex_;
00188   int64 last_cache_flush_check_sec_; 
00189 
00190   Variable* cache_flush_count_;
00191   Variable* cache_flush_timestamp_ms_;
00192 
00193   DISALLOW_COPY_AND_ASSIGN(ApacheServerContext);
00194 };
00195 
00196 }  
00197 
00198 #endif  ///< NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines