Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | 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  ConfigurationMode { kInitialConfiguration, kUpdateConfiguration }
 

Public Member Functions

 StaticAssetManager (const GoogleString &static_asset_base, ThreadSystem *threads, Hasher *hasher, MessageHandler *message_handler)
 static_asset_base is path on this host we serve resources from.
 
bool IsValidIndex (size_t i) const
 Determines whether the specified index is a valid asset enum.
 
const GoogleStringGetAssetUrl (StaticAssetEnum::StaticAsset module, const RewriteOptions *options) const
 
const char * GetAsset (StaticAssetEnum::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 SetGStaticHashForTest (StaticAssetEnum::StaticAsset module, const GoogleString &hash)
 
void ServeAssetsFromGStatic (StringPiece gstatic_base)
 
void DoNotServeAssetsFromGStatic ()
 
void ApplyGStaticConfiguration (const StaticAssetConfig &config, ConfigurationMode mode)
 
void ResetGStaticConfiguration ()
 
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 Function Documentation

void net_instaweb::StaticAssetManager::ApplyGStaticConfiguration ( const StaticAssetConfig &  config,
ConfigurationMode  mode 
)

If serve_assets_from_gstatic_ is true, uses information in config to set up serving urls. mode == kInitialConfiguration will always overwrite settings. mode == kUpdateConfiguration will only update those which have a matching value of release_label, and expect a previous call with kInitialConfiguration.

Note that the computed config is always based on the last call with update mode applied on top of the initial config; multiple calls of update are not concatenated together.

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 ( StaticAssetEnum::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::ResetGStaticConfiguration ( )

If serve_assets_from_gstatic_ is true, reset configuration to what was last set by ApplyGStaticConfiguration with mod == kInitialConfiguration. Precondition: ApplyGStaticConfiguration(kInitialConfiguration) must have been called.

void net_instaweb::StaticAssetManager::ServeAssetsFromGStatic ( StringPiece  gstatic_base)
inline

Sets serve_assets_from_gstatic_ to true, enabling serving of files from gstatic, and configures the base URL. Note that files won't actually get served from gstatic until you also configure the particular assets this should apply to via SetGStaticHashForTest or ApplyGStaticConfiguration.

void net_instaweb::StaticAssetManager::SetGStaticHashForTest ( StaticAssetEnum::StaticAsset  module,
const GoogleString hash 
)

If serve_assets_from_gstatic_ is true, update the URL for module to use gstatic. This sets both debug and release versions, and is meant to be used to simplify tests.


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