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

#include "test_rewrite_driver_factory.h"

Inheritance diagram for net_instaweb::TestRewriteDriverFactory:
net_instaweb::RewriteDriverFactory net_instaweb::CustomRewriteTestBase< OptionsClass >::CustomTestRewriteDriverFactory

Classes

class  CreateFilterCallback
 
class  CreateRewriterCallback
 
class  PlatformSpecificConfigurationCallback
 

Public Member Functions

 TestRewriteDriverFactory (const ProcessContext &process_context, const StringPiece &temp_dir, MockUrlFetcher *mock_fetcher)
 
DelayCachedelay_cache ()
 
LRUCachelru_cache ()
 
MockTimermock_timer ()
 
MockHashermock_hasher ()
 
MemFileSystemmem_file_system ()
 
MockUrlFetchermock_url_async_fetcher ()
 
WaitUrlAsyncFetcherwait_url_async_fetcher ()
 
CountingUrlAsyncFetchercounting_url_async_fetcher ()
 
MockTimeCachemock_time_cache ()
 
void SetupWaitFetcher ()
 
void CallFetcherCallbacksForDriver (RewriteDriver *driver)
 
MockMessageHandlermock_message_handler ()
 
MockSchedulermock_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 RewriteOptionsNewRewriteOptions ()
 Note that this disables ajax rewriting by default.
 
virtual ServerContextNewServerContext ()
 Note that this enables html proxying.
 
virtual ServerContextNewDecodingServerContext ()
 
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::CohortSetupCohort (PropertyCache *cache, const GoogleString &cohort_name)
 Sets up the cohort in the PropertyCache provided.
 
CachePropertyStorecache_property_store ()
 
- Public Member Functions inherited from net_instaweb::RewriteDriverFactory
 RewriteDriverFactory (const ProcessContext &process_context, ThreadSystem *thread_system)
 Takes ownership of thread_system.
 
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_nonce_generator (NonceGenerator *nonce_generator)
 
void set_url_namer (UrlNamer *url_namer)
 
void set_signature (SHA1Signature *signature)
 
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_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 ()
 
NonceGeneratornonce_generator ()
 
Hasherhasher ()
 
UrlNamerurl_namer ()
 
UserAgentMatcheruser_agent_matcher ()
 
StaticAssetManagerstatic_asset_manager ()
 
SHA1Signaturesignature ()
 
RewriteOptionsdefault_options ()
 
virtual RewriteOptionsManagerNewRewriteOptionsManager ()
 
Timertimer ()
 
NamedLockManagerlock_manager ()
 
QueuedWorkerPoolWorkerPool (WorkerPoolCategory pool)
 
Schedulerscheduler ()
 
UsageDataReporterusage_data_reporter ()
 
const
pagespeed::js::JsTokenizerPatterns
js_tokenizer_patterns () const
 
const std::vector< const
UserAgentNormalizer * > & 
user_agent_normalizers ()
 
virtual UrlAsyncFetcherComputeUrlAsyncFetcher ()
 
ServerContextCreateServerContext ()
 
void InitServerContext (ServerContext *server_context)
 
ThreadSystemthread_system ()
 
const StringSet & created_directories () const
 
bool async_rewrites ()
 
RewriteStatsrewrite_stats ()
 
virtual bool HasWaveforms () const
 Returns true if the server supports waveforms in its status page.
 
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 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)
 
template<class T >
void TakeOwnership (T *obj)
 
virtual ExperimentMatcherNewExperimentMatcher ()
 

Static Public Member Functions

static void InitStats (Statistics *statistics)
 
- Static Public Member Functions inherited from net_instaweb::RewriteDriverFactory
static void InitializeDefaultOptions (RewriteOptions *options)
 
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 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 HasherNewHasher ()
 
virtual MessageHandlerDefaultHtmlParseMessageHandler ()
 
virtual MessageHandlerDefaultMessageHandler ()
 
virtual UrlAsyncFetcherDefaultAsyncUrlFetcher ()
 
virtual FileSystemDefaultFileSystem ()
 
virtual NonceGeneratorDefaultNonceGenerator ()
 
virtual TimerDefaultTimer ()
 
virtual void SetupCaches (ServerContext *server_context)
 
virtual UrlNamerDefaultUrlNamer ()
 
virtual SchedulerCreateScheduler ()
 
virtual void AddPlatformSpecificDecodingPasses (RewriteDriver *driver)
 
virtual void AddPlatformSpecificRewritePasses (RewriteDriver *driver)
 
virtual void ApplyPlatformSpecificConfiguration (RewriteDriver *driver)
 
virtual NamedLockManagerDefaultLockManager ()
 
- Protected Member Functions inherited from net_instaweb::RewriteDriverFactory
bool FetchersComputed () const
 
virtual void StopCacheActivity ()
 
StringPiece filename_prefix ()
 
bool TerminateServerContext (ServerContext *server_context)
 
virtual SHA1SignatureDefaultSignature ()
 
virtual CriticalImagesFinderDefaultCriticalImagesFinder (ServerContext *server_context)
 
virtual CriticalSelectorFinderDefaultCriticalSelectorFinder (ServerContext *server_context)
 
virtual UserAgentMatcherDefaultUserAgentMatcher ()
 
virtual UsageDataReporterDefaultUsageDataReporter ()
 
virtual void AddPlatformSpecificUserAgentNormalizers (std::vector< const UserAgentNormalizer * > *out)
 
virtual QueuedWorkerPoolCreateWorkerPool (WorkerPoolCategory pool, StringPiece name)
 
virtual int LowPriorityLoadSheddingThreshold () const
 
virtual void FetcherSetupHooks ()
 Called before creating the url fetchers.
 
virtual StringPiece LockFilePrefix ()
 
virtual void InitStaticAssetManager (StaticAssetManager *static_asset_manager)
 Initializes the StaticAssetManager.
 
void InitStubDecodingServerContext (ServerContext *context)
 
virtual std::shared_ptr
< CentralController
GetCentralController (NamedLockManager *lock_manager)
 
void RebuildDecodingDriverForTests (ServerContext *server_context)
 For use in tests.
 
void reset_default_options (RewriteOptions *new_defaults)
 

Additional Inherited Members

- Public Types inherited from net_instaweb::RewriteDriverFactory
enum  WorkerPoolCategory { kHtmlWorkers, kRewriteWorkers, kLowPriorityRewriteWorkers, kNumWorkerPools }
 

Detailed Description

RewriteDriverFactory implementation for use in tests, using mock time, mock fetchers, and a memory-based file system.

Member Function Documentation

virtual void net_instaweb::TestRewriteDriverFactory::AddPlatformSpecificDecodingPasses ( RewriteDriver driver)
protectedvirtual

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)
protectedvirtual

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)
protectedvirtual

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 ( )
protectedvirtual

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 ( )
protectedvirtual

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 NamedLockManager* net_instaweb::TestRewriteDriverFactory::DefaultLockManager ( )
protectedvirtual

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

Reimplemented from net_instaweb::RewriteDriverFactory.

virtual UrlNamer* net_instaweb::TestRewriteDriverFactory::DefaultUrlNamer ( )
protectedvirtual

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

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)
protectedvirtual

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.

Member Data Documentation

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.


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