Page Speed Optimization Libraries
1.13.35.1
|
#include "single_rewrite_context.h"
Public Member Functions | |
SingleRewriteContext (RewriteDriver *driver, RewriteContext *parent, ResourceContext *resource_context) | |
Public Member Functions inherited from net_instaweb::RewriteContext | |
RewriteContext (RewriteDriver *driver, RewriteContext *parent, ResourceContext *resource_context) | |
int | num_slots () const |
ResourceSlotPtr | slot (int index) const |
int | num_outputs () const |
OutputResourcePtr | output (int i) const |
int | num_output_partitions () const |
const CachedResult * | output_partition (int i) const |
CachedResult * | mutable_output_partition (int i) |
bool | chained () const |
void | AddSlot (const ResourceSlotPtr &slot) |
void | RemoveLastSlot () |
void | AddNestedContext (RewriteContext *context) |
void | CallFetchInputs () |
void | CallLockFailed () |
void | CallStartFetchImpl () |
void | Initiate () |
bool | Fetch (const OutputResourcePtr &output_resource, AsyncFetch *fetch, MessageHandler *message_handler) |
bool | slow () const |
bool | is_metadata_cache_miss () const |
This particular rewrite was a metadata cache miss. | |
bool | has_parent () const |
Returns true if this is a nested rewriter. | |
bool | IsNestedIn (StringPiece id) const |
void | CheckNotFrozen () |
RewriteContext * | parent () |
Allows a nested rewriter to walk up its parent hierarchy. | |
const RewriteContext * | parent () const |
int | num_nested () const |
Accessors for the nested rewrites. | |
RewriteContext * | nested (int i) const |
RewriteDriver * | Driver () const |
void | set_force_rewrite (bool x) |
If called with true, forces a rewrite and re-generates the output. | |
bool | rewrite_uncacheable () const |
void | set_rewrite_uncacheable (bool rewrite_uncacheable) |
const ResourceContext * | resource_context () const |
GoogleString | ToString () const |
Returns debug information about this RewriteContext. | |
GoogleString | ToStringWithPrefix (StringPiece prefix) const |
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) |
void | AddLinkRelCanonical (const ResourcePtr &input, ResponseHeaders *output) |
Adds a link: rel=canonical header pointing to the input URL as canonical. | |
void | AddLinkRelCanonicalForFallbackHeaders (ResponseHeaders *output) |
Helper for using above in FixFetchFallbackHeaders() | |
Protected Member Functions inherited from net_instaweb::RewriteContext | |
ServerContext * | FindServerContext () const |
const RewriteOptions * | Options () const |
OutputPartitions * | partitions () |
void | AddRecheckDependency () |
virtual bool | OptimizationOnly () const |
virtual void | PartitionAsync (OutputPartitions *partitions, OutputResourceVector *outputs) |
void | PartitionDone (RewriteResult result) |
void | CrossThreadPartitionDone (RewriteResult result) |
void | RewriteDone (RewriteResult result, int partition_index) |
virtual bool | SendFallbackResponse (StringPiece output_url_base, StringPiece contents, AsyncFetch *async_fetch, MessageHandler *handler) |
void | StartNestedTasks () |
virtual void | Harvest () |
virtual bool | PolicyPermitsRendering () const =0 |
bool | AreOutputsAllowedByCsp (CspDirective role) const |
Helper that checks that all output resources are OK with CSP as given role. | |
virtual void | Render () |
virtual void | WillNotRender () |
virtual void | Cancel () |
virtual const UrlSegmentEncoder * | encoder () const |
virtual GoogleString | CacheKeySuffix () const |
virtual GoogleString | UserAgentCacheKey (const ResourceContext *context) const |
virtual void | EncodeUserAgentIntoResourceContext (ResourceContext *context) |
virtual const char * | id () const =0 |
Returns the filter ID. | |
virtual OutputResourceKind | kind () const =0 |
void | AttachDependentRequestTrace (const StringPiece &label) |
RequestTrace * | dependent_request_trace () |
void | TracePrintf (const char *fmt,...) |
virtual void | StartFetchReconstruction () |
void | DetachFetch () |
virtual bool | DecodeFetchUrls (const OutputResourcePtr &output_resource, MessageHandler *message_handler, GoogleUrlStarVector *url_vector) |
virtual void | FixFetchFallbackHeaders (const CachedResult &cached_result, ResponseHeaders *headers) |
virtual void | FetchCallbackDone (bool success) |
virtual void | FetchTryFallback (const GoogleString &url, const StringPiece &hash) |
void | Freshen () |
Freshens resources proactively to avoid expiration in the near future. | |
bool | notify_driver_on_fetch_done () const |
void | set_notify_driver_on_fetch_done (bool value) |
AsyncFetch * | async_fetch () |
Note that the following must only be called in the fetch flow. | |
bool | FetchContextDetached () |
Is fetch_ detached? Only call this in the fetch flow. | |
MessageHandler * | fetch_message_handler () |
The message handler for the fetch. | |
bool | stale_rewrite () const |
Indicates whether we are serving a stale rewrite. | |
virtual int64 | GetRewriteDeadlineAlarmMs () const |
virtual bool | CreationLockBeforeStartFetch () const |
Should the context call LockForCreation before checking the cache? | |
virtual bool | FailOnHashMismatch () const |
virtual bool | ScheduleViaCentralController () |
virtual bool | ScheduleNestedContextViaCentalController () const |
void | ObtainLockForCreation (ServerContext *server_context, Function *callback) |
void | ReleaseCreationLock (bool succeeded) |
Additional Inherited Members | |
Public Types inherited from net_instaweb::RewriteContext | |
typedef std::vector< InputInfo * > | InputInfoStarVector |
Static Public Member Functions inherited from net_instaweb::RewriteContext | |
static void | InitStats (Statistics *stats) |
Initializes statistics. | |
Static Public Attributes inherited from net_instaweb::RewriteContext | |
static const char | kNumRewritesAbandonedForLockContention [] |
static const char | kNumDeadlineAlarmInvocations [] |
static const char | kHashMismatchMessage [] |
Protected Types inherited from net_instaweb::RewriteContext | |
typedef std::vector< GoogleUrl * > | GoogleUrlStarVector |
Static Protected Member Functions inherited from net_instaweb::RewriteContext | |
static bool | LookupMetadataForOutputResourceImpl (OutputResourcePtr output_resource, const GoogleUrl &gurl, RewriteContext *rewrite_context, RewriteDriver *driver, GoogleString *error_out, CacheLookupResultCallback *callback) |
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'.
|
protectedvirtual |
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.