19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_STATIC_ASSET_MANAGER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_STATIC_ASSET_MANAGER_H_
26 #include "net/instaweb/rewriter/static_asset_config.pb.h"
32 #include "pagespeed/kernel/base/thread_annotations.h"
36 namespace net_instaweb {
50 static const char kGStaticBase[];
51 static const char kDefaultLibraryUrlPrefix[];
53 enum ConfigurationMode {
54 kInitialConfiguration,
69 bool valid = (i <= assets_.size()) && (assets_[i]->file_name !=
nullptr);
80 const char*
GetAsset(StaticAssetEnum::StaticAsset module,
88 bool GetAsset(StringPiece file_name, StringPiece* content,
89 ContentType* content_type, StringPiece* cache_header)
const;
103 serve_assets_from_gstatic_ =
true;
104 gstatic_base.CopyToString(&gstatic_base_);
107 void DoNotServeAssetsFromGStatic() {
109 serve_assets_from_gstatic_ =
false;
110 gstatic_base_.clear();
124 ConfigurationMode mode);
135 url_prefix.CopyToString(&library_url_prefix_);
136 InitializeAssetUrls();
139 void set_static_asset_base(
const StringPiece& x) {
141 x.CopyToString(&static_asset_base_);
142 InitializeAssetUrls();
149 const char* file_name;
157 ContentType content_type;
160 typedef std::map<GoogleString, StaticAssetEnum::StaticAsset>
163 void InitializeAssetStrings();
164 void InitializeAssetUrls() EXCLUSIVE_LOCKS_REQUIRED(lock_);
170 void ApplyGStaticConfigurationImpl(const StaticAssetConfig& config,
171 ConfigurationMode mode)
172 EXCLUSIVE_LOCKS_REQUIRED(lock_);
177 MessageHandler* message_handler_;
179 scoped_ptr<ThreadSystem::RWLock> lock_;
180 std::vector<Asset*> assets_ GUARDED_BY(lock_);
181 FileNameToModuleMap file_name_to_module_map_ GUARDED_BY(lock_);
183 bool serve_assets_from_gstatic_ GUARDED_BY(lock_);
185 scoped_ptr<StaticAssetConfig> initial_gstatic_config_ GUARDED_BY(lock_);
187 GoogleString cache_header_with_long_ttl_ GUARDED_BY(lock_);
188 GoogleString cache_header_with_private_ttl_ GUARDED_BY(lock_);
void SetGStaticHashForTest(StaticAssetEnum::StaticAsset module, const GoogleString &hash)
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.
void ResetGStaticConfiguration()
Definition: static_asset_manager.h:48
bool IsValidIndex(size_t i) const
Determines whether the specified index is a valid asset enum.
Definition: static_asset_manager.h:67
void set_library_url_prefix(const StringPiece &url_prefix)
Set the prefix for the URLs of assets.
Definition: static_asset_manager.h:133
void ServeAssetsFromGStatic(StringPiece gstatic_base)
Definition: static_asset_manager.h:101
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Helper class for lexically scoped mutexing.
Definition: abstract_mutex.h:46
const char * GetAsset(StaticAssetEnum::StaticAsset module, const RewriteOptions *options) const
Returns the contents of the asset.
const GoogleString & GetAssetUrl(StaticAssetEnum::StaticAsset module, const RewriteOptions *options) const
Definition: content_type.h:31
Definition: thread_system.h:40
Definition: message_handler.h:39
void ApplyGStaticConfiguration(const StaticAssetConfig &config, ConfigurationMode mode)
Definition: rewrite_options.h:84