Page Speed Optimization Libraries  1.7.30.4
net/instaweb/system/public/system_server_context.h
Go to the documentation of this file.
00001 // Copyright 2013 Google Inc.
00016 
00017 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
00018 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
00019 
00020 #include "net/instaweb/rewriter/public/server_context.h"
00021 
00022 #include "net/instaweb/http/public/request_context.h"
00023 #include "net/instaweb/util/public/basictypes.h"
00024 #include "net/instaweb/util/public/scoped_ptr.h"
00025 #include "pagespeed/kernel/base/string_util.h"
00026 #include "pagespeed/kernel/base/string.h"
00027 
00028 namespace net_instaweb {
00029 
00030 class AbstractMutex;
00031 class AsyncFetch;
00032 class ContentType;
00033 class Histogram;
00034 class RewriteDriver;
00035 class RewriteDriverFactory;
00036 class RewriteStats;
00037 class SharedMemStatistics;
00038 class Statistics;
00039 class SystemCaches;
00040 class SystemRewriteDriverFactory;
00041 class SystemRewriteOptions;
00042 class UrlAsyncFetcherStats;
00043 class Variable;
00044 class Writer;
00045 
00047 class SystemServerContext : public ServerContext {
00048  public:
00049   SystemServerContext(RewriteDriverFactory* factory,
00050                       StringPiece hostname, int port);
00051   virtual ~SystemServerContext();
00052 
00061   void FlushCacheIfNecessary();
00062 
00063   SystemRewriteOptions* global_system_rewrite_options();
00064   GoogleString hostname_identifier() { return hostname_identifier_; }
00065 
00066   static void InitStats(Statistics* statistics);
00067 
00069   virtual void ChildInit(SystemRewriteDriverFactory* factory);
00070 
00074   void CreateLocalStatistics(Statistics* global_statistics,
00075                              SystemRewriteDriverFactory* factory);
00076 
00079   bool initialized() const { return initialized_; }
00080 
00092   virtual void ApplySessionFetchers(const RequestContextPtr& req,
00093                                     RewriteDriver* driver);
00094 
00097   void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
00098 
00103   virtual void CollapseConfigOverlaysAndComputeSignatures();
00104 
00107   void ConsoleHandler(const SystemRewriteOptions& options, AsyncFetch* fetch);
00108 
00110   void MessageHistoryHandler(AsyncFetch* fetch);
00111 
00113   void StatisticsGraphsHandler(Writer* writer);
00114 
00126   const char* StatisticsHandler(
00127       SystemCaches* caches,
00128       Statistics* stats,
00129       SystemRewriteOptions* spdy_config,  
00130       StringPiece query_params,
00131       ContentType* content_type,
00132       Writer* writer);
00133 
00134  protected:
00147   virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00148 
00150   virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request,
00151                                             RewriteDriver* driver) {}
00152 
00153   Variable* statistics_404_count();
00154 
00155  private:
00156   bool initialized_;
00157 
00161   scoped_ptr<AbstractMutex> cache_flush_mutex_;
00162   int64 last_cache_flush_check_sec_; 
00163 
00164   Variable* cache_flush_count_;
00165   Variable* cache_flush_timestamp_ms_;
00166 
00167   Histogram* html_rewrite_time_us_histogram_;
00168 
00170   scoped_ptr<Statistics> split_statistics_;
00171 
00173   SharedMemStatistics* local_statistics_;
00174 
00176   scoped_ptr<RewriteStats> local_rewrite_stats_;
00177   scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
00178 
00182   GoogleString hostname_identifier_;
00183 
00184   DISALLOW_COPY_AND_ASSIGN(SystemServerContext);
00185 };
00186 
00187 }  
00188 
00189 #endif  ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines