Page Speed Optimization Libraries
1.5.27.2
|
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 bool statistics_logging_enabled() const { 00088 return statistics_logging_enabled_.value(); 00089 } 00090 void set_statistics_logging_enabled(bool x) { 00091 set_option(x, &statistics_logging_enabled_); 00092 } 00093 const GoogleString& statistics_logging_file_prefix() const { 00094 return statistics_logging_file_prefix_.value(); 00095 } 00096 int64 statistics_logging_max_file_size_kb() const { 00097 return statistics_logging_max_file_size_kb_.value(); 00098 } 00099 const GoogleString& statistics_logging_charts_css() const { 00100 return statistics_logging_charts_css_.value(); 00101 } 00102 const GoogleString& statistics_logging_charts_js() const { 00103 return statistics_logging_charts_js_.value(); 00104 } 00105 void set_statistics_logging_file_prefix(GoogleString x) { 00106 set_option(x, &statistics_logging_file_prefix_); 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(GoogleString x) { 00118 set_option(x, &file_cache_path_); 00119 } 00120 const GoogleString& memcached_servers() const { 00121 return memcached_servers_.value(); 00122 } 00123 void set_memcached_servers(GoogleString x) { 00124 set_option(x, &memcached_servers_); 00125 } 00126 int memcached_threads() const { 00127 return memcached_threads_.value(); 00128 } 00129 void set_memcached_threads(int x) { 00130 set_option(x, &memcached_threads_); 00131 } 00132 int memcached_timeout_us() const { 00133 return memcached_timeout_us_.value(); 00134 } 00135 bool has_memcached_timeout_us() const { 00136 return memcached_timeout_us_.was_set(); 00137 } 00138 void set_memcached_timeout_us(int x) { 00139 set_option(x, &memcached_timeout_us_); 00140 } 00141 const GoogleString& fetcher_proxy() const { 00142 return fetcher_proxy_.value(); 00143 } 00144 void set_fetcher_proxy(GoogleString x) { 00145 set_option(x, &fetcher_proxy_); 00146 } 00147 00149 void set_cache_flush_poll_interval_sec(int64 num_seconds) { 00150 set_option(num_seconds, &cache_flush_poll_interval_sec_); 00151 } 00152 int64 cache_flush_poll_interval_sec() const { 00153 return cache_flush_poll_interval_sec_.value(); 00154 } 00155 void set_cache_flush_filename(const StringPiece& sp) { 00156 set_option(sp.as_string(), &cache_flush_filename_); 00157 } 00158 const GoogleString& cache_flush_filename() const { 00159 return cache_flush_filename_.value(); 00160 } 00161 00162 virtual SystemRewriteOptions* Clone() const; 00163 virtual SystemRewriteOptions* NewOptions() const; 00164 00165 private: 00168 static Properties* system_properties_; 00169 00172 template<class RewriteOptionsSubclass, class OptionClass> 00173 static void AddSystemProperty(typename OptionClass::ValueType default_value, 00174 OptionClass RewriteOptionsSubclass::*offset, 00175 const char* id, 00176 OptionEnum option_enum, 00177 const char* help) { 00178 AddProperty(default_value, offset, id, option_enum, kServerScope, help, 00179 system_properties_); 00180 } 00181 00182 static void AddProperties(); 00183 00184 Option<GoogleString> fetcher_proxy_; 00185 Option<GoogleString> file_cache_path_; 00186 00189 Option<GoogleString> memcached_servers_; 00190 Option<GoogleString> statistics_logging_file_prefix_; 00191 Option<GoogleString> statistics_logging_charts_css_; 00192 Option<GoogleString> statistics_logging_charts_js_; 00193 Option<GoogleString> cache_flush_filename_; 00194 00195 Option<bool> statistics_enabled_; 00196 Option<bool> statistics_logging_enabled_; 00197 Option<bool> use_shared_mem_locking_; 00198 Option<bool> compress_metadata_cache_; 00199 00200 Option<int> memcached_threads_; 00201 Option<int> memcached_timeout_us_; 00202 00203 Option<int64> file_cache_clean_inode_limit_; 00204 Option<int64> file_cache_clean_interval_ms_; 00205 Option<int64> file_cache_clean_size_kb_; 00206 Option<int64> lru_cache_byte_limit_; 00207 Option<int64> lru_cache_kb_per_process_; 00208 Option<int64> statistics_logging_interval_ms_; 00211 Option<int64> cache_flush_poll_interval_sec_; 00212 Option<int64> statistics_logging_max_file_size_kb_; 00213 00214 DISALLOW_COPY_AND_ASSIGN(SystemRewriteOptions); 00215 }; 00216 00217 } 00218 00219 #endif ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_