Page Speed Optimization Libraries
1.6.29.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 explicit SystemRewriteOptions(ThreadSystem* thread_system); 00037 virtual ~SystemRewriteOptions(); 00038 00039 int64 file_cache_clean_interval_ms() const { 00040 return file_cache_clean_interval_ms_.value(); 00041 } 00042 void set_file_cache_clean_interval_ms(int64 x) { 00043 set_option(x, &file_cache_clean_interval_ms_); 00044 } 00045 int64 file_cache_clean_size_kb() const { 00046 return file_cache_clean_size_kb_.value(); 00047 } 00048 void set_file_cache_clean_size_kb(int64 x) { 00049 set_option(x, &file_cache_clean_size_kb_); 00050 } 00051 int64 file_cache_clean_inode_limit() const { 00052 return file_cache_clean_inode_limit_.value(); 00053 } 00054 void set_file_cache_clean_inode_limit(int64 x) { 00055 set_option(x, &file_cache_clean_inode_limit_); 00056 } 00057 int64 lru_cache_byte_limit() const { 00058 return lru_cache_byte_limit_.value(); 00059 } 00060 void set_lru_cache_byte_limit(int64 x) { 00061 set_option(x, &lru_cache_byte_limit_); 00062 } 00063 int64 lru_cache_kb_per_process() const { 00064 return lru_cache_kb_per_process_.value(); 00065 } 00066 void set_lru_cache_kb_per_process(int64 x) { 00067 set_option(x, &lru_cache_kb_per_process_); 00068 } 00069 bool use_shared_mem_locking() const { 00070 return use_shared_mem_locking_.value(); 00071 } 00072 void set_use_shared_mem_locking(bool x) { 00073 set_option(x, &use_shared_mem_locking_); 00074 } 00075 bool compress_metadata_cache() const { 00076 return compress_metadata_cache_.value(); 00077 } 00078 void set_compress_metadata_cache(bool x) { 00079 set_option(x, &compress_metadata_cache_); 00080 } 00081 bool statistics_enabled() const { 00082 return statistics_enabled_.value(); 00083 } 00084 void set_statistics_enabled(bool x) { 00085 set_option(x, &statistics_enabled_); 00086 } 00087 const GoogleString& statistics_handler_path() const { 00088 return statistics_handler_path_.value(); 00089 } 00090 void set_statistics_handler_path(const GoogleString& x) { 00091 set_option(x, &statistics_handler_path_); 00092 } 00093 bool statistics_logging_enabled() const { 00094 return statistics_logging_enabled_.value(); 00095 } 00096 void set_statistics_logging_enabled(bool x) { 00097 set_option(x, &statistics_logging_enabled_); 00098 } 00099 int64 statistics_logging_max_file_size_kb() const { 00100 return statistics_logging_max_file_size_kb_.value(); 00101 } 00102 const GoogleString& statistics_logging_charts_css() const { 00103 return statistics_logging_charts_css_.value(); 00104 } 00105 const GoogleString& statistics_logging_charts_js() const { 00106 return statistics_logging_charts_js_.value(); 00107 } 00108 int64 statistics_logging_interval_ms() const { 00109 return statistics_logging_interval_ms_.value(); 00110 } 00111 void set_statistics_logging_interval_ms(int64 x) { 00112 set_option(x, &statistics_logging_interval_ms_); 00113 } 00114 const GoogleString& file_cache_path() const { 00115 return file_cache_path_.value(); 00116 } 00117 void set_file_cache_path(const GoogleString& x) { 00118 set_option(x, &file_cache_path_); 00119 } 00120 const GoogleString& log_dir() const { return log_dir_.value(); } 00121 void set_log_dir(const GoogleString& x) { set_option(x, &log_dir_); } 00122 const GoogleString& memcached_servers() const { 00123 return memcached_servers_.value(); 00124 } 00125 void set_memcached_servers(const GoogleString& x) { 00126 set_option(x, &memcached_servers_); 00127 } 00128 int memcached_threads() const { 00129 return memcached_threads_.value(); 00130 } 00131 void set_memcached_threads(int x) { 00132 set_option(x, &memcached_threads_); 00133 } 00134 int memcached_timeout_us() const { 00135 return memcached_timeout_us_.value(); 00136 } 00137 bool has_memcached_timeout_us() const { 00138 return memcached_timeout_us_.was_set(); 00139 } 00140 void set_memcached_timeout_us(int x) { 00141 set_option(x, &memcached_timeout_us_); 00142 } 00143 const GoogleString& fetcher_proxy() const { 00144 return fetcher_proxy_.value(); 00145 } 00146 void set_fetcher_proxy(const GoogleString& x) { 00147 set_option(x, &fetcher_proxy_); 00148 } 00149 00151 void set_cache_flush_poll_interval_sec(int64 num_seconds) { 00152 set_option(num_seconds, &cache_flush_poll_interval_sec_); 00153 } 00154 int64 cache_flush_poll_interval_sec() const { 00155 return cache_flush_poll_interval_sec_.value(); 00156 } 00157 void set_cache_flush_filename(const StringPiece& sp) { 00158 set_option(sp.as_string(), &cache_flush_filename_); 00159 } 00160 const GoogleString& cache_flush_filename() const { 00161 return cache_flush_filename_.value(); 00162 } 00163 00164 const GoogleString& ssl_cert_directory() const { 00165 return ssl_cert_directory_.value(); 00166 } 00167 const GoogleString& ssl_cert_file() const { 00168 return ssl_cert_file_.value(); 00169 } 00170 00171 virtual SystemRewriteOptions* Clone() const; 00172 virtual SystemRewriteOptions* NewOptions() const; 00173 00174 protected: 00176 Option<GoogleString> statistics_handler_path_; 00177 00178 private: 00181 static Properties* system_properties_; 00182 00185 template<class RewriteOptionsSubclass, class OptionClass> 00186 static void AddSystemProperty(typename OptionClass::ValueType default_value, 00187 OptionClass RewriteOptionsSubclass::*offset, 00188 const char* id, 00189 StringPiece option_name, 00190 const char* help) { 00191 AddProperty(default_value, offset, id, option_name, kServerScope, help, 00192 system_properties_); 00193 } 00194 00195 static void AddProperties(); 00196 00197 Option<GoogleString> fetcher_proxy_; 00198 Option<GoogleString> file_cache_path_; 00199 Option<GoogleString> log_dir_; 00200 00203 Option<GoogleString> memcached_servers_; 00204 Option<GoogleString> statistics_logging_charts_css_; 00205 Option<GoogleString> statistics_logging_charts_js_; 00206 Option<GoogleString> cache_flush_filename_; 00207 Option<GoogleString> ssl_cert_directory_; 00208 Option<GoogleString> ssl_cert_file_; 00209 00210 Option<bool> statistics_enabled_; 00211 Option<bool> statistics_logging_enabled_; 00212 Option<bool> use_shared_mem_locking_; 00213 Option<bool> compress_metadata_cache_; 00214 00215 Option<int> memcached_threads_; 00216 Option<int> memcached_timeout_us_; 00217 00218 Option<int64> file_cache_clean_inode_limit_; 00219 Option<int64> file_cache_clean_interval_ms_; 00220 Option<int64> file_cache_clean_size_kb_; 00221 Option<int64> lru_cache_byte_limit_; 00222 Option<int64> lru_cache_kb_per_process_; 00223 Option<int64> statistics_logging_interval_ms_; 00226 Option<int64> cache_flush_poll_interval_sec_; 00227 Option<int64> statistics_logging_max_file_size_kb_; 00228 00229 DISALLOW_COPY_AND_ASSIGN(SystemRewriteOptions); 00230 }; 00231 00232 } 00233 00234 #endif ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_