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

#include "apache_server_context.h"

Inheritance diagram for net_instaweb::ApacheServerContext:
net_instaweb::SystemServerContext net_instaweb::ServerContext

Public Member Functions

 ApacheServerContext (ApacheRewriteDriverFactory *factory, server_rec *server, const StringPiece &version)
 
ApacheRewriteDriverFactoryapache_factory ()
 
ApacheConfigglobal_config ()
 
bool InitPath (const GoogleString &path)
 
ApacheConfigSpdyConfigOverlay ()
 
ApacheConfigNonSpdyConfigOverlay ()
 
bool has_spdy_config_overlay () const
 
bool has_non_spdy_config_overlay () const
 
void set_spdy_config_overlay (ApacheConfig *x)
 These two take ownership of their parameters.
 
void set_non_spdy_config_overlay (ApacheConfig *x)
 
virtual const ApacheConfigSpdyGlobalConfig () const
 
RewriteDriverPoolspdy_driver_pool ()
 
virtual void CollapseConfigOverlaysAndComputeSignatures ()
 
bool PoolDestroyed ()
 
const server_rec * server () const
 
virtual RewriteDriverPoolSelectDriverPool (bool using_spdy)
 Chooses a driver pool based on the request protocol.
 
virtual void MaybeApplySpdySessionFetcher (const RequestContextPtr &request, RewriteDriver *driver)
 Hook for implementations to support fetching directly from the spdy module.
 
ProxyFetchFactoryproxy_fetch_factory ()
 
void InitProxyFetchFactory ()
 
virtual bool ProxiesHtml () const
 
ApacheRequestContextNewApacheRequestContext (request_rec *request)
 
void ReportResourceNotFound (StringPiece message, request_rec *request)
 
void ReportStatisticsNotFound (StringPiece message, request_rec *request)
 
void ReportSlurpNotFound (StringPiece message, request_rec *request)
 
virtual GoogleString FormatOption (StringPiece option_name, StringPiece args)
 
- Public Member Functions inherited from net_instaweb::SystemServerContext
 SystemServerContext (RewriteDriverFactory *factory, StringPiece hostname, int port)
 
void SetCachePath (SystemCachePath *cache_path)
 
void FlushCacheIfNecessary ()
 
SystemRewriteOptionsglobal_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)
 
SystemCachePathcache_path ()
 
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)
 
AdminSiteadmin_site ()
 
- Public Member Functions inherited from net_instaweb::ServerContext
 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
 
RewriteDriverFactoryfactory () const
 
ThreadSynchronizer * thread_synchronizer ()
 
ExperimentMatcherexperiment_matcher ()
 
void ApplyInputCacheControl (const ResourceVector &inputs, ResponseHeaders *headers)
 
bool IsPagespeedResource (const GoogleUrl &url)
 Is this URL a ref to a Pagespeed resource?
 
const RewriteFilterFindFilterForDecoding (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)
 
UrlNamerurl_namer () const
 
void set_url_namer (UrlNamer *n)
 
RewriteOptionsManagerrewrite_options_manager () const
 
SHA1Signature * signature () const
 
void SetRewriteOptionsManager (RewriteOptionsManager *rom)
 Takes ownership of RewriteOptionsManager.
 
StaticAssetManagerstatic_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 ()
 
UrlAsyncFetcherDefaultSystemFetcher ()
 
UrlAsyncFetcherDefaultDistributedFetcher ()
 
Timer * timer () const
 
void set_timer (Timer *timer)
 Note: doesn't take ownership.
 
HTTPCachehttp_cache () const
 
void set_http_cache (HTTPCache *x)
 
void MakePagePropertyCache (PropertyStore *property_store)
 Creates PagePropertyCache object with the provided PropertyStore object.
 
PropertyCachepage_property_cache () const
 
const PropertyCache::Cohortdom_cohort () const
 
void set_dom_cohort (const PropertyCache::Cohort *c)
 
const PropertyCache::Cohortblink_cohort () const
 
void set_blink_cohort (const PropertyCache::Cohort *c)
 
const PropertyCache::Cohortbeacon_cohort () const
 
void set_beacon_cohort (const PropertyCache::Cohort *c)
 
const PropertyCache::Cohortfix_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)
 
CriticalCssFindercritical_css_finder () const
 
void set_critical_css_finder (CriticalCssFinder *finder)
 
CriticalImagesFindercritical_images_finder () const
 
void set_critical_images_finder (CriticalImagesFinder *finder)
 
CriticalSelectorFindercritical_selector_finder () const
 
void set_critical_selector_finder (CriticalSelectorFinder *finder)
 
FlushEarlyInfoFinderflush_early_info_finder () const
 
void set_flush_early_info_finder (FlushEarlyInfoFinder *finder)
 
UserAgentMatcher * user_agent_matcher () const
 
void set_user_agent_matcher (UserAgentMatcher *n)
 
CacheHtmlInfoFindercache_html_info_finder () const
 
SimpleRandom * simple_random ()
 
void set_cache_html_info_finder (CacheHtmlInfoFinder *finder)
 
CriticalLineInfoFindercritical_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)
 
RewriteStatsrewrite_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)
 
RewriteOptionsglobal_options ()
 
const RewriteOptionsglobal_options () const
 
void reset_global_options (RewriteOptions *options)
 
RewriteOptionsNewOptions ()
 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)
 
RewriteOptionsGetCustomOptions (RequestHeaders *request_headers, RewriteOptions *domain_options, RewriteOptions *query_options)
 
GoogleString GetRewriteOptionsSignatureHash (const RewriteOptions *options)
 
RewriteDriverNewRewriteDriver (const RequestContextPtr &request_ctx)
 
RewriteDriverNewRewriteDriverFromPool (RewriteDriverPool *pool, const RequestContextPtr &request_ctx)
 
RewriteDriverNewUnmanagedRewriteDriver (RewriteDriverPool *pool, RewriteOptions *options, const RequestContextPtr &request_ctx)
 
RewriteDriverNewCustomRewriteDriver (RewriteOptions *custom_options, const RequestContextPtr &request_ctx)
 
void ReleaseRewriteDriver (RewriteDriver *rewrite_driver)
 
ThreadSystem * thread_system ()
 
UsageDataReporterusage_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)
 
RewriteDriverPoolstandard_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)
 
RequestPropertiesNewRequestProperties ()
 Makes a new RequestProperties.
 
void DeleteCacheOnDestruction (CacheInterface *cache)
 
void set_cache_property_store (CachePropertyStore *p)
 
void set_decoding_driver (RewriteDriver *rd)
 
virtual PropertyStoreCreatePropertyStore (CacheInterface *cache_backend)
 Creates CachePropertyStore object which will be used by PagePropertyCache.
 
const PropertyCache::CohortAddCohort (const GoogleString &cohort_name, PropertyCache *pcache)
 
const PropertyCache::CohortAddCohortWithCache (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)
 

Static Public Member Functions

static void InitStats (Statistics *statistics)
 This must be called for every statistics object in use before using this.
 
- Static Public Member Functions inherited from net_instaweb::SystemServerContext
static void InitStats (Statistics *statistics)
 
- Static Public Member Functions inherited from net_instaweb::ServerContext
static bool ScanSplitHtmlRequest (const RequestContextPtr &ctx, const RewriteOptions *options, GoogleString *url)
 
static bool IsExcludedAttribute (const char *attribute)
 
static GoogleString ShowCacheForm (StringPiece user_agent)
 

Additional Inherited Members

- Public Types inherited from net_instaweb::ServerContext
typedef std::pair
< RewriteOptions *, bool > 
OptionsBoolPair
 
- Static Public Attributes inherited from net_instaweb::ServerContext
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.
 
- Protected Member Functions inherited from net_instaweb::SystemServerContext
void ConsoleJsonHandler (const QueryParams &params, 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 ()
 
- Protected Member Functions inherited from net_instaweb::ServerContext
void ManageRewriteDriverPool (RewriteDriverPool *pool)
 

Detailed Description

Creates an Apache-specific ServerContext. This differs from base class that it incorporates by adding per-VirtualHost configuration, including:

Member Function Documentation

virtual void net_instaweb::ApacheServerContext::CollapseConfigOverlaysAndComputeSignatures ( )
virtual

This should be called after all configuration parsing is done to collapse configuration inside the config overlays into actual ApacheConfig objects. It will also compute signatures when done.

Reimplemented from net_instaweb::SystemServerContext.

virtual GoogleString net_instaweb::ApacheServerContext::FormatOption ( StringPiece  option_name,
StringPiece  args 
)
virtual

Returns the format for specifying a configuration file option. E.g. for option_name="EnableCachePurge", args="on", returns: nginx: "pagespeed EnableCachePurge on;" apache: "ModPagespeed EnableCachePurge on" The base class simply returns "EnableCachePurge on".

Reimplemented from net_instaweb::ServerContext.

bool net_instaweb::ApacheServerContext::has_spdy_config_overlay ( ) const
inline

These return true if the given overlays were constructed (in response to having something in config files to put in them).

ApacheRequestContext* net_instaweb::ApacheServerContext::NewApacheRequestContext ( request_rec *  request)

Creates a request context which is suitable for resolving options, but is not yet suitable for establishing a context from which to do fetches. Establishing that context is slightly expensive so we want to only do that in request-paths that can lead to spdy fetches.

To enable a rewrite context for fetching, call apache_request_context->SetupSpdyConnectionIfNeeded(request); after the object is context is constructed.

bool net_instaweb::ApacheServerContext::PoolDestroyed ( )

Called on notification from Apache on child exit. Returns true if this is the last ServerContext that exists.

virtual bool net_instaweb::ApacheServerContext::ProxiesHtml ( ) const
inlinevirtual

We do not proxy external HTML from mod_pagespeed in Apache using the ProxyFetch flow. Currently we must rely on a separate module to let mod_pagespeed behave as an origin fetcher.

Implements net_instaweb::ServerContext.

void net_instaweb::ApacheServerContext::ReportResourceNotFound ( StringPiece  message,
request_rec *  request 
)
inline

Reports an error status to the HTTP resource request, and logs the error as a Warning to the log file, and bumps a stat as needed.

void net_instaweb::ApacheServerContext::ReportSlurpNotFound ( StringPiece  message,
request_rec *  request 
)
inline

Reports an error status to the HTTP slurp request, and logs the error as a Warning to the log file, and bumps a stat as needed.

void net_instaweb::ApacheServerContext::ReportStatisticsNotFound ( StringPiece  message,
request_rec *  request 
)
inline

Reports an error status to the HTTP statistics request, and logs the error as a Warning to the log file, and bumps a stat as needed.

RewriteDriverPool* net_instaweb::ApacheServerContext::spdy_driver_pool ( )
inline

Pool to pass to NewRewriteDriverFromPool to get a RewriteDriver configured with SPDY-specific options. May be NULL in case there is no spdy-specific configuration.

ApacheConfig* net_instaweb::ApacheServerContext::SpdyConfigOverlay ( )

These return configuration objects that hold settings from <ModPagespeedIf spdy>=""> and <ModPagespeedIf !spdy> sections of configuration. They initialize lazily, so are not thread-safe; however they are only meant to be used during configuration parsing. These methods should be called only if there is actually a need to put something in them, since otherwise we may end up constructing separate SPDY vs. non-SPDY configurations needlessly.

virtual const ApacheConfig* net_instaweb::ApacheServerContext::SpdyGlobalConfig ( ) const
inlinevirtual

Returns special configuration that should be used for SPDY sessions instead of global_config(). Returns NULL if global_config() should be used instead.

Reimplemented from net_instaweb::SystemServerContext.


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