Page Speed Optimization Libraries  1.7.30.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/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* 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 
00094   ApacheConfig* SpdyConfig() { return spdy_specific_config_.get(); }
00095 
00099   RewriteDriverPool* spdy_driver_pool() { return spdy_driver_pool_; }
00100 
00104   virtual void CollapseConfigOverlaysAndComputeSignatures();
00105 
00108   bool PoolDestroyed();
00109 
00110   const server_rec* server() const { return server_rec_; }
00111 
00112   virtual RewriteDriverPool* SelectDriverPool(bool using_spdy);
00113 
00115   virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request,
00116                                             RewriteDriver* driver);
00117 
00118   ProxyFetchFactory* proxy_fetch_factory() {
00119     return proxy_fetch_factory_.get();
00120   }
00121 
00122   void InitProxyFetchFactory();
00123 
00127   virtual bool ProxiesHtml() const { return false; }
00128 
00129   ApacheRequestContext* NewApacheRequestContext(request_rec* request);
00130 
00134   void ReportResourceNotFound(StringPiece message, request_rec* request) {
00135     ReportNotFoundHelper(kWarning, message, request,
00136                          rewrite_stats()->resource_404_count());
00137   }
00138 
00142   void ReportStatisticsNotFound(StringPiece message, request_rec* request) {
00143     ReportNotFoundHelper(kWarning, message, request, statistics_404_count());
00144   }
00145 
00149   void ReportSlurpNotFound(StringPiece message, request_rec* request) {
00150     ReportNotFoundHelper(kInfo, message, request,
00151                          rewrite_stats()->slurp_404_count());
00152   }
00153 
00154  private:
00155   virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00156 
00157   void ReportNotFoundHelper(MessageType message_type,
00158                             StringPiece url,
00159                             request_rec* request,
00160                             Variable* error_count);
00161 
00162   ApacheRewriteDriverFactory* apache_factory_;
00163   server_rec* server_rec_;
00164   GoogleString version_;
00165 
00168   scoped_ptr<ApacheConfig> spdy_config_overlay_;
00169   scoped_ptr<ApacheConfig> non_spdy_config_overlay_;
00170 
00172   scoped_ptr<ApacheConfig> spdy_specific_config_;
00173 
00176   RewriteDriverPool* spdy_driver_pool_;
00177 
00178   scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
00179 
00180   DISALLOW_COPY_AND_ASSIGN(ApacheServerContext);
00181 };
00182 
00183 }  
00184 
00185 #endif  ///< NET_INSTAWEB_APACHE_APACHE_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines