Page Speed Optimization Libraries  1.7.30.3
net/instaweb/automatic/public/cache_html_flow.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2013 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http:///www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00019 
00020 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_CACHE_HTML_FLOW_H_
00021 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_CACHE_HTML_FLOW_H_
00022 
00023 #include "net/instaweb/rewriter/cache_html_info.pb.h"
00024 #include "net/instaweb/util/public/google_url.h"
00025 #include "net/instaweb/util/public/basictypes.h"
00026 #include "net/instaweb/util/public/scoped_ptr.h"
00027 #include "net/instaweb/util/public/string.h"
00028 
00029 namespace net_instaweb {
00030 
00031 class AbstractLogRecord;
00032 class AsyncFetch;
00033 class FallbackPropertyPage;
00034 class MessageHandler;
00035 class PropertyPage;
00036 class ProxyFetchPropertyCallbackCollector;
00037 class ProxyFetchFactory;
00038 class ServerContext;
00039 class RewriteOptions;
00040 class RewriteDriver;
00041 class Statistics;
00042 class TimedVariable;
00043 
00054 class CacheHtmlFlow {
00055  public:
00056   class LogHelper;
00057 
00060   static const char kBackgroundComputationDone[];
00061 
00062   static void Start(const GoogleString& url,
00063                     AsyncFetch* base_fetch,
00064                     RewriteDriver* driver,
00065                     ProxyFetchFactory* factory,
00066                     ProxyFetchPropertyCallbackCollector* property_callback);
00067 
00068   virtual ~CacheHtmlFlow();
00069 
00070   static void InitStats(Statistics* statistics);
00071 
00072   static const char kNumCacheHtmlHits[];
00073   static const char kNumCacheHtmlMisses[];
00074   static const char kNumCacheHtmlMatches[];
00075   static const char kNumCacheHtmlMismatches[];
00076   static const char kNumCacheHtmlMismatchesCacheDeletes[];
00077   static const char kNumCacheHtmlSmartdiffMatches[];
00078   static const char kNumCacheHtmlSmartdiffMismatches[];
00079 
00080  private:
00081   CacheHtmlFlow(const GoogleString& url,
00082                 AsyncFetch* base_fetch,
00083                 RewriteDriver* driver,
00084                 ProxyFetchFactory* factory,
00085                 ProxyFetchPropertyCallbackCollector* property_callback);
00086 
00087   void CacheHtmlLookupDone();
00088 
00089   void Cancel();
00090 
00092   void CacheHtmlRewriteDone(bool flushed_split_js);
00093 
00099   void CacheHtmlHit(FallbackPropertyPage* page);
00100 
00103   void CacheHtmlMiss();
00104 
00106   void TriggerProxyFetch();
00107 
00110   void PopulateCacheHtmlInfo(PropertyPage* page);
00111 
00112   GoogleString url_;
00113   GoogleUrl google_url_;
00114   AsyncFetch* base_fetch_;
00117   scoped_ptr<AbstractLogRecord> cache_html_log_record_;
00118   RewriteDriver* rewrite_driver_;
00119   const RewriteOptions* options_;
00120   ProxyFetchFactory* factory_;
00121   ServerContext* server_context_;
00122   ProxyFetchPropertyCallbackCollector* property_cache_callback_;
00123   MessageHandler* handler_;
00124   CacheHtmlInfo cache_html_info_;
00125   scoped_ptr<LogHelper> cache_html_log_helper_;
00126 
00127   TimedVariable* num_cache_html_misses_;
00128   TimedVariable* num_cache_html_hits_;
00129 
00130   DISALLOW_COPY_AND_ASSIGN(CacheHtmlFlow);
00131 };
00132 
00133 }  
00134 
00135 #endif  ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_CACHE_HTML_FLOW_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines