Page Speed Optimization Libraries
1.7.30.3
|
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 ApacheConfig* SpdyGlobalConfig() { return spdy_specific_config_.get(); } 00096 00100 RewriteDriverPool* spdy_driver_pool() { return spdy_driver_pool_; } 00101 00105 virtual void CollapseConfigOverlaysAndComputeSignatures(); 00106 00109 bool PoolDestroyed(); 00110 00111 const server_rec* server() const { return server_rec_; } 00112 00113 virtual RewriteDriverPool* SelectDriverPool(bool using_spdy); 00114 00116 virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request, 00117 RewriteDriver* driver); 00118 00119 ProxyFetchFactory* proxy_fetch_factory() { 00120 return proxy_fetch_factory_.get(); 00121 } 00122 00123 void InitProxyFetchFactory(); 00124 00128 virtual bool ProxiesHtml() const { return false; } 00129 00130 ApacheRequestContext* NewApacheRequestContext(request_rec* request); 00131 00135 void ReportResourceNotFound(StringPiece message, request_rec* request) { 00136 ReportNotFoundHelper(kWarning, message, request, 00137 rewrite_stats()->resource_404_count()); 00138 } 00139 00143 void ReportStatisticsNotFound(StringPiece message, request_rec* request) { 00144 ReportNotFoundHelper(kWarning, message, request, statistics_404_count()); 00145 } 00146 00150 void ReportSlurpNotFound(StringPiece message, request_rec* request) { 00151 ReportNotFoundHelper(kInfo, message, request, 00152 rewrite_stats()->slurp_404_count()); 00153 } 00154 00155 private: 00156 virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms); 00157 00158 void ReportNotFoundHelper(MessageType message_type, 00159 StringPiece url, 00160 request_rec* request, 00161 Variable* error_count); 00162 00163 ApacheRewriteDriverFactory* apache_factory_; 00164 server_rec* server_rec_; 00165 GoogleString version_; 00166 00169 scoped_ptr<ApacheConfig> spdy_config_overlay_; 00170 scoped_ptr<ApacheConfig> non_spdy_config_overlay_; 00171 00173 scoped_ptr<ApacheConfig> spdy_specific_config_; 00174 00177 RewriteDriverPool* spdy_driver_pool_; 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_