Page Speed Optimization Libraries  1.8.31.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
net_instaweb::SystemServerContext Class Reference

A server context with features specific to a PSOL port on a unix system. More...

#include "system_server_context.h"

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

List of all members.

Public Types

enum  AdminSource { kPageSpeedAdmin, kStatistics, kOther }

Public Member Functions

 SystemServerContext (RewriteDriverFactory *factory, StringPiece hostname, int port)
void FlushCacheIfNecessary ()
SystemRewriteOptionsglobal_system_rewrite_options ()
GoogleString hostname_identifier ()
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)
virtual void CollapseConfigOverlaysAndComputeSignatures ()
virtual const
SystemRewriteOptions
SpdyGlobalConfig () const
void ConsoleHandler (const SystemRewriteOptions &options, AdminSource source, const QueryParams &query_params, AsyncFetch *fetch)
void MessageHistoryHandler (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)

Static Public Member Functions

static void InitStats (Statistics *statistics)

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 &params, AsyncFetch *fetch)
 Returns JSON used by the PageSpeed Console JavaScript.
void StatisticsHandler (bool is_global_request, AdminSource source, AsyncFetch *fetch)
void PrintSpdyConfig (AdminSource source, AsyncFetch *fetch)
 Print details fo the SPDY configuration.
void PrintNormalConfig (AdminSource source, AsyncFetch *fetch)
 Print details fo the non-SPDY configuration.
void PrintCaches (bool is_global, AdminSource source, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
void PrintHistograms (bool is_global_request, AdminSource source, AsyncFetch *fetch)
 Print histograms showing the dynamics of server activity.
Variable * statistics_404_count ()

Detailed Description

A server context with features specific to a PSOL port on a unix system.


Member Enumeration Documentation

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.


Member Function Documentation

Accumulate in a histogram the amount of time spent rewriting HTML.

Todo:
TODO(sligocki): Remove in favor of RewriteStats::rewrite_latency_histogram.
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 void net_instaweb::SystemServerContext::ApplySessionFetchers ( const RequestContextPtr &  req,
RewriteDriver driver 
) [virtual]

Normally we just fetch with the default UrlAsyncFetcher, generally serf, but there are some cases where we need to do something more complex:

  • Local requests: requests for resources on this host should go directly to the local IP.
  • Fetches directly from other modules: in Apache we have an experimental pathway where we can make fetches directly from mod_spdy without going out to the network.
  • Custom fetch headers: before continuing with the fetch we want to add request headers. Session fetchers allow us to make these decisions. Here we may update driver->async_fetcher() to be a special fetcher just for this request.

Reimplemented from net_instaweb::ServerContext.

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

Implementations should call this method on every request, both for html and resources, to avoid serving stale resources.

Todo:
TODO(jmarantz): allow a URL-based mechanism to flush cache, even if we implement it by simply writing the cache.flush file so other servers can see it. Note that using shared-memory is not a great plan because we need the cache-invalidation to persist across server restart.

Whether ChildInit() has been called yet. Exposed so debugging code can verify initialization proceeded properly.

void net_instaweb::SystemServerContext::PrintCaches ( bool  is_global,
AdminSource  source,
const QueryParams &  query_params,
const RewriteOptions options,
AsyncFetch fetch 
) [protected]

Print statistics about the caches. In the future this will also be a launching point for examining cache entries and purging them.

Returns the spdy-specific configuration, or NULL if there is none specified.

Reimplemented in net_instaweb::ApacheServerContext.

void net_instaweb::SystemServerContext::StatisticsHandler ( bool  is_global_request,
AdminSource  source,
AsyncFetch fetch 
) [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.

virtual bool net_instaweb::SystemServerContext::UpdateCacheFlushTimestampMs ( int64  timestamp_ms) [protected, virtual]

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines