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"
26 #include "pagespeed/kernel/base/basictypes.h"
27 #include "pagespeed/kernel/base/scoped_ptr.h"
28 #include "pagespeed/kernel/base/string.h"
29 #include "pagespeed/kernel/base/string_util.h"
30 #include "pagespeed/kernel/util/simple_stats.h"
32 namespace net_instaweb {
34 class CachePropertyStore;
35 class CountingUrlAsyncFetcher;
44 class MockMessageHandler;
51 class RateControllingUrlAsyncFetcher;
58 class TestDistributedFetcher;
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,
115 static void InitStats(Statistics*
statistics);
117 DelayCache* delay_cache() {
return delay_cache_; }
118 LRUCache* lru_cache() {
return lru_cache_.get(); }
119 MockTimer* mock_timer() {
return mock_timer_; }
120 MockHasher* mock_hasher() {
return mock_hasher_; }
121 MemFileSystem* mem_file_system() {
return mem_file_system_; }
122 MockUrlFetcher* mock_url_async_fetcher() {
123 return mock_url_fetcher_;
125 WaitUrlAsyncFetcher* wait_url_async_fetcher() {
126 return wait_url_async_fetcher_.get();
128 CountingUrlAsyncFetcher* counting_url_async_fetcher() {
129 return counting_url_async_fetcher_.get();
131 CountingUrlAsyncFetcher* counting_distributed_async_fetcher() {
132 return counting_distributed_async_fetcher_;
134 MockTimeCache* mock_time_cache() {
return mock_time_cache_.get(); }
136 void SetupWaitFetcher();
137 void CallFetcherCallbacksForDriver(RewriteDriver* driver);
138 MockMessageHandler* mock_message_handler() {
return mock_message_handler_; }
139 MockScheduler* mock_scheduler() {
return mock_scheduler_; }
140 bool use_test_url_namer()
const {
return use_test_url_namer_; }
141 void SetUseTestUrlNamer(
bool x);
145 filter_callback_vector_.push_back(callback);
148 void ClearFilterCallbackVector() {
149 filter_callback_vector_.clear();
154 rewriter_callback_vector_.push_back(callback);
157 void ClearRewriterCallbackVector() {
158 rewriter_callback_vector_.clear();
163 return use_beacon_results_in_filters_;
166 void set_use_beacon_results_in_filters(
bool b) {
167 use_beacon_results_in_filters_ = b;
173 platform_config_vector_.push_back(callback);
176 void ClearPlatformSpecificConfigurationCallback() {
177 platform_config_vector_.clear();
189 return ip ==
"127.0.0.1";
196 add_platform_specific_decoding_passes_ = value;
199 bool add_platform_specific_decoding_passes()
const {
200 return add_platform_specific_decoding_passes_;
211 PropertyCache* cache,
const GoogleString& cohort_name);
213 CachePropertyStore* cache_property_store() {
214 return cache_property_store_;
218 virtual Hasher* NewHasher();
219 virtual MessageHandler* DefaultHtmlParseMessageHandler();
220 virtual MessageHandler* DefaultMessageHandler();
222 virtual UrlAsyncFetcher* DefaultDistributedUrlFetcher();
223 virtual FileSystem* DefaultFileSystem();
224 virtual NonceGenerator* DefaultNonceGenerator();
225 virtual Timer* DefaultTimer();
226 virtual void SetupCaches(ServerContext* server_context);
234 MockTimer* mock_timer_;
235 MockScheduler* mock_scheduler_;
236 DelayCache* delay_cache_;
237 scoped_ptr<ThreadsafeCache> threadsafe_cache_;
238 scoped_ptr<LRUCache> lru_cache_;
239 MockUrlFetcher* mock_url_fetcher_;
240 TestDistributedFetcher* test_distributed_fetcher_;
241 scoped_ptr<CountingUrlAsyncFetcher> counting_url_async_fetcher_;
242 RateControllingUrlAsyncFetcher* rate_controlling_url_async_fetcher_;
243 CountingUrlAsyncFetcher* counting_distributed_async_fetcher_;
244 scoped_ptr<WaitUrlAsyncFetcher> wait_url_async_fetcher_;
245 scoped_ptr<MockTimeCache> mock_time_cache_;
246 MemFileSystem* mem_file_system_;
247 MockHasher* mock_hasher_;
248 SimpleStats simple_stats_;
249 MockMessageHandler* mock_message_handler_;
250 MockMessageHandler* mock_html_message_handler_;
251 bool use_beacon_results_in_filters_;
252 bool use_test_url_namer_;
253 bool add_platform_specific_decoding_passes_;
254 std::vector<CreateFilterCallback*> filter_callback_vector_;
255 std::vector<CreateRewriterCallback*> rewriter_callback_vector_;
256 std::vector<PlatformSpecificConfigurationCallback*> platform_config_vector_;
257 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
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:188
Definition: test_rewrite_driver_factory.h:79
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:171
void set_add_platform_specific_decoding_passes(bool value)
Definition: test_rewrite_driver_factory.h:195
virtual void AddPlatformSpecificDecodingPasses(RewriteDriver *driver)
Definition: test_distributed_fetcher.h:37
static const int64 kStartTimeMs
Arbitrary time to start MockTimer.
Definition: test_rewrite_driver_factory.h:69
virtual bool UseBeaconResultsInFilters() const
By default this is false, but can be reset.
Definition: test_rewrite_driver_factory.h:162
virtual void AddPlatformSpecificRewritePasses(RewriteDriver *driver)
Definition: rewrite_filter.h:37
Definition: mock_url_fetcher.h:41
void AddCreateRewriterCallback(CreateRewriterCallback *callback)
Does NOT take ownership of the callback.
Definition: test_rewrite_driver_factory.h:153
virtual UrlNamer * DefaultUrlNamer()
Definition: rewrite_driver.h:98
Definition: process_context.h:35
static const int kMaxFetchGlobalQueueSize
Definition: test_rewrite_driver_factory.h:75
Statistics * statistics()
Definition: rewrite_driver_factory.h:242
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:144
Definition: rewrite_driver_factory.h:73