Page Speed Optimization Libraries
1.7.30.2
|
Context used by CssFilter under async flow. More...
#include "css_filter.h"
Public Member Functions | |
Context (CssFilter *filter, RewriteDriver *driver, RewriteContext *parent, CacheExtender *cache_extender, ImageRewriteFilter *image_rewriter, ImageCombineFilter *image_combiner, ResourceContext *context) | |
void | SetupInlineRewrite (HtmlElement *style_element, HtmlCharactersNode *text) |
Setup rewriting for inline, attribute, or external CSS. | |
void | SetupAttributeRewrite (HtmlElement *element, HtmlElement::Attribute *src, InlineCssKind inline_css_kind) |
void | SetupExternalRewrite (HtmlElement *element, const GoogleUrl &base_gurl, const GoogleUrl &trim_gurl) |
void | RewriteCssFromNested (RewriteContext *parent, CssHierarchy *hierarchy) |
virtual bool | AbsolutifyIfNeeded (const StringPiece &input_contents, Writer *writer, MessageHandler *handler) |
CssResourceSlotFactory * | slot_factory () |
CssHierarchy * | mutable_hierarchy () |
Protected Member Functions | |
virtual void | Render () |
virtual void | Harvest () |
virtual bool | Partition (OutputPartitions *partitions, OutputResourceVector *outputs) |
SingleRewriteContext takes care of these methods from RewriteContext: | |
virtual void | RewriteSingle (const ResourcePtr &input, const OutputResourcePtr &output) |
Subclasses of SingleRewriteContext must override this: | |
virtual const char * | id () const |
Returns the filter ID. | |
virtual OutputResourceKind | kind () const |
virtual GoogleString | CacheKeySuffix () const |
virtual const UrlSegmentEncoder * | encoder () const |
virtual GoogleString | UserAgentCacheKey (const ResourceContext *resource_context) const |
Implements UserAgentCacheKey method of RewriteContext. |
virtual bool net_instaweb::CssFilter::Context::AbsolutifyIfNeeded | ( | const StringPiece & | input_contents, |
Writer * | writer, | ||
MessageHandler * | handler | ||
) | [virtual] |
Specialization to absolutify URLs in input resource in case of rewrite fail or deadline exceeded.
Reimplemented from net_instaweb::RewriteContext.
virtual GoogleString net_instaweb::CssFilter::Context::CacheKeySuffix | ( | ) | const [protected, virtual] |
Allows subclasses to add additional text to be appended to the metadata cache key. The default implementation returns "".
Reimplemented from net_instaweb::RewriteContext.
virtual const UrlSegmentEncoder* net_instaweb::CssFilter::Context::encoder | ( | ) | const [protected, virtual] |
This final set of protected methods can be optionally overridden by subclasses. All RewriteContexts define how they encode URLs and other associated information needed for a rewrite into a URL. The default implementation handles a single URL with no extra data. The RewriteContext owns the encoder.
Reimplemented from net_instaweb::RewriteContext.
virtual void net_instaweb::CssFilter::Context::Harvest | ( | ) | [protected, virtual] |
Once any nested rewrites have completed, the results of these can be incorporated into the rewritten data. For contexts that do not require any nested RewriteContexts, it is OK to skip overriding this method -- the empty default implementation is fine.
Reimplemented from net_instaweb::RewriteContext.
virtual OutputResourceKind net_instaweb::CssFilter::Context::kind | ( | ) | const [inline, protected, virtual] |
Rewrites come in three flavors, as described in output_resource_kind.h, so this method must be defined by subclasses to indicate which it is.
For example, we will avoid caching output_resource content in the HTTP cache for rewrites that are so quick to complete that it's fine to do the rewrite on every request. extend_cache is obviously in this category, and it's arguable we could treat js minification that way too (though we don't at the moment).
Implements net_instaweb::RewriteContext.
virtual void net_instaweb::CssFilter::Context::Render | ( | ) | [protected, virtual] |
Performs rendering activities that span multiple HTML slots. For example, in a filter that combines N slots to 1, N-1 of the HTML elements might need to be removed. That can be performed in Render(). This method is optional; the base-class implementation is empty.
Note that unlike Harvest(), this method runs in the HTML thread (for top-level rewrites), and only runs if the rewrite completes prior to the rewrite-deadline. If the rewrite does make it by the deadline, RewriteContext::Render() will be invoked regardless of whether any slots were actually optimized successfully.
Reimplemented from net_instaweb::RewriteContext.
void net_instaweb::CssFilter::Context::RewriteCssFromNested | ( | RewriteContext * | parent, |
CssHierarchy * | hierarchy | ||
) |
Starts nested rewrite jobs for any imports or images contained in the CSS. Marked public, so that it's accessible from CssHierarchy.