Page Speed Optimization Libraries
1.13.35.1
|
#include "resource_combiner.h"
Public Member Functions | |
ResourceCombiner (RewriteDriver *rewrite_driver, const StringPiece &extension, RewriteFilter *filter) | |
Note: extension should not include the leading dot here. | |
void | Reset () |
GoogleString | UrlSafeId () const |
int | num_urls () const |
Returns the number of URLs that have been successfully added. | |
const ResourceVector & | resources () const |
GoogleString | ResolvedBase () const |
Base common to all URLs. Always has a trailing slash. | |
TimedBool | AddResourceNoFetch (const ResourcePtr &resource, MessageHandler *handler) |
Static Public Attributes | |
static const int | kUrlSlack = 100 |
Protected Member Functions | |
virtual void | RemoveLastResource () |
OutputResourcePtr | Combine (MessageHandler *handler) |
virtual bool | WriteCombination (const ResourceVector &combine_resources, const OutputResourcePtr &combination, MessageHandler *handler) |
virtual bool | WritePiece (int index, int num_pieces, const Resource *input, OutputResource *combination, Writer *writer, MessageHandler *handler) |
virtual void | Clear () |
Protected Attributes | |
ServerContext *const | server_context_ |
RewriteDriver *const | rewrite_driver_ |
Friends | |
class | AggregateCombiner |
This class is a utility for filters that combine multiple resource files into one. It provides two major pieces of functionality to help out: 1) It keeps a ResourceVector and provides methods to keep track of resources and URLs that can be safely combined together while encoding the information on the pieces in the combined URL. 2) It implements Fetch, reconstructing combinations as needed.
TimedBool net_instaweb::ResourceCombiner::AddResourceNoFetch | ( | const ResourcePtr & | resource, |
MessageHandler * | handler | ||
) |
|
protectedvirtual |
Override this if you need to remove some state whenever Reset() is called. Your implementation must call the superclass.
|
protected |
Returns one resource containing the combination of all added resources, creating it if necessary. Caller takes ownership. Returns NULL if the combination does not exist and cannot be created. Will not combine fewer than 2 resources.
|
protectedvirtual |
Removes the last resource that was added here, assuming the last call to AddResource was successful. If the last call to AddResource returned false, behavior is undefined.
void net_instaweb::ResourceCombiner::Reset | ( | ) |
Resets the current combiner to an empty state, incorporating the base URL. Make sure this gets called before documents — on a ::Flush() is enough. If a subclass needs to do some of its own reseting, see Clear().
GoogleString net_instaweb::ResourceCombiner::UrlSafeId | ( | ) | const |
Computes a name for the URL that meets all known character-set and size restrictions.
|
protectedvirtual |
Override this if your combination is not a matter of combining text pieces (perhaps adjusted by WritePiece).
|
protectedvirtual |
Override this to alter how pieces are processed when included inside a combination. Returns whether successful. The default implementation writes input->contents() to the writer without any alteration. 'index' is the position of this piece in the combination, while num_pieces is the total number of pieces.
Reimplemented in net_instaweb::CombiningFilter::Combiner.
|
static |
Slack to leave in URL size, so that other filters running afterwards can expand the URLs without going over maximum allowed sizes.
Why 100? First example I saw, CssFilter expanded a CssCombined URL by 36 chars. So 100 seemed like a nice round number to allow two filters to run after this and then for there still be a little slack.