19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_LOCAL_STORAGE_CACHE_FILTER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_LOCAL_STORAGE_CACHE_FILTER_H_
30 namespace net_instaweb {
50 static const char kLscCookieName[];
55 static const char kStoredTotal[];
56 static const char kStoredImages[];
57 static const char kStoredCss[];
58 static const char kCandidatesAdded[];
59 static const char kCandidatesRemoved[];
64 InlineState() : initialized_(
false), enabled_(
false) {}
78 static void InitStats(Statistics* statistics);
81 virtual void EndDocument();
82 virtual void StartElementImpl(HtmlElement* element);
83 virtual void EndElementImpl(HtmlElement* element);
85 virtual const char* Name()
const {
return "LocalStorageCache"; }
86 virtual const char* id()
const {
87 return RewriteOptions::kLocalStorageCacheId;
90 std::set<StringPiece>* mutable_cookie_hashes() {
return &cookie_hashes_; }
110 RewriteDriver* driver,
111 bool skip_cookie_check,
112 HtmlElement* element,
124 const CachedResult& cached,
125 RewriteDriver* driver,
126 HtmlElement* element);
130 RewriteDriver* driver);
133 void InsertOurScriptElement(HtmlElement* before);
134 static bool IsHashInCookie(
const RewriteDriver* driver,
135 const StringPiece cookie_name,
136 const StringPiece hash,
137 std::set<StringPiece>* hash_set);
138 static GoogleString ExtractOtherImgAttributes(
const HtmlElement* element);
139 static GoogleString GenerateHashFromUrlAndElement(
const RewriteDriver* driver,
140 const StringPiece& lsc_url,
141 const HtmlElement* element);
144 bool script_inserted_;
146 bool script_needs_inserting_;
149 std::set<StringPiece> cookie_hashes_;
152 Variable* num_local_storage_cache_candidates_found_;
154 Variable* num_local_storage_cache_stored_total_;
156 Variable* num_local_storage_cache_stored_images_;
158 Variable* num_local_storage_cache_stored_css_;
160 Variable* num_local_storage_cache_candidates_added_;
162 Variable* num_local_storage_cache_candidates_removed_;
164 DISALLOW_COPY_AND_ASSIGN(LocalStorageCacheFilter);
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:54
static bool AddStorableResource(const StringPiece &url, RewriteDriver *driver, bool skip_cookie_check, HtmlElement *element, InlineState *state)
Definition: local_storage_cache_filter.h:48
virtual void StartDocumentImpl()
static void RemoveLscAttributes(HtmlElement *element, RewriteDriver *driver)
Remove the LSC attributes from the given element.
Definition: rewrite_filter.h:37
Definition: rewrite_driver.h:98
State information for an inline filter using LSC.
Definition: local_storage_cache_filter.h:62
static const char kLscInitializer[]
public for the test harness only.
Definition: local_storage_cache_filter.h:51
static void InitStats(Statistics *statistics)
May be called multiple times, if there are multiple statistics objects.