Page Speed Optimization Libraries  1.7.30.3
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 Histogram;
00032 class SharedMemStatistics;
00033 class RewriteDriver;
00034 class RewriteDriverFactory;
00035 class RewriteStats;
00036 class Statistics;
00037 class SystemRewriteDriverFactory;
00038 class SystemRewriteOptions;
00039 class UrlAsyncFetcherStats;
00040 class Variable;
00041 
00043 class SystemServerContext : public ServerContext {
00044  public:
00045   SystemServerContext(RewriteDriverFactory* factory,
00046                       StringPiece hostname, int port);
00047   virtual ~SystemServerContext();
00048 
00057   void FlushCacheIfNecessary();
00058 
00059   SystemRewriteOptions* global_system_rewrite_options();
00060   GoogleString hostname_identifier() { return hostname_identifier_; }
00061 
00062   static void InitStats(Statistics* statistics);
00063 
00065   virtual void ChildInit(SystemRewriteDriverFactory* factory);
00066 
00070   void CreateLocalStatistics(Statistics* global_statistics,
00071                              SystemRewriteDriverFactory* factory);
00072 
00075   bool initialized() const { return initialized_; }
00076 
00088   virtual void ApplySessionFetchers(const RequestContextPtr& req,
00089                                     RewriteDriver* driver);
00090 
00093   void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
00094 
00099   virtual void CollapseConfigOverlaysAndComputeSignatures();
00100 
00101  protected:
00114   virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
00115 
00117   virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request,
00118                                             RewriteDriver* driver) {}
00119 
00120   Variable* statistics_404_count();
00121 
00122  private:
00123   bool initialized_;
00124 
00128   scoped_ptr<AbstractMutex> cache_flush_mutex_;
00129   int64 last_cache_flush_check_sec_; 
00130 
00131   Variable* cache_flush_count_;
00132   Variable* cache_flush_timestamp_ms_;
00133 
00134   Histogram* html_rewrite_time_us_histogram_;
00135 
00137   scoped_ptr<Statistics> split_statistics_;
00138 
00140   SharedMemStatistics* local_statistics_;
00141 
00143   scoped_ptr<RewriteStats> local_rewrite_stats_;
00144   scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
00145 
00149   GoogleString hostname_identifier_;
00150 
00151   DISALLOW_COPY_AND_ASSIGN(SystemServerContext);
00152 };
00153 
00154 }  
00155 
00156 #endif  ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines