Page Speed Optimization Libraries
1.8.31.3
|
#include "test_rewrite_driver_factory.h"
Classes | |
class | CreateFilterCallback |
class | CreateRewriterCallback |
class | PlatformSpecificConfigurationCallback |
Public Member Functions | |
TestRewriteDriverFactory (const ProcessContext &process_context, const StringPiece &temp_dir, MockUrlFetcher *mock_fetcher, TestDistributedFetcher *test_distributed_fetcher) | |
DelayCache * | delay_cache () |
LRUCache * | lru_cache () |
MockTimer * | mock_timer () |
MockHasher * | mock_hasher () |
MemFileSystem * | mem_file_system () |
MockUrlFetcher * | mock_url_async_fetcher () |
WaitUrlAsyncFetcher * | wait_url_async_fetcher () |
CountingUrlAsyncFetcher * | counting_url_async_fetcher () |
CountingUrlAsyncFetcher * | counting_distributed_async_fetcher () |
MockTimeCache * | mock_time_cache () |
void | SetupWaitFetcher () |
void | CallFetcherCallbacksForDriver (RewriteDriver *driver) |
MockMessageHandler * | mock_message_handler () |
MockScheduler * | mock_scheduler () |
bool | use_test_url_namer () const |
void | SetUseTestUrlNamer (bool x) |
void | AddCreateFilterCallback (CreateFilterCallback *callback) |
Does NOT take ownership of the callback. | |
void | ClearFilterCallbackVector () |
void | AddCreateRewriterCallback (CreateRewriterCallback *callback) |
Does NOT take ownership of the callback. | |
void | ClearRewriterCallbackVector () |
virtual bool | UseBeaconResultsInFilters () const |
By default this is false, but can be reset. | |
void | set_use_beacon_results_in_filters (bool b) |
void | AddPlatformSpecificConfigurationCallback (PlatformSpecificConfigurationCallback *callback) |
Does NOT take ownership of the callback. | |
void | ClearPlatformSpecificConfigurationCallback () |
virtual RewriteOptions * | NewRewriteOptions () |
Note that this disables ajax rewriting by default. | |
virtual ServerContext * | NewServerContext () |
Note that this enables html proxying. | |
virtual ServerContext * | NewDecodingServerContext () |
virtual bool | IsDebugClient (const GoogleString &ip) const |
Base method that returns true if the given ip is a debug ip. | |
void | set_add_platform_specific_decoding_passes (bool value) |
bool | add_platform_specific_decoding_passes () const |
void | AdvanceTimeMs (int64 delta_ms) |
Advances the mock scheduler by delta_ms. | |
const PropertyCache::Cohort * | SetupCohort (PropertyCache *cache, const GoogleString &cohort_name) |
Sets up the cohort in the PropertyCache provided. | |
CachePropertyStore * | cache_property_store () |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
Static Public Attributes | |
static const int64 | kStartTimeMs |
Arbitrary time to start MockTimer. | |
static const char | kUrlNamerScheme [] |
Env.var URL_NAMER_SCHEME. | |
static const int | kMaxFetchGlobalQueueSize = 500 |
static const int | kFetchesPerHostOutgoingRequestThreshold = 100 |
static const int | kFetchesPerHostQueuedRequestThreshold = 500 |
Protected Member Functions | |
virtual Hasher * | NewHasher () |
virtual MessageHandler * | DefaultHtmlParseMessageHandler () |
virtual MessageHandler * | DefaultMessageHandler () |
virtual UrlAsyncFetcher * | DefaultAsyncUrlFetcher () |
virtual UrlAsyncFetcher * | DefaultDistributedUrlFetcher () |
virtual FileSystem * | DefaultFileSystem () |
virtual NonceGenerator * | DefaultNonceGenerator () |
virtual Timer * | DefaultTimer () |
virtual void | SetupCaches (ServerContext *server_context) |
virtual UrlNamer * | DefaultUrlNamer () |
virtual Scheduler * | CreateScheduler () |
virtual void | AddPlatformSpecificDecodingPasses (RewriteDriver *driver) |
virtual void | AddPlatformSpecificRewritePasses (RewriteDriver *driver) |
virtual void | ApplyPlatformSpecificConfiguration (RewriteDriver *driver) |
RewriteDriverFactory implementation for use in tests, using mock time, mock fetchers, and a memory-based file system.
virtual void net_instaweb::TestRewriteDriverFactory::AddPlatformSpecificDecodingPasses | ( | RewriteDriver * | driver | ) | [protected, virtual] |
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. This should be done independent of RewriteOptions, since we only store a single decoding driver globally to save memory.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual void net_instaweb::TestRewriteDriverFactory::AddPlatformSpecificRewritePasses | ( | RewriteDriver * | driver | ) | [protected, virtual] |
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 from net_instaweb::RewriteDriverFactory.
virtual void net_instaweb::TestRewriteDriverFactory::ApplyPlatformSpecificConfiguration | ( | RewriteDriver * | driver | ) | [protected, virtual] |
Provides an optional hook for customizing the RewriteDriver object using the options set on it. This is called before RewriteDriver::AddFilters() and AddPlatformSpecificRewritePasses().
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual Scheduler* net_instaweb::TestRewriteDriverFactory::CreateScheduler | ( | ) | [protected, virtual] |
Subclasses can override this to create an appropriate Scheduler subclass if the default isn't acceptable.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual UrlAsyncFetcher* net_instaweb::TestRewriteDriverFactory::DefaultAsyncUrlFetcher | ( | ) | [protected, virtual] |
Implementors of RewriteDriverFactory must supply default definitions for each of these methods, although they may be overridden via set_ methods above. These methods all instantiate objects and transfer ownership to the caller.
Implements net_instaweb::RewriteDriverFactory.
virtual UrlNamer* net_instaweb::TestRewriteDriverFactory::DefaultUrlNamer | ( | ) | [protected, virtual] |
They may also supply a custom Url namer. The default implementation performs sharding and appends '.pagespeed.<filter>.<hash>.<extension>'.
Reimplemented from net_instaweb::RewriteDriverFactory.
static void net_instaweb::TestRewriteDriverFactory::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 from net_instaweb::RewriteDriverFactory.
virtual ServerContext* net_instaweb::TestRewriteDriverFactory::NewDecodingServerContext | ( | ) | [virtual] |
Create a new ServerContext used for decoding only. Unlike NewServerContext, the resulting ServerContext should not be fresh, but should have some of its platform dependencies injected --- but just enough for decoding URLs, and not full operation. At the time of writing it needs the timer, url namer, hasher, message handler, and stats; expensive stuff like cache backends is not needed, however.
You may find InitStubDecodingServerContext() useful for doing that, as it will inject all of these from what's available in 'this'.
Implements net_instaweb::RewriteDriverFactory.
void net_instaweb::TestRewriteDriverFactory::set_add_platform_specific_decoding_passes | ( | bool | value | ) | [inline] |
Enable or disable adding the contents of rewriter_callback_vector_ within AddPlatformSpecificRewritePasses. You'll also want to call RebuildDecodingDriverForTests.
virtual void net_instaweb::TestRewriteDriverFactory::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.
const int net_instaweb::TestRewriteDriverFactory::kMaxFetchGlobalQueueSize = 500 [static] |
These constants are used to initialize the rate-controlling fetcher, which is instantiated unconditionally, with limits high enough that no tests will hit this unless they are trying to.