19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_TEST_REWRITE_DRIVER_FACTORY_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_TEST_REWRITE_DRIVER_FACTORY_H_
25 #include "net/instaweb/util/public/property_cache.h"
33 namespace net_instaweb {
35 class CachePropertyStore;
36 class CountingUrlAsyncFetcher;
45 class MockMessageHandler;
50 class NamedLockManager;
53 class RateControllingUrlAsyncFetcher;
59 class ThreadsafeCache;
61 class UrlAsyncFetcher;
63 class WaitUrlAsyncFetcher;
76 static const int kFetchesPerHostOutgoingRequestThreshold = 100;
77 static const int kFetchesPerHostQueuedRequestThreshold = 500;
110 const StringPiece& temp_dir,
116 DelayCache* delay_cache() {
return delay_cache_; }
117 LRUCache* lru_cache() {
return lru_cache_.get(); }
118 MockTimer* mock_timer() {
return mock_timer_; }
119 MockHasher* mock_hasher() {
return mock_hasher_; }
120 MemFileSystem* mem_file_system() {
return mem_file_system_; }
121 MockUrlFetcher* mock_url_async_fetcher() {
122 return mock_url_fetcher_;
124 WaitUrlAsyncFetcher* wait_url_async_fetcher() {
125 return wait_url_async_fetcher_.get();
127 CountingUrlAsyncFetcher* counting_url_async_fetcher() {
128 return counting_url_async_fetcher_.get();
130 MockTimeCache* mock_time_cache() {
return mock_time_cache_.get(); }
132 void SetupWaitFetcher();
133 void CallFetcherCallbacksForDriver(RewriteDriver* driver);
134 MockMessageHandler* mock_message_handler() {
return mock_message_handler_; }
135 MockScheduler* mock_scheduler() {
return mock_scheduler_; }
136 bool use_test_url_namer()
const {
return use_test_url_namer_; }
137 void SetUseTestUrlNamer(
bool x);
141 filter_callback_vector_.push_back(callback);
144 void ClearFilterCallbackVector() {
145 filter_callback_vector_.clear();
150 rewriter_callback_vector_.push_back(callback);
153 void ClearRewriterCallbackVector() {
154 rewriter_callback_vector_.clear();
159 return use_beacon_results_in_filters_;
162 void set_use_beacon_results_in_filters(
bool b) {
163 use_beacon_results_in_filters_ = b;
169 platform_config_vector_.push_back(callback);
172 void ClearPlatformSpecificConfigurationCallback() {
173 platform_config_vector_.clear();
185 return ip ==
"127.0.0.1";
192 add_platform_specific_decoding_passes_ = value;
195 bool add_platform_specific_decoding_passes()
const {
196 return add_platform_specific_decoding_passes_;
209 CachePropertyStore* cache_property_store() {
210 return cache_property_store_;
214 virtual Hasher* NewHasher();
215 virtual MessageHandler* DefaultHtmlParseMessageHandler();
216 virtual MessageHandler* DefaultMessageHandler();
218 virtual FileSystem* DefaultFileSystem();
219 virtual NonceGenerator* DefaultNonceGenerator();
220 virtual Timer* DefaultTimer();
221 virtual void SetupCaches(ServerContext* server_context);
230 MockTimer* mock_timer_;
231 MockScheduler* mock_scheduler_;
232 DelayCache* delay_cache_;
233 scoped_ptr<ThreadsafeCache> threadsafe_cache_;
234 scoped_ptr<LRUCache> lru_cache_;
235 MockUrlFetcher* mock_url_fetcher_;
236 scoped_ptr<CountingUrlAsyncFetcher> counting_url_async_fetcher_;
237 RateControllingUrlAsyncFetcher* rate_controlling_url_async_fetcher_;
238 scoped_ptr<WaitUrlAsyncFetcher> wait_url_async_fetcher_;
239 scoped_ptr<MockTimeCache> mock_time_cache_;
240 MemFileSystem* mem_file_system_;
241 MockHasher* mock_hasher_;
242 SimpleStats simple_stats_;
243 MockMessageHandler* mock_message_handler_;
244 MockMessageHandler* mock_html_message_handler_;
245 bool use_beacon_results_in_filters_;
246 bool use_test_url_namer_;
247 bool add_platform_specific_decoding_passes_;
248 std::vector<CreateFilterCallback*> filter_callback_vector_;
249 std::vector<CreateRewriterCallback*> rewriter_callback_vector_;
250 std::vector<PlatformSpecificConfigurationCallback*> platform_config_vector_;
251 CachePropertyStore* cache_property_store_;
Definition: test_rewrite_driver_factory.h:67
virtual ServerContext * NewServerContext()
Note that this enables html proxying.
static const char kUrlNamerScheme[]
Env.var URL_NAMER_SCHEME.
Definition: test_rewrite_driver_factory.h:70
Definition: html_filter.h:35
virtual void ApplyPlatformSpecificConfiguration(RewriteDriver *driver)
virtual void SetupCaches(ServerContext *server_context)
void RebuildDecodingDriverForTests(ServerContext *server_context)
For use in tests.
virtual bool IsDebugClient(const GoogleString &ip) const
Base method that returns true if the given ip is a debug ip.
Definition: test_rewrite_driver_factory.h:184
See file comment.
Definition: delay_cache.h:47
Definition: test_rewrite_driver_factory.h:79
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Definition: test_rewrite_driver_factory.h:89
virtual Scheduler * CreateScheduler()
void AddPlatformSpecificConfigurationCallback(PlatformSpecificConfigurationCallback *callback)
Does NOT take ownership of the callback.
Definition: test_rewrite_driver_factory.h:167
virtual NamedLockManager * DefaultLockManager()
void set_add_platform_specific_decoding_passes(bool value)
Definition: test_rewrite_driver_factory.h:191
virtual void AddPlatformSpecificDecodingPasses(RewriteDriver *driver)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static const int64 kStartTimeMs
Arbitrary time to start MockTimer.
Definition: test_rewrite_driver_factory.h:69
Definition: lru_cache.h:44
virtual bool UseBeaconResultsInFilters() const
By default this is false, but can be reset.
Definition: test_rewrite_driver_factory.h:158
virtual void AddPlatformSpecificRewritePasses(RewriteDriver *driver)
Definition: rewrite_filter.h:35
Definition: mock_url_fetcher.h:41
void AddCreateRewriterCallback(CreateRewriterCallback *callback)
Does NOT take ownership of the callback.
Definition: test_rewrite_driver_factory.h:149
virtual UrlNamer * DefaultUrlNamer()
Definition: rewrite_driver.h:100
Definition: process_context.h:35
static const int kMaxFetchGlobalQueueSize
Definition: test_rewrite_driver_factory.h:75
Statistics * statistics()
Definition: rewrite_driver_factory.h:247
virtual ServerContext * NewDecodingServerContext()
virtual RewriteOptions * NewRewriteOptions()
Note that this disables ajax rewriting by default.
virtual UrlAsyncFetcher * DefaultAsyncUrlFetcher()
const PropertyCache::Cohort * SetupCohort(PropertyCache *cache, const GoogleString &cohort_name)
Sets up the cohort in the PropertyCache provided.
void AdvanceTimeMs(int64 delta_ms)
Advances the mock scheduler by delta_ms.
void AddCreateFilterCallback(CreateFilterCallback *callback)
Does NOT take ownership of the callback.
Definition: test_rewrite_driver_factory.h:140
Definition: rewrite_driver_factory.h:70