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

#include "rewrite_driver_factory.h"

Inheritance diagram for net_instaweb::RewriteDriverFactory:
net_instaweb::ApacheRewriteDriverFactory net_instaweb::FileRewriter net_instaweb::TestRewriteDriverFactory

List of all members.

Classes

class  Deleter

Public Types

enum  WorkerPoolName { kHtmlWorkers, kRewriteWorkers, kLowPriorityRewriteWorkers, kNumWorkerPools }

Public Member Functions

 RewriteDriverFactory (ThreadSystem *thread_system)
 Takes ownership of thread_system.
 RewriteDriverFactory ()
 Initializes thread_system_ using ThreadSystem::ComputeThreadSystem().
void InitializeDefaultOptions ()
void set_html_parse_message_handler (MessageHandler *message_handler)
void set_message_handler (MessageHandler *message_handler)
void set_file_system (FileSystem *file_system)
void set_hasher (Hasher *hasher)
void set_filename_encoder (FilenameEncoder *filename_encoder)
void set_url_namer (UrlNamer *url_namer)
void set_timer (Timer *timer)
void set_usage_data_reporter (UsageDataReporter *reporter)
void set_slurp_directory (const StringPiece &directory)
void set_slurp_read_only (bool read_only)
void set_slurp_print_urls (bool read_only)
void set_force_caching (bool u)
void set_base_url_fetcher (UrlFetcher *url_fetcher)
void set_base_url_async_fetcher (UrlAsyncFetcher *url_fetcher)
bool set_filename_prefix (StringPiece p)
bool slurping_enabled () const
 Determines whether Slurping is enabled.
MessageHandlerhtml_parse_message_handler ()
MessageHandlermessage_handler ()
FileSystemfile_system ()
Hasherhasher ()
FilenameEncoderfilename_encoder ()
UrlNamerurl_namer ()
UserAgentMatcheruser_agent_matcher ()
StaticJavascriptManagerstatic_javascript_manager ()
RewriteOptionsdefault_options ()
Timertimer ()
NamedLockManagerlock_manager ()
QueuedWorkerPoolWorkerPool (WorkerPoolName pool)
Schedulerscheduler ()
UsageDataReporterusage_data_reporter ()
virtual UrlFetcherComputeUrlFetcher ()
virtual UrlAsyncFetcherComputeUrlAsyncFetcher ()
ServerContextCreateServerContext ()
void InitServerContext (ServerContext *server_context)
virtual void SetupCaches (ServerContext *server_context)=0
virtual void AddPlatformSpecificRewritePasses (RewriteDriver *driver)
virtual void AddPlatformSpecificDecodingPasses (RewriteDriver *driver)
virtual void ApplyPlatformSpecificConfiguration (RewriteDriver *driver)
ThreadSystemthread_system ()
const StringSet & created_directories () const
bool async_rewrites ()
RewriteStatsrewrite_stats ()
Statisticsstatistics ()
void SetStatistics (Statistics *stats)
 Does *not* take ownership of Statistics.
virtual void ShutDown ()
void AddCreatedDirectory (const GoogleString &dir)
 Registers the directory as having been created by us.
virtual RewriteOptionsNewRewriteOptions ()
virtual RewriteOptionsNewRewriteOptionsForQuery ()
const GoogleStringversion_string () const
 get/set the version placed into the X-[Mod-]Page(s|-S)peed header.
void set_version_string (const StringPiece &version_string)
void defer_cleanup (Function *f)
virtual bool IsDebugClient (const GoogleString &ip) const
 Base method that returns true if the given ip is a debug ip.
virtual AbstractClientStateNewClientState ()
virtual FuriousMatcherNewFuriousMatcher ()

Static Public Member Functions

static void InitStats (Statistics *statistics)
static void Initialize ()
 Initializes static variables. Initialize/Terminate calls must be paired.
static void Terminate ()

Protected Member Functions

bool FetchersComputed () const
virtual void StopCacheActivity ()
StringPiece filename_prefix ()
bool TerminateServerContext (ServerContext *rm)
virtual UrlFetcherDefaultUrlFetcher ()=0
virtual UrlAsyncFetcherDefaultAsyncUrlFetcher ()=0
virtual MessageHandlerDefaultHtmlParseMessageHandler ()=0
virtual MessageHandlerDefaultMessageHandler ()=0
virtual FileSystemDefaultFileSystem ()=0
virtual TimerDefaultTimer ()=0
virtual HasherNewHasher ()=0
virtual CriticalImagesFinderDefaultCriticalImagesFinder ()
virtual
BlinkCriticalLineDataFinder
DefaultBlinkCriticalLineDataFinder (PropertyCache *cache)
 Default implementation returns NULL.
virtual FlushEarlyInfoFinderDefaultFlushEarlyInfoFinder ()
 Default implementation returns NULL.
virtual NamedLockManagerDefaultLockManager ()
virtual UrlNamerDefaultUrlNamer ()
virtual UserAgentMatcherDefaultUserAgentMatcher ()
virtual UsageDataReporterDefaultUsageDataReporter ()
virtual QueuedWorkerPoolCreateWorkerPool (WorkerPoolName name)
virtual int LowPriorityLoadSheddingThreshold () const
virtual SchedulerCreateScheduler ()
virtual void FetcherSetupHooks ()
 Called before creating the url fetchers.
virtual StringPiece LockFilePrefix ()
virtual void InitStaticJavascriptManager (StaticJavascriptManager *static_js_manager)
 Initializes the StaticJavascriptManager.

Detailed Description

Manages the construction and ownership of most objects needed to create RewriteDrivers. If you have your own versions of these classes (specific implementations of UrlAsyncFetcher, Hasher, etc.) you can make your own subclass of RewriteDriverFactory to use these by default.


Member Enumeration Documentation

Enumerator:
kNumWorkerPools 

Make sure to insert new values above this line.


Member Function Documentation

Provides an optional hook for adding rewriters to the .pagespeed. resource decoding chain. This should be used for rewriters that are specific to a particular RewriteDriverFactory implementation. The caller should only use the resulting driver for reconstructing a .pagespeed. resource, not for transforming HTML. Therefore, implementations should add any platform-specific rewriter whose id might appear in a .pagespeed. URL.

Reimplemented in net_instaweb::TestRewriteDriverFactory.

Provides an optional hook for adding rewrite passes to the HTML filter chain. This should be used for filters that are specific to a particular RewriteDriverFactory implementation.

Reimplemented in net_instaweb::TestRewriteDriverFactory.

Provides an optional hook for customizing the RewriteDriver object using the options set on it. This is called before RewriteDriver::AddFilters() and AddPlatformSpecificRewritePasses().

Reimplemented in net_instaweb::TestRewriteDriverFactory.

Computes URL fetchers using the based fetcher, and optionally, slurp_directory and slurp_read_only. These are not thread-safe; they must be called once prior to spawning threads, e.g. via CreateServerContext.

const StringSet& net_instaweb::RewriteDriverFactory::created_directories ( ) const [inline]

Returns the set of directories that we (our our subclasses) have created thus far.

Subclasses can override this to create an appropriate Scheduler subclass if the default isn't acceptable.

Reimplemented in net_instaweb::TestRewriteDriverFactory.

Threadsafe mechanism to create a managed ServerContext. The ServerContext is owned by the factory, and should not be deleted directly. Currently it is not possible to delete a server context except by deleting the entire factory.

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 in net_instaweb::ApacheRewriteDriverFactory.

They may also supply a custom lock manager. The default implementation will use the file system.

Reimplemented in net_instaweb::ApacheRewriteDriverFactory.

virtual UrlFetcher* net_instaweb::RewriteDriverFactory::DefaultUrlFetcher ( ) [protected, pure virtual]

Implementors of RewriteDriverFactory must supply default definitions for each of these methods, although they may be overridden via set_ methods above.

Implemented in net_instaweb::ApacheRewriteDriverFactory, net_instaweb::TestRewriteDriverFactory, and net_instaweb::FileRewriter.

They may also supply a custom Url namer. The default implementation performs sharding and appends '.pagespeed.<filter>.<hash>.<extension>'.

Reimplemented in net_instaweb::TestRewriteDriverFactory.

Causes the given function to be Run after all the threads are shutdown, in order to do any needed resource cleanups. The Deleter<T> template below may be useful for object deletion cleanups.

Todo:
TODO(sligocki): Remove hasher() and force people to make a NewHasher when they need one.

Initializes default options we want to hard-code into the base-class to get consistency across deployments. Subclasses that override NewRewriteOptions() should call this method from their constructor. It is safe to call this multiple times.

Initializes a ServerContext that has been new'd directly. This allows 2-phase initialization if required. There is no need to call this if you use CreateServerContext.

static void net_instaweb::RewriteDriverFactory::InitStats ( Statistics statistics) [static]

Initializes statistics variables. This must be done at process startup to enable shared memory segments in Apache to be set up.

Reimplemented in net_instaweb::ApacheRewriteDriverFactory.

virtual StringPiece net_instaweb::RewriteDriverFactory::LockFilePrefix ( ) [protected, virtual]

Override this if you want to change what directory locks go into when using the default filesystem-based lock manager. The default is filename_prefix()

Subclasses can override this method to request load-shedding to happen if the low-priority work pool has too many inactive sequences queued up waiting (the returned value will be a threshold beyond which things will start getting dropped). The default implementation returns kNoLoadShedding, which disables the feature. See also QueuedWorkerPool::set_load_shedding_threshold

Creates a new AbstractClientState object that must be populated. Subclasses can override this to create an appropriate AbstractClientState subclass if the default isn't acceptable.

Creates a FuriousMatcher, which is used to match clients or sessions to a specific furious experiment.

Creates a new empty RewriteOptions object, with no default settings. Note that InitResourceManager() will copy the factory's default_options() into the server context's global_options(), but this method just provides a blank set of options.

Reimplemented in net_instaweb::ApacheRewriteDriverFactory, and net_instaweb::TestRewriteDriverFactory.

Creates a new empty RewriteOptions object meant for use for custom options from queries or headers. Default implementation just forwards to NewRewriteOptions().

Reimplemented in net_instaweb::ApacheRewriteDriverFactory.

Collection of global statistics objects. This is thread-unsafe: it must be called prior to spawning threads, and after any calls to SetStatistics. Failing that, it will be initialized in the first call to InitServerContext(), which is thread-safe.

You should either call set_base_url_fetcher, set_base_url_async_fetcher, or neither. Do not set both. If you want to enable real async fetching, because you are serving or want to model live traffic, then call set_base_url_async_fetcher before calling url_fetcher.

These fetchers may be used directly when serving traffic, or they may be aggregated with other fetchers (e.g. for slurping).

You cannot set either base URL fetcher once ComputeUrlFetcher has been called.

Setting HTTP caching on causes both the fetcher and the async fecher to return cached versions.

The RewriteDriveFactory will create objects of default type through the New* method from drived classes. Here are the objects that can be replaced before creating the RewriteDriver. Note: RewriteDriver takes ownership of these.

void net_instaweb::RewriteDriverFactory::set_slurp_directory ( const StringPiece &  directory)

Set up a directory for slurped files for HTML and resources. If read_only is true, then it will only read from these files, and this will eliminate the usage of any other url_fetcher. If read_only is false, then the existing url fetcher will be used as a fallback if the slurped file is not found, and slurped files will be subsequently written so they don't have to be fetched from the Internet again.

You must set the slurp directory prior to calling ComputeUrlFetcher or ComputeUrlAsyncFetcher.

virtual void net_instaweb::RewriteDriverFactory::SetupCaches ( ServerContext server_context) [pure 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.

Implemented in net_instaweb::ApacheRewriteDriverFactory, net_instaweb::TestRewriteDriverFactory, and net_instaweb::FileRewriter.

Clean up all the factory-owned resources: fetchers, pools, Server Contexts, the Drivers owned by the Server Contexts, and worker threads.

Reimplemented in net_instaweb::ApacheRewriteDriverFactory.

statistics (default is NullStatistics). This can be overridden by calling SetStatistics, either from subclasses or externally.

Reimplemented in net_instaweb::FileRewriter.

Used by subclasses to indicate that a ResourceManager has been terminated. Returns true if this was the last server context known to this factory.

These accessors are *not* thread-safe. They must be called once prior to forking threads, e.g. via ComputeUrlFetcher().


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