17 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_DRIVER_FACTORY_H_
18 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_DRIVER_FACTORY_H_
27 #include "pagespeed/kernel/base/scoped_ptr.h"
28 #include "pagespeed/kernel/base/string.h"
29 #include "pagespeed/kernel/base/string_util.h"
31 namespace net_instaweb {
33 class AbstractSharedMem;
37 class NamedLockManager;
40 class QueuedWorkerPool;
42 class SharedCircularBuffer;
43 class SharedMemStatistics;
44 class StaticAssetManager;
47 class SystemRewriteOptions;
48 class SystemServerContext;
49 class SystemThreadSystem;
51 class UrlAsyncFetcher;
68 AbstractSharedMem* shared_mem_runtime,
69 StringPiece hostname,
int port);
77 AbstractSharedMem* shared_mem_runtime()
const {
78 return shared_mem_runtime_.get();
116 virtual void RootInit();
117 virtual void ChildInit();
130 void PostConfig(
const std::vector<SystemServerContext*>& server_contexts,
131 GoogleString* error_message,
133 Statistics** global_statistics);
155 MessageHandler* handler);
162 MessageHandler* handler);
164 virtual Hasher* NewHasher();
165 virtual Timer* DefaultTimer();
173 GoogleString hostname_identifier() {
return hostname_identifier_; }
179 virtual void StopCacheActivity();
181 SystemCaches* caches() {
return caches_.get(); }
183 virtual void set_message_buffer_size(
int x) {
184 message_buffer_size_ = x;
190 UrlAsyncFetcher*
GetFetcher(SystemRewriteOptions* config);
195 track_original_content_length_ = x;
197 bool track_original_content_length()
const {
198 return track_original_content_length_;
206 list_outstanding_urls_on_error_ = x;
216 void set_static_asset_prefix(StringPiece s) {
217 s.CopyToString(&static_asset_prefix_);
219 const GoogleString& static_asset_prefix() {
return static_asset_prefix_; }
221 int num_rewrite_threads()
const {
return num_rewrite_threads_; }
222 void set_num_rewrite_threads(
int x) { num_rewrite_threads_ = x; }
223 int num_expensive_rewrite_threads()
const {
224 return num_expensive_rewrite_threads_;
226 void set_num_expensive_rewrite_threads(
int x) {
227 num_expensive_rewrite_threads_ = x;
229 bool use_per_vhost_statistics()
const {
230 return use_per_vhost_statistics_;
232 void set_use_per_vhost_statistics(
bool x) {
233 use_per_vhost_statistics_ = x;
235 bool install_crash_handler()
const {
236 return install_crash_handler_;
238 void set_install_crash_handler(
bool x) {
239 install_crash_handler_ = x;
264 static void InitStats(Statistics* statistics);
275 virtual void ShutDownMessageHandlers() {}
276 virtual void SetCircularBuffer(SharedCircularBuffer* buffer) {}
297 virtual FileSystem* DefaultFileSystem();
304 bool thread_counts_finalized() {
return thread_counts_finalized_; }
309 Statistics* SetUpGlobalSharedMemStatistics(
315 GoogleString GetFetcherKey(
bool include_slurping_config,
326 scoped_ptr<SharedMemStatistics> shared_mem_statistics_;
329 StringVector local_shm_stats_segment_names_;
330 scoped_ptr<AbstractSharedMem> shared_mem_runtime_;
331 scoped_ptr<SharedCircularBuffer> shared_circular_buffer_;
333 bool statistics_frozen_;
334 bool is_root_process_;
339 const GoogleString hostname_identifier_;
343 int message_buffer_size_;
346 scoped_ptr<SystemCaches> caches_;
348 bool track_original_content_length_;
349 bool list_outstanding_urls_on_error_;
363 typedef std::map<GoogleString, UrlAsyncFetcher*> FetcherMap;
364 FetcherMap base_fetcher_map_;
365 FetcherMap fetcher_map_;
368 GoogleString static_asset_prefix_;
376 bool use_per_vhost_statistics_;
379 bool install_crash_handler_;
382 bool thread_counts_finalized_;
385 int num_rewrite_threads_;
386 int num_expensive_rewrite_threads_;
void PostConfig(const std::vector< SystemServerContext * > &server_contexts, GoogleString *error_message, int *error_index, Statistics **global_statistics)
virtual int LookupThreadLimit()
Definition: system_rewrite_driver_factory.h:257
virtual void ParentOrChildInit()
Definition: static_asset_manager.h:44
bool is_root_process() const
Definition: system_rewrite_driver_factory.h:115
std::set< SystemServerContext * > SystemServerContextSet
Definition: system_rewrite_driver_factory.h:289
SystemRewriteDriverFactory(const ProcessContext &process_context, SystemThreadSystem *thread_system, AbstractSharedMem *shared_mem_runtime, StringPiece hostname, int port)
virtual void AutoDetectThreadCounts()
virtual void SetupCaches(ServerContext *server_context)
WorkerPoolCategory
Definition: rewrite_driver_factory.h:78
void set_track_original_content_length(bool x)
Definition: system_rewrite_driver_factory.h:194
virtual int requests_per_host()
Normally 4, or #threads if that's more.
UrlAsyncFetcher * GetFetcher(SystemRewriteOptions *config)
A server context with features specific to a psol port on a unix system.
Definition: system_rewrite_driver_factory.h:54
virtual bool IsServerThreaded()
Definition: system_rewrite_driver_factory.h:251
Definition: system_thread_system.h:32
Definition: system_rewrite_options.h:31
virtual RewriteOptions::OptionSettingResult ParseAndSetOption1(StringPiece option, StringPiece arg, bool process_scope, GoogleString *msg, MessageHandler *handler)
static void InitStats(Statistics *statistics)
virtual void SetupMessageHandlers()
Definition: system_rewrite_driver_factory.h:274
virtual NamedLockManager * DefaultLockManager()
virtual void NonStaticInitStats(Statistics *statistics)=0
Definition: server_context.h:100
Definition: process_context.h:35
void SharedCircularBufferInit(bool is_root)
virtual int max_queue_size()
Definition: system_rewrite_driver_factory.h:212
Statistics * statistics()
Definition: rewrite_driver_factory.h:242
OptionSettingResult
Used for return value of SetOptionFromName.
Definition: rewrite_options.h:599
NonceGenerator * DefaultNonceGenerator()
Creates a HashedNonceGenerator initialized with data from /dev/random.
virtual bool enable_property_cache() const
Hook so implementations may disable the property cache.
Definition: system_rewrite_driver_factory.h:169
virtual void ShutDownFetchers()
Definition: system_rewrite_driver_factory.h:280
virtual UrlAsyncFetcher * AllocateFetcher(SystemRewriteOptions *config)
virtual QueuedWorkerPool * CreateWorkerPool(WorkerPoolCategory pool, StringPiece name)
SharedMemStatistics * AllocateAndInitSharedMemStatistics(bool local, const StringPiece &name, const SystemRewriteOptions &options)
Creates and ::Initializes a shared memory statistics object.
virtual bool UseBeaconResultsInFilters() const
Definition: system_rewrite_driver_factory.h:244
virtual void InitStaticAssetManager(StaticAssetManager *static_asset_manager)
Initializes the StaticAssetManager.
virtual ServerContext * NewServerContext()
Definition: url_async_fetcher.h:33
void list_outstanding_urls_on_error(bool x)
Definition: system_rewrite_driver_factory.h:205
Definition: rewrite_driver_factory.h:73