Page Speed Optimization Libraries  1.8.31.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/rewriter/public/rewrite_stats.h"
00023 #include "net/instaweb/system/public/system_server_context.h"
00024 #include "net/instaweb/util/public/basictypes.h"
00025 #include "net/instaweb/util/public/scoped_ptr.h"
00026 #include "net/instaweb/util/public/string.h"
00027 #include "net/instaweb/util/public/string_util.h"
00028 #include "pagespeed/kernel/base/message_handler.h"
00029 
00030 struct request_rec;
00031 struct server_rec;
00032 
00033 namespace net_instaweb {
00034 
00035 class ApacheRewriteDriverFactory;
00036 class ApacheRequestContext;
00037 class ProxyFetchFactory;
00038 class RewriteDriverPool;
00039 class RewriteDriver;
00040 class Statistics;
00041 class Variable;
00042 
00049 class ApacheServerContext : public SystemServerContext {
00050  public:
00051   ApacheServerContext(ApacheRewriteDriverFactory* factory,
00052                       server_rec* server,
00053                       const StringPiece& version);
00054   virtual ~ApacheServerContext();
00055 
00057   static void InitStats(Statistics* statistics);
00058 
00059   ApacheRewriteDriverFactory* apache_factory() { return apache_factory_; }
00060   ApacheConfig* global_config();
00061   bool InitPath(const GoogleString& path);
00062 
00070   ApacheConfig* SpdyConfigOverlay();
00071   ApacheConfig* NonSpdyConfigOverlay();
00072 
00075   bool has_spdy_config_overlay() const {
00076     return spdy_config_overlay_.get() != NULL;
00077   }
00078 
00079   bool has_non_spdy_config_overlay() const {
00080     return non_spdy_config_overlay_.get() != NULL;
00081   }
00082 
00084   void set_spdy_config_overlay(ApacheConfig* x) {
00085     spdy_config_overlay_.reset(x);
00086   }
00087 
00088   void set_non_spdy_config_overlay(ApacheConfig* x) {
00089     non_spdy_config_overlay_.reset(x);
00090   }
00091 
00095   virtual const ApacheConfig* SpdyGlobalConfig() const {
00096     return spdy_specific_config_.get();
00097   }
00098 
00102   RewriteDriverPool* spdy_driver_pool() { return spdy_driver_pool_; }
00103 
00107   virtual void CollapseConfigOverlaysAndComputeSignatures();
00108 
00111   bool PoolDestroyed();
00112 
00113   const server_rec* server() const { return server_rec_; }
00114 
00115   virtual RewriteDriverPool* SelectDriverPool(bool using_spdy);
00116 
00118   virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request,
00119                                             RewriteDriver* driver);
00120 
00121   ProxyFetchFactory* proxy_fetch_factory() {
00122     return proxy_fetch_factory_.get();
00123   }
00124 
00125   void InitProxyFetchFactory();
00126 
00130   virtual bool ProxiesHtml() const { return false; }
00131 
00141   ApacheRequestContext* NewApacheRequestContext(request_rec* request);
00142 
00146   void ReportResourceNotFound(StringPiece message, request_rec* request) {
00147     ReportNotFoundHelper(kWarning, message, request,
00148                          rewrite_stats()->resource_404_count());
00149   }
00150 
00154   void ReportStatisticsNotFound(StringPiece message, request_rec* request) {
00155     ReportNotFoundHelper(kWarning, message, request, statistics_404_count());
00156   }
00157 
00161   void ReportSlurpNotFound(StringPiece message, request_rec* request) {
00162     ReportNotFoundHelper(kInfo, message, request,
00163                          rewrite_stats()->slurp_404_count());
00164   }
00165 
00166  private:
00167   virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00168 
00169   void ReportNotFoundHelper(MessageType message_type,
00170                             StringPiece url,
00171                             request_rec* request,
00172                             Variable* error_count);
00173 
00174   ApacheRewriteDriverFactory* apache_factory_;
00175   server_rec* server_rec_;
00176   GoogleString version_;
00177 
00180   scoped_ptr<ApacheConfig> spdy_config_overlay_;
00181   scoped_ptr<ApacheConfig> non_spdy_config_overlay_;
00182 
00184   scoped_ptr<ApacheConfig> spdy_specific_config_;
00185 
00188   RewriteDriverPool* spdy_driver_pool_;
00189 
00190   scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
00191 
00192   DISALLOW_COPY_AND_ASSIGN(ApacheServerContext);
00193 };
00194 
00195 }  
00196 
00197 #endif  ///< NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines