Page Speed Optimization Libraries
1.8.31.3
|
00001 // Copyright 2013 Google Inc. 00016 00017 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_ 00018 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_ 00019 00020 #include "net/instaweb/rewriter/public/rewrite_options.h" 00021 #include "net/instaweb/util/public/basictypes.h" 00022 #include "net/instaweb/util/public/string.h" 00023 #include "net/instaweb/util/public/string_util.h" 00024 00025 namespace net_instaweb { 00026 00027 class ThreadSystem; 00028 00031 class SystemRewriteOptions : public RewriteOptions { 00032 public: 00033 static void Initialize(); 00034 static void Terminate(); 00035 00036 SystemRewriteOptions(const StringPiece& description, 00037 ThreadSystem* thread_system); 00038 explicit SystemRewriteOptions(ThreadSystem* thread_system); 00039 virtual ~SystemRewriteOptions(); 00040 00041 int64 file_cache_clean_interval_ms() const { 00042 return file_cache_clean_interval_ms_.value(); 00043 } 00044 bool has_file_cache_clean_interval_ms() const { 00045 return file_cache_clean_interval_ms_.was_set(); 00046 } 00047 void set_file_cache_clean_interval_ms(int64 x) { 00048 set_option(x, &file_cache_clean_interval_ms_); 00049 } 00050 int64 file_cache_clean_size_kb() const { 00051 return file_cache_clean_size_kb_.value(); 00052 } 00053 bool has_file_cache_clean_size_kb() const { 00054 return file_cache_clean_size_kb_.was_set(); 00055 } 00056 void set_file_cache_clean_size_kb(int64 x) { 00057 set_option(x, &file_cache_clean_size_kb_); 00058 } 00059 int64 file_cache_clean_inode_limit() const { 00060 return file_cache_clean_inode_limit_.value(); 00061 } 00062 bool has_file_cache_clean_inode_limit() const { 00063 return file_cache_clean_inode_limit_.was_set(); 00064 } 00065 void set_file_cache_clean_inode_limit(int64 x) { 00066 set_option(x, &file_cache_clean_inode_limit_); 00067 } 00068 int64 lru_cache_byte_limit() const { 00069 return lru_cache_byte_limit_.value(); 00070 } 00071 void set_lru_cache_byte_limit(int64 x) { 00072 set_option(x, &lru_cache_byte_limit_); 00073 } 00074 int64 lru_cache_kb_per_process() const { 00075 return lru_cache_kb_per_process_.value(); 00076 } 00077 void set_lru_cache_kb_per_process(int64 x) { 00078 set_option(x, &lru_cache_kb_per_process_); 00079 } 00080 bool use_shared_mem_locking() const { 00081 return use_shared_mem_locking_.value(); 00082 } 00083 void set_use_shared_mem_locking(bool x) { 00084 set_option(x, &use_shared_mem_locking_); 00085 } 00086 bool compress_metadata_cache() const { 00087 return compress_metadata_cache_.value(); 00088 } 00089 void set_compress_metadata_cache(bool x) { 00090 set_option(x, &compress_metadata_cache_); 00091 } 00092 bool statistics_enabled() const { 00093 return statistics_enabled_.value(); 00094 } 00095 void set_statistics_enabled(bool x) { 00096 set_option(x, &statistics_enabled_); 00097 } 00098 bool statistics_logging_enabled() const { 00099 return statistics_logging_enabled_.value(); 00100 } 00101 void set_statistics_logging_enabled(bool x) { 00102 set_option(x, &statistics_logging_enabled_); 00103 } 00104 int64 statistics_logging_max_file_size_kb() const { 00105 return statistics_logging_max_file_size_kb_.value(); 00106 } 00107 const GoogleString& statistics_logging_charts_css() const { 00108 return statistics_logging_charts_css_.value(); 00109 } 00110 const GoogleString& statistics_logging_charts_js() const { 00111 return statistics_logging_charts_js_.value(); 00112 } 00113 int64 statistics_logging_interval_ms() const { 00114 return statistics_logging_interval_ms_.value(); 00115 } 00116 void set_statistics_logging_interval_ms(int64 x) { 00117 set_option(x, &statistics_logging_interval_ms_); 00118 } 00119 const GoogleString& file_cache_path() const { 00120 return file_cache_path_.value(); 00121 } 00122 void set_file_cache_path(const GoogleString& x) { 00123 set_option(x, &file_cache_path_); 00124 } 00125 const GoogleString& log_dir() const { return log_dir_.value(); } 00126 void set_log_dir(const GoogleString& x) { set_option(x, &log_dir_); } 00127 const GoogleString& memcached_servers() const { 00128 return memcached_servers_.value(); 00129 } 00130 void set_memcached_servers(const GoogleString& x) { 00131 set_option(x, &memcached_servers_); 00132 } 00133 int memcached_threads() const { 00134 return memcached_threads_.value(); 00135 } 00136 void set_memcached_threads(int x) { 00137 set_option(x, &memcached_threads_); 00138 } 00139 int memcached_timeout_us() const { 00140 return memcached_timeout_us_.value(); 00141 } 00142 bool has_memcached_timeout_us() const { 00143 return memcached_timeout_us_.was_set(); 00144 } 00145 void set_memcached_timeout_us(int x) { 00146 set_option(x, &memcached_timeout_us_); 00147 } 00148 const GoogleString& fetcher_proxy() const { 00149 return fetcher_proxy_.value(); 00150 } 00151 void set_fetcher_proxy(const GoogleString& x) { 00152 set_option(x, &fetcher_proxy_); 00153 } 00154 00156 void set_cache_flush_poll_interval_sec(int64 num_seconds) { 00157 set_option(num_seconds, &cache_flush_poll_interval_sec_); 00158 } 00159 int64 cache_flush_poll_interval_sec() const { 00160 return cache_flush_poll_interval_sec_.value(); 00161 } 00162 void set_cache_flush_filename(const StringPiece& sp) { 00163 set_option(sp.as_string(), &cache_flush_filename_); 00164 } 00165 const GoogleString& cache_flush_filename() const { 00166 return cache_flush_filename_.value(); 00167 } 00168 00169 const GoogleString& https_options() const { 00170 return https_options_.value(); 00171 } 00172 const GoogleString& ssl_cert_directory() const { 00173 return ssl_cert_directory_.value(); 00174 } 00175 const GoogleString& ssl_cert_file() const { 00176 return ssl_cert_file_.value(); 00177 } 00178 00179 int64 slurp_flush_limit() const { 00180 return slurp_flush_limit_.value(); 00181 } 00182 void set_slurp_flush_limit(int64 x) { 00183 set_option(x, &slurp_flush_limit_); 00184 } 00185 bool slurp_read_only() const { 00186 return slurp_read_only_.value(); 00187 } 00188 void set_slurp_read_only(bool x) { 00189 set_option(x, &slurp_read_only_); 00190 } 00191 bool rate_limit_background_fetches() const { 00192 return rate_limit_background_fetches_.value(); 00193 } 00194 const GoogleString& slurp_directory() const { 00195 return slurp_directory_.value(); 00196 } 00197 void set_slurp_directory(GoogleString x) { 00198 set_option(x, &slurp_directory_); 00199 } 00200 bool disable_loopback_routing() const { 00201 return disable_loopback_routing_.value(); 00202 } 00203 bool fetch_with_gzip() const { 00204 return fetch_with_gzip_.value(); 00205 } 00206 int64 ipro_max_response_bytes() const { 00207 return ipro_max_response_bytes_.value(); 00208 } 00209 int64 ipro_max_concurrent_recordings() const { 00210 return ipro_max_concurrent_recordings_.value(); 00211 } 00212 int64 default_shared_memory_cache_kb() const { 00213 return default_shared_memory_cache_kb_.value(); 00214 } 00215 void set_default_shared_memory_cache_kb(int64 x) { 00216 set_option(x, &default_shared_memory_cache_kb_); 00217 } 00218 00222 bool test_proxy() const { 00223 return test_proxy_.value(); 00224 } 00225 void set_test_proxy(bool x) { 00226 set_option(x, &test_proxy_); 00227 } 00228 00235 GoogleString test_proxy_slurp() const { 00236 return test_proxy_slurp_.value(); 00237 } 00238 00240 bool slurping_enabled() const { 00241 return !slurp_directory().empty(); 00242 } 00243 00244 bool slurping_enabled_read_only() const { 00245 return slurping_enabled() && slurp_read_only(); 00246 } 00247 00248 virtual SystemRewriteOptions* Clone() const; 00249 virtual SystemRewriteOptions* NewOptions() const; 00250 00253 static const SystemRewriteOptions* DynamicCast( 00254 const RewriteOptions* instance); 00255 static SystemRewriteOptions* DynamicCast(RewriteOptions* instance); 00256 00260 StringPiece description() const { return description_; } 00261 void set_description(const StringPiece& x) { x.CopyToString(&description_); } 00262 00263 private: 00266 class HttpsOptions : public Option<GoogleString> { 00267 public: 00268 virtual bool SetFromString(StringPiece value_string, 00269 GoogleString* error_detail); 00270 }; 00271 00274 static Properties* system_properties_; 00275 00278 template<class OptionClass> 00279 static void AddSystemProperty(typename OptionClass::ValueType default_value, 00280 OptionClass SystemRewriteOptions::*offset, 00281 const char* id, 00282 StringPiece option_name, 00283 const char* help) { 00284 AddProperty(default_value, offset, id, option_name, kServerScope, help, 00285 system_properties_); 00286 } 00287 00288 template<class OptionClass> 00289 static void AddSystemProperty(typename OptionClass::ValueType default_value, 00290 OptionClass SystemRewriteOptions::*offset, 00291 const char* id, 00292 StringPiece option_name, 00293 OptionScope scope, 00294 const char* help) { 00295 AddProperty(default_value, offset, id, option_name, scope, help, 00296 system_properties_); 00297 } 00298 00299 static void AddProperties(); 00300 00302 GoogleString description_; 00303 00304 Option<GoogleString> fetcher_proxy_; 00305 Option<GoogleString> file_cache_path_; 00306 Option<GoogleString> log_dir_; 00307 00310 Option<GoogleString> memcached_servers_; 00311 Option<GoogleString> statistics_logging_charts_css_; 00312 Option<GoogleString> statistics_logging_charts_js_; 00313 Option<GoogleString> cache_flush_filename_; 00314 Option<GoogleString> ssl_cert_directory_; 00315 Option<GoogleString> ssl_cert_file_; 00316 HttpsOptions https_options_; 00317 00318 Option<GoogleString> slurp_directory_; 00319 Option<GoogleString> test_proxy_slurp_; 00320 00321 Option<bool> statistics_enabled_; 00322 Option<bool> statistics_logging_enabled_; 00323 Option<bool> use_shared_mem_locking_; 00324 Option<bool> compress_metadata_cache_; 00325 00326 Option<bool> slurp_read_only_; 00327 Option<bool> test_proxy_; 00328 Option<bool> rate_limit_background_fetches_; 00329 00332 Option<bool> disable_loopback_routing_; 00333 00337 Option<bool> fetch_with_gzip_; 00338 00339 Option<int> memcached_threads_; 00340 Option<int> memcached_timeout_us_; 00341 00342 Option<int64> file_cache_clean_inode_limit_; 00343 Option<int64> file_cache_clean_interval_ms_; 00344 Option<int64> file_cache_clean_size_kb_; 00345 Option<int64> lru_cache_byte_limit_; 00346 Option<int64> lru_cache_kb_per_process_; 00347 Option<int64> statistics_logging_interval_ms_; 00350 Option<int64> cache_flush_poll_interval_sec_; 00351 Option<int64> statistics_logging_max_file_size_kb_; 00352 Option<int64> slurp_flush_limit_; 00353 Option<int64> ipro_max_response_bytes_; 00354 Option<int64> ipro_max_concurrent_recordings_; 00355 Option<int64> default_shared_memory_cache_kb_; 00356 00357 DISALLOW_COPY_AND_ASSIGN(SystemRewriteOptions); 00358 }; 00359 00360 } 00361 00362 #endif ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_