Page Speed Optimization Libraries
1.8.31.3
|
#include "static_asset_manager.h"
Public Types | |
enum | StaticAsset { kAddInstrumentationJs, kBlankGif, kBlinkJs, kClientDomainRewriter, kConsoleCss, kConsoleJs, kCriticalCssBeaconJs, kCriticalCssLoaderJs, kCriticalImagesBeaconJs, kDedupInlinedImagesJs, kDeferIframe, kDeferJs, kDelayImagesInlineJs, kDelayImagesJs, kDeterministicJs, kExtendedInstrumentationJs, kGhostClickBusterJs, kLazyloadImagesJs, kLocalStorageCacheJs, kSplitHtmlBeaconJs, kEndOfModules } |
Public Member Functions | |
StaticAssetManager (const GoogleString &static_asset_base, Hasher *hasher, MessageHandler *message_handler) | |
const GoogleString & | GetAssetUrl (const StaticAsset &module, const RewriteOptions *options) const |
const char * | GetAsset (const StaticAsset &module, const RewriteOptions *options) const |
Returns the contents of the asset. | |
bool | GetAsset (StringPiece file_name, StringPiece *content, ContentType *content_type, StringPiece *cache_header) const |
void | AddJsToElement (StringPiece js, HtmlElement *script, RewriteDriver *driver) const |
void | set_gstatic_hash (const StaticAsset &module, const GoogleString &gstatic_base, const GoogleString &hash) |
void | set_serve_asset_from_gstatic (bool serve_asset_from_gstatic) |
void | set_library_url_prefix (const StringPiece &url_prefix) |
Set the prefix for the URLs of assets. | |
void | set_static_asset_base (const StringPiece &x) |
Static Public Attributes | |
static const char | kGStaticBase [] |
static const char | kDefaultLibraryUrlPrefix [] |
Composes URLs for the javascript files injected by the various PSA filters.
void net_instaweb::StaticAssetManager::AddJsToElement | ( | StringPiece | js, |
HtmlElement * | script, | ||
RewriteDriver * | driver | ||
) | const |
Add a CharacterNode to an already created script element, properly escaping the text with CDATA tags is necessary. The script element should be added already, say with a call to InsertNodeBeforeNode.
bool net_instaweb::StaticAssetManager::GetAsset | ( | StringPiece | file_name, |
StringPiece * | content, | ||
ContentType * | content_type, | ||
StringPiece * | cache_header | ||
) | const |
Get the asset to be served as external file for the file names file_name. The snippet is returned as 'content' and cache-control headers is set into cache_header. If the hash matches, then ttl is set to 1 year, or else set to 'private max-age=300'. Returns true iff the content for filename is found.
const GoogleString& net_instaweb::StaticAssetManager::GetAssetUrl | ( | const StaticAsset & | module, |
const RewriteOptions * | options | ||
) | const |
Returns the url based on the value of debug filter and the value of serve_asset_from_gstatic flag.
void net_instaweb::StaticAssetManager::set_gstatic_hash | ( | const StaticAsset & | module, |
const GoogleString & | gstatic_base, | ||
const GoogleString & | hash | ||
) |
If set_serve_asset_from_gstatic is true, update the URL for module to use gstatic.
void net_instaweb::StaticAssetManager::set_serve_asset_from_gstatic | ( | bool | serve_asset_from_gstatic | ) | [inline] |
Set serve_asset_from_gstatic_ to serve the files from gstatic. Note that files won't actually get served from gstatic until you also call set_gstatic_hash for the URL that you'd like served from gstatic. set_gstatic_hash should be called after calling set_server_asset_from_gstatic(true).