Page Speed Optimization Libraries
1.7.30.2
|
#include "single_rewrite_context.h"
Public Member Functions | |
SingleRewriteContext (RewriteDriver *driver, RewriteContext *parent, ResourceContext *resource_context) | |
Protected Member Functions | |
virtual void | RewriteSingle (const ResourcePtr &input, const OutputResourcePtr &output)=0 |
Subclasses of SingleRewriteContext must override this: | |
virtual bool | Partition (OutputPartitions *partitions, OutputResourceVector *outputs) |
SingleRewriteContext takes care of these methods from RewriteContext: | |
virtual void | Rewrite (int partition_index, CachedResult *partition, const OutputResourcePtr &output) |
Class that unifies tasks common to building rewriters for filters that only do one-for-one URL substitutions.
net_instaweb::SingleRewriteContext::SingleRewriteContext | ( | RewriteDriver * | driver, |
RewriteContext * | parent, | ||
ResourceContext * | resource_context | ||
) |
Transfers ownership of resource_context, which must be NULL or allocated with 'new'.
virtual void net_instaweb::SingleRewriteContext::Rewrite | ( | int | partition_index, |
CachedResult * | partition, | ||
const OutputResourcePtr & | output | ||
) | [protected, virtual] |
Takes a completed rewrite partition and rewrites it. When complete, implementations should call RewriteDone(kRewriteOk) if they successfully created an output resource using RewriteDriver::Write, and RewriteDone(kRewriteFailed) if they didn't. They may also call RewriteDone(kTooBusy) in case system load/resource usage makes it dangerous for the filter to do optimization at this time.
Any information about the inputs or output that may be needed to update the containing document should be stored inside the CachedResult.
If implementors wish to rewrite resources referred to from within the inputs (e.g. images in CSS), they may create nested rewrite contexts and call AddNestedContext() on each, and then StartNestedTasks() when all have been added.
Implements net_instaweb::RewriteContext.