Page Speed Optimization Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
net_instaweb::LocalStorageCacheFilter Class Reference
Inheritance diagram for net_instaweb::LocalStorageCacheFilter:
net_instaweb::RewriteFilter net_instaweb::CommonFilter net_instaweb::EmptyHtmlFilter net_instaweb::HtmlFilter


class  InlineState
 State information for an inline filter using LSC. More...

Public Member Functions

 LocalStorageCacheFilter (RewriteDriver *rewrite_driver)
virtual void StartDocumentImpl ()
virtual void EndDocument ()
virtual void StartElementImpl (HtmlElement *element)
virtual void EndElementImpl (HtmlElement *element)
virtual const char * Name () const
 The name of this filter – used for logging and debugging.
virtual const char * id () const
std::set< StringPiece > * mutable_cookie_hashes ()
ScriptUsage GetScriptUsage () const override
- Public Member Functions inherited from net_instaweb::RewriteFilter
 RewriteFilter (RewriteDriver *driver)
virtual void DetermineEnabled (GoogleString *disabled_reason)
virtual bool CanModifyUrls ()
virtual const UrlSegmentEncoderencoder () const
virtual bool ComputeOnTheFly () const
virtual RewriteContextMakeRewriteContext ()
virtual RewriteContextMakeNestedRewriteContext (RewriteContext *parent, const ResourceSlotPtr &slot)
virtual void EncodeUserAgentIntoResourceContext (ResourceContext *context) const
virtual const
RelatedFilters (int *num_filters) const
virtual const StringPieceVector * RelatedOptions () const
- Public Member Functions inherited from net_instaweb::CommonFilter
 CommonFilter (RewriteDriver *driver)
const GoogleUrlbase_url () const
 Getters. More...
const GoogleUrldecoded_base_url () const
RewriteDriverdriver () const
HtmlElementnoscript_element () const
void InsertNodeAtBodyEnd (HtmlNode *data)
virtual void StartDocument ()
 Note: Don't overload these methods, overload the implementers instead!
virtual void StartElement (HtmlElement *element)
virtual void EndElement (HtmlElement *element)
virtual void Characters (HtmlCharactersNode *characters)
ResourcePtr CreateInputResource (StringPiece input_url, RewriteDriver::InputRole role, bool *is_authorized)
ResourcePtr CreateInputResourceOrInsertDebugComment (StringPiece input_url, RewriteDriver::InputRole role, HtmlElement *element)
void ResolveUrl (StringPiece input_url, GoogleUrl *out_url)
bool IsRelativeUrlLoadPermittedByCsp (StringPiece url, CspDirective role)
bool BaseUrlIsValid () const
bool DebugMode () const
bool CanAddPagespeedOnloadToImage (const HtmlElement &)
virtual void LogFilterModifiedContent ()
AllowUnauthorizedDomain () const
virtual bool IntendedForInlining () const
void AddJsToElement (StringPiece js, HtmlElement *script)
- Public Member Functions inherited from net_instaweb::EmptyHtmlFilter
virtual void Cdata (HtmlCdataNode *cdata)
 Called for CDATA blocks (e.g. <![CDATA[foobar]]>)
virtual void Comment (HtmlCommentNode *comment)
 Called for HTML comments that aren't IE directives (e.g. ).
virtual void IEDirective (HtmlIEDirectiveNode *directive)
virtual void Directive (HtmlDirectiveNode *directive)
 Called for HTML directives (e.g. <!doctype foobar>).
virtual void Flush ()
ScriptUsage GetScriptUsage () const override
- Public Member Functions inherited from net_instaweb::HtmlFilter
virtual void RenderDone ()
bool is_enabled () const
void set_is_enabled (bool is_enabled)

Static Public Member Functions

static void InitStats (Statistics *statistics)
 May be called multiple times, if there are multiple statistics objects.
static bool AddStorableResource (const StringPiece &url, RewriteDriver *driver, bool skip_cookie_check, HtmlElement *element, InlineState *state)
static bool AddLscAttributes (const StringPiece url, const CachedResult &cached, RewriteDriver *driver, HtmlElement *element)
static void RemoveLscAttributes (HtmlElement *element, RewriteDriver *driver)
 Remove the LSC attributes from the given element.
- Static Public Member Functions inherited from net_instaweb::RewriteFilter
static StringPiece GetCharsetForScript (const Resource *script, const StringPiece attribute_charset, const StringPiece enclosing_charset)
static GoogleString GetCharsetForStylesheet (const Resource *stylesheet, const StringPiece attribute_charset, const StringPiece enclosing_charset)
- Static Public Member Functions inherited from net_instaweb::CommonFilter
static bool ExtractMetaTagDetails (const HtmlElement &element, const ResponseHeaders *headers, GoogleString *content, GoogleString *mime_type, GoogleString *charset)

Static Public Attributes

static const char kLscCookieName []
static const char kLscInitializer []
 public for the test harness only.
static const char kCandidatesFound []
 Statistics' names.
static const char kStoredTotal []
static const char kStoredImages []
static const char kStoredCss []
static const char kCandidatesAdded []
static const char kCandidatesRemoved []
- Static Public Attributes inherited from net_instaweb::CommonFilter
static const char kCreateResourceFailedDebugMsg []
 Debug message to be inserted when resource creation fails.

Additional Inherited Members

- Public Types inherited from net_instaweb::HtmlFilter
enum  ScriptUsage { kWillInjectScripts, kMayInjectScripts, kNeverInjectsScripts }
 Describes a filter's relationship with scripts. More...
- Protected Member Functions inherited from net_instaweb::RewriteFilter
virtual const char * LoggingId ()
 This class logs using id().
- Protected Member Functions inherited from net_instaweb::CommonFilter
ServerContextserver_context () const
const RewriteOptionsrewrite_options ()

Member Function Documentation

static bool net_instaweb::LocalStorageCacheFilter::AddLscAttributes ( const StringPiece  url,
const CachedResult &  cached,
RewriteDriver driver,
HtmlElement element 

Tell the LSC to add its attributes to the given element: data-pagespeed-lsc-hash and, if the resource has an expiry time [in cached], data-pagespeed-lsc-expiry. This is a no-op if LSC is disabled. url is the URL of the resource being rewritten. cached is the result of the resource rewrite. driver is the request's context. element is the element to update. Returns true if the element was updated.

static bool net_instaweb::LocalStorageCacheFilter::AddStorableResource ( const StringPiece &  url,
RewriteDriver driver,
bool  skip_cookie_check,
HtmlElement element,
InlineState state 

Tell the LSC that the resource with the given url is a candidate for storing in the browser's local storage. If LSC is disabled it's a no-op, otherwise it determines the LSC's version of the url and, if skip_cookie_check is true or the hash of the LSC's url is in the LSC's cookie, adds the LSC's url as an attribute of the given element, which the LSC later uses to tell that the element is suitable for storing in local cache. Returns true if the attribute was added. Saves various computed values in the given state variable for any subsequent call (a filter might need to call this method once with skip_cookie_check false, then again later with it true). url is the URL from the HTML element, src from img, href from style. driver is the request's context. is_enabled is set to true if the local storage cache filter is enabled. skip_cookie_check if true skips the checking of the cookie for the hash and adds the LSC's url attribute if LSC is enabled. element is the element to add the attribute to. state is where to save the computed values.

virtual void net_instaweb::LocalStorageCacheFilter::EndDocument ( )

Note: EndDocument will be called immediately before the last Flush call. (which also means that in the RewriteDriver use it is called before rendering for the last flush window).

Reimplemented from net_instaweb::EmptyHtmlFilter.

ScriptUsage net_instaweb::LocalStorageCacheFilter::GetScriptUsage ( ) const

Note: there is also kRequiresScriptExecutionFilterSet in, which identifies filters that will leave broken pages if javascript is disabled, and hence require noscript handing. The set of filters that CanInjectScripts is larger, as it includes filters that might inject beacons or other optional functionality that is not page-critical.

Implements net_instaweb::HtmlFilter.

virtual void net_instaweb::LocalStorageCacheFilter::StartDocumentImpl ( )

Overload these implementer methods: Intentionally left abstract so that implementers don't forget to change the name from Blah to BlahImpl.

Implements net_instaweb::CommonFilter.

The documentation for this class was generated from the following file: