Page Speed Optimization Libraries
1.4.26.1
|
Creates an Apache RewriteDriver. More...
#include "apache_rewrite_driver_factory.h"
Classes | |
struct | MetadataShmCacheInfo |
Public Member Functions | |
ApacheRewriteDriverFactory (server_rec *server, const StringPiece &version) | |
virtual Hasher * | NewHasher () |
UrlPollableAsyncFetcher * | SubResourceFetcher () |
GoogleString | hostname_identifier () |
AbstractSharedMem * | shared_mem_runtime () const |
ApacheMessageHandler * | apache_message_handler () |
bool | is_root_process () const |
void | RootInit () |
void | ChildInit () |
Statistics * | MakeGlobalSharedMemStatistics (bool logging, int64 logging_interval_ms, const GoogleString &logging_file) |
SharedMemStatistics * | AllocateAndInitSharedMemStatistics (const StringPiece &name, const bool logging, const int64 logging_interval_ms, const GoogleString &logging_file) |
Creates and ::Initializes a shared memory statistics object. | |
virtual ApacheServerContext * | MakeApacheServerContext (server_rec *server) |
ServerContext * | NewServerContext () |
void | set_fetch_with_gzip (bool x) |
bool | fetch_with_gzip () const |
void | set_track_original_content_length (bool x) |
bool | track_original_content_length () const |
void | set_num_rewrite_threads (int x) |
int | num_rewrite_threads () const |
void | set_num_expensive_rewrite_threads (int x) |
int | num_expensive_rewrite_threads () const |
void | set_message_buffer_size (int x) |
void | list_outstanding_urls_on_error (bool x) |
bool | use_per_vhost_statistics () const |
void | set_use_per_vhost_statistics (bool x) |
bool | enable_property_cache () const |
void | set_enable_property_cache (bool x) |
bool | inherit_vhost_config () const |
If true, virtual hosts should inherit global configuration. | |
void | set_inherit_vhost_config (bool x) |
bool | disable_loopback_routing () const |
void | set_disable_loopback_routing (bool x) |
bool | install_crash_handler () const |
void | set_install_crash_handler (bool x) |
SystemCaches * | caches () |
virtual bool | UseBeaconResultsInFilters () const |
UrlAsyncFetcher * | GetFetcher (ApacheConfig *config) |
SerfUrlAsyncFetcher * | GetSerfFetcher (ApacheConfig *config) |
bool | PoolDestroyed (ApacheServerContext *rm) |
virtual RewriteOptions * | NewRewriteOptions () |
virtual RewriteOptions * | NewRewriteOptionsForQuery () |
bool | SetHttpsOptions (StringPiece directive, GoogleString *error_message) |
ModSpdyFetchController * | mod_spdy_fetch_controller () |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
static void | Initialize () |
Initializes static variables. Initialize/Terminate calls must be paired. | |
static void | Terminate () |
Static Public Attributes | |
static const char | kStaticAssetPrefix [] |
Protected Member Functions | |
virtual UrlFetcher * | DefaultUrlFetcher () |
virtual UrlAsyncFetcher * | DefaultAsyncUrlFetcher () |
virtual void | StopCacheActivity () |
virtual MessageHandler * | DefaultHtmlParseMessageHandler () |
Provide defaults. | |
virtual MessageHandler * | DefaultMessageHandler () |
virtual FileSystem * | DefaultFileSystem () |
virtual Timer * | DefaultTimer () |
virtual void | SetupCaches (ServerContext *resource_manager) |
virtual NamedLockManager * | DefaultLockManager () |
virtual QueuedWorkerPool * | CreateWorkerPool (WorkerPoolCategory pool, StringPiece name) |
virtual bool | ShouldWriteResourcesToFileSystem () |
void | ParentOrChildInit () |
void | SharedCircularBufferInit (bool is_root) |
virtual void | ShutDown () |
virtual void | InitStaticAssetManager (StaticAssetManager *static_asset_manager) |
Initializes the StaticAssetManager. |
Creates an Apache RewriteDriver.
Give access to apache_message_handler_ for the cases we need to use ApacheMessageHandler rather than MessageHandler. e.g. Use ApacheMessageHandler::Dump() This is a better choice than cast from MessageHandler.
virtual QueuedWorkerPool* net_instaweb::ApacheRewriteDriverFactory::CreateWorkerPool | ( | WorkerPoolCategory | pool, |
StringPiece | name | ||
) | [protected, virtual] |
Subclasses can override this to create an appropriately-sized thread pool for their environment. The default implementation will always make one with a single thread.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual NamedLockManager* net_instaweb::ApacheRewriteDriverFactory::DefaultLockManager | ( | ) | [protected, virtual] |
They may also supply a custom lock manager. The default implementation will use the file system.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual UrlFetcher* net_instaweb::ApacheRewriteDriverFactory::DefaultUrlFetcher | ( | ) | [protected, virtual] |
Implementors of RewriteDriverFactory must supply default definitions for each of these methods, although they may be overridden via set_ methods above.
Implements net_instaweb::RewriteDriverFactory.
Finds a fetcher for the settings in this config, sharing with existing fetchers if possible, otherwise making a new one (and its required thread).
SerfUrlAsyncFetcher* net_instaweb::ApacheRewriteDriverFactory::GetSerfFetcher | ( | ApacheConfig * | config | ) |
As above, but just gets a Serf fetcher --- not a slurp fetcher or a rate limiting one, etc.
static void net_instaweb::ApacheRewriteDriverFactory::InitStats | ( | Statistics * | statistics | ) | [static] |
Initializes all the statistics objects created transitively by ApacheRewriteDriverFactory, including apache-specific and platform-independent statistics.
Reimplemented from net_instaweb::RewriteDriverFactory.
bool net_instaweb::ApacheRewriteDriverFactory::is_root_process | ( | ) | const [inline] |
For shared memory resources the general setup we follow is to have the first running process (aka the root) create the necessary segments and fill in their shared data structures, while processes created to actually handle requests attach to already existing shared data structures.
During normal server startup[1], RootInit() is called from the Apache hooks in the root process for the first task, and then ChildInit() is called in any child process.
Keep in mind, however, that when fork() is involved a process may effectively see both calls, in which case the 'ChildInit' call would come second and override the previous root status. Both calls are also invoked in the debug single-process mode (httpd -X).
Note that these are not static methods --- they are invoked on every ApacheRewriteDriverFactory instance, which exist for the global configuration as well as all the vhosts.
[1] Besides normal startup, Apache also uses a temporary process to syntax check the config file. That basically looks like a complete normal startup and shutdown to the code.
void net_instaweb::ApacheRewriteDriverFactory::list_outstanding_urls_on_error | ( | bool | x | ) | [inline] |
When Serf gets a system error during polling, to avoid spamming the log we just print the number of outstanding fetch URLs. To debug this it's useful to print the complete set of URLs, in which case this should be turned on.
Statistics* net_instaweb::ApacheRewriteDriverFactory::MakeGlobalSharedMemStatistics | ( | bool | logging, |
int64 | logging_interval_ms, | ||
const GoogleString & | logging_file | ||
) |
Build global shared-memory statistics. This is invoked if at least one server context (global or VirtualHost) enables statistics.
virtual RewriteOptions* net_instaweb::ApacheRewriteDriverFactory::NewRewriteOptions | ( | ) | [virtual] |
Create a new RewriteOptions. In this implementation it will be an ApacheConfig.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual RewriteOptions* net_instaweb::ApacheRewriteDriverFactory::NewRewriteOptionsForQuery | ( | ) | [virtual] |
As above, but set a name on the ApacheConfig noting that it came from a query.
Reimplemented from net_instaweb::RewriteDriverFactory.
Creates a new ServerContext* object. ServerContexst itself must be overridden per Factory as it has at least one pure virtual method.
Implements net_instaweb::RewriteDriverFactory.
void net_instaweb::ApacheRewriteDriverFactory::ParentOrChildInit | ( | ) | [protected] |
This helper method contains init procedures invoked by both RootInit() and ChildInit()
Notification of apache tearing down a context (vhost or top-level) corresponding to given ApacheServerContext. Returns true if it was the last context.
void net_instaweb::ApacheRewriteDriverFactory::set_fetch_with_gzip | ( | bool | x | ) | [inline] |
Makes fetches from PSA to origin-server request accept-encoding:gzip, even when used in a context when we want cleartext. We'll decompress as we read the content if needed.
void net_instaweb::ApacheRewriteDriverFactory::set_track_original_content_length | ( | bool | x | ) | [inline] |
Tracks the size of resources fetched from origin and populates the X-Original-Content-Length header for resources derived from them.
bool net_instaweb::ApacheRewriteDriverFactory::SetHttpsOptions | ( | StringPiece | directive, |
GoogleString * | error_message | ||
) |
Parses a comma-separated list of HTTPS options. If successful, applies the options to the fetcher and returns true. If the options were invalid, error_message is populated and false is returned.
It is *not* considered an error in this context to attempt to enable HTTPS when support is not compiled in. However, an error message will be logged in the server log, and the option-setting will have no effect.
virtual void net_instaweb::ApacheRewriteDriverFactory::SetupCaches | ( | ServerContext * | server_context | ) | [protected, virtual] |
Called from InitServerContext, but virtualized separately as it is platform-specific. This method must call on the server context: set_http_cache, set_metadata_cache, set_filesystem_metadata_cache, and MakePropertyCaches.
Implements net_instaweb::RewriteDriverFactory.
void net_instaweb::ApacheRewriteDriverFactory::SharedCircularBufferInit | ( | bool | is_root | ) | [protected] |
Initialize SharedCircularBuffer and pass it to ApacheMessageHandler and ApacheHtmlParseMessageHandler. is_root is true if this is invoked from root (ie. parent) process.
virtual bool net_instaweb::ApacheRewriteDriverFactory::ShouldWriteResourcesToFileSystem | ( | ) | [inline, protected, virtual] |
Disable the Resource Manager's filesystem since we have a write-through http_cache.
virtual void net_instaweb::ApacheRewriteDriverFactory::ShutDown | ( | ) | [protected, virtual] |
Release all the resources. It also calls the base class ShutDown to release the base class resources.
Reimplemented from net_instaweb::RewriteDriverFactory.
Returns the fetcher that will be used by the filters to load any resources they need. This either matches the resource manager's async fetcher or is NULL in case we are configured in a way that all fetches will succeed immediately. Must be called after the fetchers have been computed
virtual bool net_instaweb::ApacheRewriteDriverFactory::UseBeaconResultsInFilters | ( | ) | const [inline, virtual] |
mod_pagespeed uses a beacon handler to collect data for critical images, css, etc., so filters should be configured accordingly.
Implements net_instaweb::RewriteDriverFactory.
const char net_instaweb::ApacheRewriteDriverFactory::kStaticAssetPrefix[] [static] |
Path prefix where we serve static assets (primarily images and js resources) needed by some filters.