Page Speed Optimization Libraries
1.9.32.1
|
A server context with features specific to a PSOL port on a unix system. More...
#include "system_server_context.h"
Public Member Functions | |
SystemServerContext (RewriteDriverFactory *factory, StringPiece hostname, int port) | |
void | SetCachePath (SystemCachePath *cache_path) |
void | FlushCacheIfNecessary () |
SystemRewriteOptions * | global_system_rewrite_options () |
GoogleString | hostname_identifier () |
void | UpdateCachePurgeSet (const CopyOnWrite< PurgeSet > &purge_set) |
virtual void | PostInitHook () |
Initialize this SystemServerContext to set up its admin site. | |
virtual void | ChildInit (SystemRewriteDriverFactory *factory) |
Called by SystemRewriteDriverFactory::ChildInit. See documentation there. | |
void | CreateLocalStatistics (Statistics *global_statistics, SystemRewriteDriverFactory *factory) |
bool | initialized () const |
virtual void | ApplySessionFetchers (const RequestContextPtr &req, RewriteDriver *driver) |
void | AddHtmlRewriteTimeUs (int64 rewrite_time_us) |
SystemCachePath * | cache_path () |
virtual void | CollapseConfigOverlaysAndComputeSignatures () |
virtual const SystemRewriteOptions * | SpdyGlobalConfig () const |
void | ConsoleHandler (const SystemRewriteOptions &options, AdminSite::AdminSource source, const QueryParams &query_params, AsyncFetch *fetch) |
void | MessageHistoryHandler (const RewriteOptions &options, AdminSite::AdminSource source, AsyncFetch *fetch) |
Displays recent Info/Warning/Error messages. | |
void | StatisticsGraphsHandler (Writer *writer) |
Deprecated handler for graphs in the PSOL console. | |
void | AdminPage (bool is_global, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch) |
void | StatisticsPage (bool is_global, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch) |
AdminSite * | admin_site () |
![]() | |
ServerContext (RewriteDriverFactory *factory) | |
void | SetDefaultLongCacheHeaders (const ContentType *content_type, StringPiece charset, StringPiece cache_control_suffix, ResponseHeaders *header) const |
void | set_filename_prefix (const StringPiece &file_prefix) |
void | set_statistics (Statistics *x) |
void | set_rewrite_stats (RewriteStats *x) |
void | set_lock_manager (NamedLockManager *x) |
void | set_enable_property_cache (bool enabled) |
void | set_message_handler (MessageHandler *x) |
StringPiece | filename_prefix () const |
Statistics * | statistics () const |
NamedLockManager * | lock_manager () const |
RewriteDriverFactory * | factory () const |
ThreadSynchronizer * | thread_synchronizer () |
ExperimentMatcher * | experiment_matcher () |
void | ApplyInputCacheControl (const ResourceVector &inputs, ResponseHeaders *headers) |
bool | IsPagespeedResource (const GoogleUrl &url) |
Is this URL a ref to a Pagespeed resource? | |
const RewriteFilter * | FindFilterForDecoding (const StringPiece &id) const |
bool | DecodeUrlGivenOptions (const GoogleUrl &url, const RewriteOptions *options, const UrlNamer *url_namer, StringVector *decoded_urls) const |
See RewriteDriver::DecodeUrl. | |
void | ComputeSignature (RewriteOptions *rewrite_options) const |
Hasher * | hasher () const |
const Hasher * | lock_hasher () const |
const Hasher * | contents_hasher () const |
FileSystem * | file_system () |
void | set_file_system (FileSystem *fs) |
UrlNamer * | url_namer () const |
void | set_url_namer (UrlNamer *n) |
RewriteOptionsManager * | rewrite_options_manager () const |
SHA1Signature * | signature () const |
void | SetRewriteOptionsManager (RewriteOptionsManager *rom) |
Takes ownership of RewriteOptionsManager. | |
StaticAssetManager * | static_asset_manager () const |
void | set_static_asset_manager (StaticAssetManager *manager) |
Scheduler * | scheduler () const |
void | set_scheduler (Scheduler *s) |
bool | has_default_system_fetcher () const |
bool | has_default_distributed_fetcher () |
UrlAsyncFetcher * | DefaultSystemFetcher () |
UrlAsyncFetcher * | DefaultDistributedFetcher () |
Timer * | timer () const |
void | set_timer (Timer *timer) |
Note: doesn't take ownership. | |
HTTPCache * | http_cache () const |
void | set_http_cache (HTTPCache *x) |
void | MakePagePropertyCache (PropertyStore *property_store) |
Creates PagePropertyCache object with the provided PropertyStore object. | |
PropertyCache * | page_property_cache () const |
const PropertyCache::Cohort * | dom_cohort () const |
void | set_dom_cohort (const PropertyCache::Cohort *c) |
const PropertyCache::Cohort * | blink_cohort () const |
void | set_blink_cohort (const PropertyCache::Cohort *c) |
const PropertyCache::Cohort * | beacon_cohort () const |
void | set_beacon_cohort (const PropertyCache::Cohort *c) |
const PropertyCache::Cohort * | fix_reflow_cohort () const |
void | set_fix_reflow_cohort (const PropertyCache::Cohort *c) |
CacheInterface * | filesystem_metadata_cache () const |
void | set_filesystem_metadata_cache (CacheInterface *x) |
CacheInterface * | metadata_cache () const |
void | set_metadata_cache (CacheInterface *x) |
CriticalCssFinder * | critical_css_finder () const |
void | set_critical_css_finder (CriticalCssFinder *finder) |
CriticalImagesFinder * | critical_images_finder () const |
void | set_critical_images_finder (CriticalImagesFinder *finder) |
CriticalSelectorFinder * | critical_selector_finder () const |
void | set_critical_selector_finder (CriticalSelectorFinder *finder) |
FlushEarlyInfoFinder * | flush_early_info_finder () const |
void | set_flush_early_info_finder (FlushEarlyInfoFinder *finder) |
UserAgentMatcher * | user_agent_matcher () const |
void | set_user_agent_matcher (UserAgentMatcher *n) |
CacheHtmlInfoFinder * | cache_html_info_finder () const |
SimpleRandom * | simple_random () |
void | set_cache_html_info_finder (CacheHtmlInfoFinder *finder) |
CriticalLineInfoFinder * | critical_line_info_finder () const |
void | set_critical_line_info_finder (CriticalLineInfoFinder *finder) |
Takes ownership of the passed in finder. | |
bool | store_outputs_in_file_system () |
void | set_store_outputs_in_file_system (bool store) |
RewriteStats * | rewrite_stats () const |
MessageHandler * | message_handler () const |
NamedLock * | MakeCreationLock (const GoogleString &name) |
NamedLock * | MakeInputLock (const GoogleString &name) |
Makes a lock used for fetching and optimizing an input resource. | |
bool | TryLockForCreation (NamedLock *creation_lock) |
Attempt to obtain a named lock without blocking. Return true if we do so. | |
void | LockForCreation (NamedLock *creation_lock, QueuedWorkerPool::Sequence *worker, Function *callback) |
void | set_hasher (Hasher *hasher) |
Setters should probably only be used in testing. | |
void | set_signature (SHA1Signature *signature) |
void | set_default_system_fetcher (UrlAsyncFetcher *fetcher) |
void | set_default_distributed_fetcher (UrlAsyncFetcher *fetcher) |
bool | HandleBeacon (StringPiece body, StringPiece user_agent, const RequestContextPtr &request_context) |
RewriteOptions * | global_options () |
const RewriteOptions * | global_options () const |
void | reset_global_options (RewriteOptions *options) |
RewriteOptions * | NewOptions () |
Makes a new, empty set of RewriteOptions. | |
bool | GetQueryOptions (const RequestContextPtr &request_context, const RewriteOptions *domain_options, GoogleUrl *request_url, RequestHeaders *request_headers, ResponseHeaders *response_headers, RewriteQuery *rewrite_query) |
RewriteOptions * | GetCustomOptions (RequestHeaders *request_headers, RewriteOptions *domain_options, RewriteOptions *query_options) |
GoogleString | GetRewriteOptionsSignatureHash (const RewriteOptions *options) |
RewriteDriver * | NewRewriteDriver (const RequestContextPtr &request_ctx) |
RewriteDriver * | NewRewriteDriverFromPool (RewriteDriverPool *pool, const RequestContextPtr &request_ctx) |
RewriteDriver * | NewUnmanagedRewriteDriver (RewriteDriverPool *pool, RewriteOptions *options, const RequestContextPtr &request_ctx) |
RewriteDriver * | NewCustomRewriteDriver (RewriteOptions *custom_options, const RequestContextPtr &request_ctx) |
void | ReleaseRewriteDriver (RewriteDriver *rewrite_driver) |
ThreadSystem * | thread_system () |
UsageDataReporter * | usage_data_reporter () |
void | set_shutting_down () |
bool | shutting_down () const |
void | ShutDownDrivers () |
void | MergeNonCachingResponseHeaders (const ResourcePtr &input, const OutputResourcePtr &output) |
void | MergeNonCachingResponseHeaders (const ResponseHeaders &input_headers, ResponseHeaders *output_headers) |
Entry-point with the same functionality, exposed for easier testing. | |
QueuedWorkerPool * | html_workers () |
Pool of worker-threads that can be used to handle html-parsing. | |
QueuedWorkerPool * | rewrite_workers () |
Pool of worker-threads that can be used to handle resource rewriting. | |
QueuedWorkerPool * | low_priority_rewrite_workers () |
size_t | num_active_rewrite_drivers () |
void | InitWorkers () |
bool | response_headers_finalized () const |
void | set_response_headers_finalized (bool x) |
RewriteDriverPool * | standard_rewrite_driver_pool () |
const GoogleString & | hostname () const |
Returns the current server hostname. | |
void | set_hostname (const GoogleString &x) |
void | AddOriginalContentLengthHeader (const ResourceVector &inputs, ResponseHeaders *headers) |
virtual RewriteDriverPool * | SelectDriverPool (bool using_spdy) |
Chooses a driver pool based on the request protocol. | |
virtual bool | ProxiesHtml () const =0 |
RequestProperties * | NewRequestProperties () |
Makes a new RequestProperties. | |
void | DeleteCacheOnDestruction (CacheInterface *cache) |
void | set_cache_property_store (CachePropertyStore *p) |
void | set_decoding_driver (RewriteDriver *rd) |
virtual PropertyStore * | CreatePropertyStore (CacheInterface *cache_backend) |
Creates CachePropertyStore object which will be used by PagePropertyCache. | |
const PropertyCache::Cohort * | AddCohort (const GoogleString &cohort_name, PropertyCache *pcache) |
const PropertyCache::Cohort * | AddCohortWithCache (const GoogleString &cohort_name, CacheInterface *cache, PropertyCache *pcache) |
const CacheInterface * | pcache_cache_backend () |
const pagespeed::js::JsTokenizerPatterns * | js_tokenizer_patterns () const |
void | ShowCacheHandler (StringPiece url, AsyncFetch *fetch, RewriteOptions *options) |
virtual GoogleString | FormatOption (StringPiece option_name, StringPiece args) |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
![]() | |
static bool | ScanSplitHtmlRequest (const RequestContextPtr &ctx, const RewriteOptions *options, GoogleString *url) |
static bool | IsExcludedAttribute (const char *attribute) |
static GoogleString | ShowCacheForm (StringPiece user_agent) |
Protected Member Functions | |
virtual bool | UpdateCacheFlushTimestampMs (int64 timestamp_ms) |
virtual void | MaybeApplySpdySessionFetcher (const RequestContextPtr &request, RewriteDriver *driver) |
Hook for implementations to support fetching directly from the spdy module. | |
void | ConsoleJsonHandler (const QueryParams ¶ms, AsyncFetch *fetch) |
Returns JSON used by the PageSpeed Console JavaScript. | |
void | StatisticsHandler (const RewriteOptions &options, bool is_global_request, AdminSite::AdminSource source, AsyncFetch *fetch) |
void | PrintSpdyConfig (AdminSite::AdminSource source, AsyncFetch *fetch) |
Print details fo the SPDY configuration. | |
void | PrintNormalConfig (AdminSite::AdminSource source, AsyncFetch *fetch) |
Print details fo the non-SPDY configuration. | |
void | PrintCaches (bool is_global, AdminSite::AdminSource source, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch) |
void | PrintHistograms (bool is_global_request, AdminSite::AdminSource source, AsyncFetch *fetch) |
Print histograms showing the dynamics of server activity. | |
Variable * | statistics_404_count () |
![]() | |
void | ManageRewriteDriverPool (RewriteDriverPool *pool) |
Additional Inherited Members | |
![]() | |
typedef std::pair < RewriteOptions *, bool > | OptionsBoolPair |
![]() | |
static const int64 | kGeneratedMaxAgeMs |
The lifetime for cache-extended generated resources, in milliseconds. | |
static const int64 | kCacheTtlForMismatchedContentMs |
Short lifetime for generated resources fetched with mismatching hash. | |
static const char | kResourceEtagValue [] |
static const char | kCacheKeyResourceNamePrefix [] |
static const char | kStatisticsGroup [] |
Default statistics group name. | |
A server context with features specific to a PSOL port on a unix system.
net_instaweb::SystemServerContext::SystemServerContext | ( | RewriteDriverFactory * | factory, |
StringPiece | hostname, | ||
int | port | ||
) |
Identifies whether the user arrived at an admin page from a /pagespeed_admin handler or a /**_pagespeed_statistics handler. The main difference between these is that the _admin site might in the future grant more privileges than the statistics site did, such as flushing cache. But it also affects the syntax of the links created to sub-pages in the top navigation bar.
void net_instaweb::SystemServerContext::AddHtmlRewriteTimeUs | ( | int64 | rewrite_time_us | ) |
Accumulate in a histogram the amount of time spent rewriting HTML.
void net_instaweb::SystemServerContext::AdminPage | ( | bool | is_global, |
const GoogleUrl & | stripped_gurl, | ||
const QueryParams & | query_params, | ||
const RewriteOptions * | options, | ||
AsyncFetch * | fetch | ||
) |
Handle a request for /pagespeed_admin/**, which is a launching point for all the administrator pages including stats, message-histogram, console, etc.
|
virtual |
Normally we just fetch with the default UrlAsyncFetcher, generally serf, but there are some cases where we need to do something more complex:
Reimplemented from net_instaweb::ServerContext.
|
virtual |
Hook called after all configuration parsing is done to support implementers like ApacheServerContext that need to collapse configuration inside the config overlays into actual RewriteOptions objects. It will also compute signatures when done, and by default that's the only thing it does.
Reimplemented in net_instaweb::ApacheServerContext.
void net_instaweb::SystemServerContext::ConsoleHandler | ( | const SystemRewriteOptions & | options, |
AdminSite::AdminSource | source, | ||
const QueryParams & | query_params, | ||
AsyncFetch * | fetch | ||
) |
Handler which serves PSOL console. Note: ConsoleHandler always succeeds.
void net_instaweb::SystemServerContext::CreateLocalStatistics | ( | Statistics * | global_statistics, |
SystemRewriteDriverFactory * | factory | ||
) |
Initialize this ServerContext to have its own statistics domain. Must be called after global_statistics has been created and had ::InitStats called on it.
void net_instaweb::SystemServerContext::FlushCacheIfNecessary | ( | ) |
Implementations should call this method on every request, both for html and resources, to avoid serving stale resources.
|
inline |
Whether ChildInit() has been called yet. Exposed so debugging code can verify initialization proceeded properly.
|
protected |
Print statistics about the caches. In the future this will also be a launching point for examining cache entries and purging them.
|
virtual |
Returns the spdy-specific configuration, or NULL if there is none specified.
Reimplemented in net_instaweb::ApacheServerContext.
|
protected |
Handler for /mod_pagespeed_statistics and /ngx_pagespeed_statistics, as well as /...pagespeed__global_statistics. If the latter, is_global_request should be true.
Returns NULL on success, otherwise the returned error string should be passed along to the user and the contents of writer and content_type should be ignored.
In systems without a spdy-specific config, spdy_config should be null.
void net_instaweb::SystemServerContext::StatisticsPage | ( | bool | is_global, |
const QueryParams & | query_params, | ||
const RewriteOptions * | options, | ||
AsyncFetch * | fetch | ||
) |
Handle a request for the legacy /**_pagespeed_statistics page, which also serves as a launching point for a subset of the admin pages. Because the admin pages are not uniformly sensitive, an existing PageSpeed user might have granted public access to /mod_pagespeed_statistics, but we don't want that to automatically imply access to the server cache.
|
protectedvirtual |
Flush the cache by updating the cache flush timestamp in the global options. This will change its signature, which is part of the cache key, and so all previously cached entries will be unreachable.
Returns true if it actually updated the timestamp, false if the existing cache flush timestamp was newer or the same as the one provided.
Subclasses which add aditional configurations need to override this method to additionally update the cache flush timestamp in those other configurations. See ApacheServerContext::UpdateCacheFlushTimestampMs where the separate SpdyConfig that mod_pagespeed uses when using SPDY also needs to have it's timestamp bumped.
void net_instaweb::SystemServerContext::UpdateCachePurgeSet | ( | const CopyOnWrite< PurgeSet > & | purge_set | ) |
Updates the PurgeSet with a new version. This is called when the system picks up (by polling or API) a new version of the cache.purge file.