net_instaweb::CssFlattenImportsContext Class Reference

Context used by CssFilter under async flow that flattens . More...

#include "css_flatten_imports_context.h"

Inheritance diagram for net_instaweb::CssFlattenImportsContext:
net_instaweb::SingleRewriteContext net_instaweb::RewriteContext

List of all members.

Public Member Functions

 CssFlattenImportsContext (RewriteDriver *driver, RewriteContext *parent, CssFilter::Context *rewriter, CssHierarchy *hierarchy)
virtual GoogleString CacheKeySuffix () const
virtual void RewriteSingle (const ResourcePtr &input_resource, const OutputResourcePtr &output_resource)
 Subclasses of SingleRewriteContext must override this:
void Harvest ()
virtual void Render ()
virtual const char * id () const
 Returrns the filter ID.
virtual OutputResourceKind kind () const

Detailed Description

Context used by CssFilter under async flow that flattens .


Constructor & Destructor Documentation

net_instaweb::CssFlattenImportsContext::CssFlattenImportsContext ( RewriteDriver driver,
RewriteContext parent,
CssFilter::Context rewriter,
CssHierarchy hierarchy 
) [inline]

no resource_context


Member Function Documentation

virtual GoogleString net_instaweb::CssFlattenImportsContext::CacheKeySuffix (  )  const [inline, virtual]

Allows subclasses to add additional text to be appended to the metadata cache key. The default implementation returns "".

We have to include the media that applies to this context in its key so that, if someone 's the same file but with a different set of media on the rule, we don't fetch the cached file, since it has been minified based on the original set of applicable media.

Reimplemented from net_instaweb::RewriteContext.

void net_instaweb::CssFlattenImportsContext::Harvest (  )  [inline, 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.

Roll up the rewritten CSS(s) regardless of success or failure. Failure means we can't flatten it for some reason, such as incompatible charsets or invalid CSS, but we still need to cache the unflattened version so we don't try to flatten it again and again, so even in that case we don't return kRewriteFailed.

Our result is the combination of all our imports and our own rules.

Reimplemented from net_instaweb::RewriteContext.

virtual OutputResourceKind net_instaweb::CssFlattenImportsContext::kind (  )  const [inline, 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::CssFlattenImportsContext::Render (  )  [inline, 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 we have flattened the imported file ...

If Harvest() was called, directly or from RewriteSingle(), then the minified contents are already set as are the stylesheet and input contents - in that case we don't actually have to do anything. If they haven't been called then the minified contents are empty and the result was found in the cache, in which case we have to set the input and minified contents to this result; the minified because we know that cached values are minified (we only cache minified contents), the input because we will need that to generate the stylesheet from when RollUpStylesheets is eventually called.

Reimplemented from net_instaweb::RewriteContext.

virtual void net_instaweb::CssFlattenImportsContext::RewriteSingle ( const ResourcePtr input,
const OutputResourcePtr output 
) [inline, virtual]

Subclasses of SingleRewriteContext must override this:

If we cannot parse the CSS then we cannot flatten it.

< Initiates rewriting of 'd files.

< Harvest centralizes all the output generation.

Implements net_instaweb::SingleRewriteContext.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Tue May 29 16:33:57 2012 for Page Speed Optimization Libraries by  doxygen 1.6.3