Page Speed Optimization Libraries
1.4.26.1
|
Public Member Functions | |
Context (RewriteDriver *driver, CombiningFilter *filter, MockScheduler *scheduler) | |
void | AddElement (HtmlElement *element, HtmlElement::Attribute *href, const ResourcePtr &resource) |
Protected Member Functions | |
virtual bool | Partition (OutputPartitions *partitions, OutputResourceVector *outputs) |
virtual void | Rewrite (int partition_index, CachedResult *partition, const OutputResourcePtr &output) |
virtual bool | OptimizationOnly () const |
void | DoRewrite (int partition_index, CachedResult *partition, OutputResourcePtr output) |
virtual void | Render () |
void | DisableRemovedSlots (CachedResult *partition) |
virtual const UrlSegmentEncoder * | encoder () const |
virtual const char * | id () const |
Returns the filter ID. | |
virtual OutputResourceKind | kind () const |
virtual const UrlSegmentEncoder* net_instaweb::CombiningFilter::Context::encoder | ( | ) | const [inline, 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 OutputResourceKind net_instaweb::CombiningFilter::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 bool net_instaweb::CombiningFilter::Context::OptimizationOnly | ( | ) | const [inline, protected, virtual] |
If this returns true, running the rewriter isn't required for correctness of the page, so the engine will be permitted to drop the rewrite if needed to preserve system responsiveness.
Reimplemented from net_instaweb::RewriteContext.
virtual bool net_instaweb::CombiningFilter::Context::Partition | ( | OutputPartitions * | partitions, |
OutputResourceVector * | outputs | ||
) | [protected, virtual] |
Partitions the input resources into one or more outputs. Return 'true' if the partitioning could complete (whether a rewrite was found or not), false if the attempt was abandoned and no conclusion can be drawn.
Note that if partitioner finds that the resources are not rewritable, it will still return true; it will simply have an empty inputs-array in OutputPartitions and leave 'outputs' unmodified. 'false' is only returned if the subclass skipped the rewrite attempt due to a lock conflict.
You must override one of Partition() or PartitionAsync(). Partition() is normally fine unless you need to do computations that can take a noticeable amount of time, since there are some scenarios under which page output may end up being held up for a partitioning step. If you do need to do something computationally expensive in partitioning steps, override PartitionAsync() instead.
Reimplemented from net_instaweb::RewriteContext.
virtual void net_instaweb::CombiningFilter::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.
virtual void net_instaweb::CombiningFilter::Context::Rewrite | ( | int | partition_index, |
CachedResult * | partition, | ||
const OutputResourcePtr & | output | ||
) | [protected, virtual] |
Takes a completed rewrite partition and rewrites it. When complete calls RewriteDone with kRewriteOk if successful. Note that a value of kTooBusy means that an HTML rewrite will skip this resource, but we should not cache it as "do not optimize".
During this phase, any nested contexts that are needed to complete the Rewrite process can be instantiated.
Implements net_instaweb::RewriteContext.