19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_LOCAL_STORAGE_CACHE_FILTER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_LOCAL_STORAGE_CACHE_FILTER_H_
24 #include "net/instaweb/rewriter/cached_result.pb.h"
28 #include "pagespeed/kernel/base/basictypes.h"
29 #include "pagespeed/kernel/base/statistics.h"
30 #include "pagespeed/kernel/base/string.h"
31 #include "pagespeed/kernel/base/string_util.h"
32 #include "pagespeed/kernel/html/html_element.h"
33 #include "pagespeed/kernel/html/html_filter.h"
35 namespace net_instaweb {
49 static const char kLscCookieName[];
54 static const char kStoredTotal[];
55 static const char kStoredImages[];
56 static const char kStoredCss[];
57 static const char kCandidatesAdded[];
58 static const char kCandidatesRemoved[];
63 InlineState() : initialized_(
false), enabled_(
false) {}
77 static void InitStats(Statistics* statistics);
80 virtual void EndDocument();
81 virtual void StartElementImpl(HtmlElement* element);
82 virtual void EndElementImpl(HtmlElement* element);
84 virtual const char* Name()
const {
return "LocalStorageCache"; }
85 virtual const char* id()
const {
86 return RewriteOptions::kLocalStorageCacheId;
89 std::set<StringPiece>* mutable_cookie_hashes() {
return &cookie_hashes_; }
109 RewriteDriver* driver,
110 bool skip_cookie_check,
111 HtmlElement* element,
123 const CachedResult& cached,
124 RewriteDriver* driver,
125 HtmlElement* element);
129 RewriteDriver* driver);
131 ScriptUsage GetScriptUsage()
const override {
return kWillInjectScripts; }
134 void InsertOurScriptElement(HtmlElement* before);
135 static bool IsHashInCookie(
const RewriteDriver* driver,
136 const StringPiece cookie_name,
137 const StringPiece hash,
138 std::set<StringPiece>* hash_set);
139 static GoogleString ExtractOtherImgAttributes(
const HtmlElement* element);
140 static GoogleString GenerateHashFromUrlAndElement(
const RewriteDriver* driver,
141 const StringPiece& lsc_url,
142 const HtmlElement* element);
145 bool script_inserted_;
147 bool script_needs_inserting_;
150 std::set<StringPiece> cookie_hashes_;
153 Variable* num_local_storage_cache_candidates_found_;
155 Variable* num_local_storage_cache_stored_total_;
157 Variable* num_local_storage_cache_stored_images_;
159 Variable* num_local_storage_cache_stored_css_;
161 Variable* num_local_storage_cache_candidates_added_;
163 Variable* num_local_storage_cache_candidates_removed_;
static bool AddLscAttributes(const StringPiece url, const CachedResult &cached, RewriteDriver *driver, HtmlElement *element)
static const char kCandidatesFound[]
Statistics' names.
Definition: local_storage_cache_filter.h:53
static bool AddStorableResource(const StringPiece &url, RewriteDriver *driver, bool skip_cookie_check, HtmlElement *element, InlineState *state)
Definition: local_storage_cache_filter.h:47
virtual void StartDocumentImpl()
static void RemoveLscAttributes(HtmlElement *element, RewriteDriver *driver)
Remove the LSC attributes from the given element.
Definition: rewrite_filter.h:35
Definition: rewrite_driver.h:98
State information for an inline filter using LSC.
Definition: local_storage_cache_filter.h:61
static const char kLscInitializer[]
public for the test harness only.
Definition: local_storage_cache_filter.h:50
static void InitStats(Statistics *statistics)
May be called multiple times, if there are multiple statistics objects.