Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Attributes | List of all members
net_instaweb::StaticAssetManager Class Reference

#include "static_asset_manager.h"

Public Types

enum  StaticAsset {
  kAddInstrumentationJs, kBlankGif, kBlinkJs, kClientDomainRewriter,
  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 []
 

Detailed Description

Composes URLs for the javascript files injected by the various PSA filters.

Todo:

TODO(ksimbili): Refactor out the common base class to serve the static files of type css, images or html etc.

TODO(xqyin): Refactor out StaticAssetManager to have shared infrastructure used by both RewriteStaticAssetManager and SystemStaticAssetManager. Now the JS files in system/ are done directly in AdminSite.

Member Enumeration Documentation

Enumerator
kEndOfModules 

Keep this as the last enum value.

Member Function Documentation

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).


The documentation for this class was generated from the following file: