Page Speed Optimization Libraries  1.7.30.1
net/instaweb/system/public/system_rewrite_options.h
Go to the documentation of this file.
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   void set_file_cache_clean_interval_ms(int64 x) {
00045     set_option(x, &file_cache_clean_interval_ms_);
00046   }
00047   int64 file_cache_clean_size_kb() const {
00048     return file_cache_clean_size_kb_.value();
00049   }
00050   void set_file_cache_clean_size_kb(int64 x) {
00051     set_option(x, &file_cache_clean_size_kb_);
00052   }
00053   int64 file_cache_clean_inode_limit() const {
00054     return file_cache_clean_inode_limit_.value();
00055   }
00056   void set_file_cache_clean_inode_limit(int64 x) {
00057     set_option(x, &file_cache_clean_inode_limit_);
00058   }
00059   int64 lru_cache_byte_limit() const {
00060     return lru_cache_byte_limit_.value();
00061   }
00062   void set_lru_cache_byte_limit(int64 x) {
00063     set_option(x, &lru_cache_byte_limit_);
00064   }
00065   int64 lru_cache_kb_per_process() const {
00066     return lru_cache_kb_per_process_.value();
00067   }
00068   void set_lru_cache_kb_per_process(int64 x) {
00069     set_option(x, &lru_cache_kb_per_process_);
00070   }
00071   bool use_shared_mem_locking() const {
00072     return use_shared_mem_locking_.value();
00073   }
00074   void set_use_shared_mem_locking(bool x) {
00075     set_option(x, &use_shared_mem_locking_);
00076   }
00077   bool compress_metadata_cache() const {
00078     return compress_metadata_cache_.value();
00079   }
00080   void set_compress_metadata_cache(bool x) {
00081     set_option(x, &compress_metadata_cache_);
00082   }
00083   bool statistics_enabled() const {
00084     return statistics_enabled_.value();
00085   }
00086   void set_statistics_enabled(bool x) {
00087     set_option(x, &statistics_enabled_);
00088   }
00089   const GoogleString& statistics_handler_path() const {
00090     return statistics_handler_path_.value();
00091   }
00092   void set_statistics_handler_path(const GoogleString& x) {
00093     set_option(x, &statistics_handler_path_);
00094   }
00095   bool statistics_logging_enabled() const {
00096     return statistics_logging_enabled_.value();
00097   }
00098   void set_statistics_logging_enabled(bool x) {
00099     set_option(x, &statistics_logging_enabled_);
00100   }
00101   int64 statistics_logging_max_file_size_kb() const {
00102     return statistics_logging_max_file_size_kb_.value();
00103   }
00104   const GoogleString& statistics_logging_charts_css() const {
00105     return statistics_logging_charts_css_.value();
00106   }
00107   const GoogleString& statistics_logging_charts_js() const {
00108     return statistics_logging_charts_js_.value();
00109   }
00110   int64 statistics_logging_interval_ms() const {
00111     return statistics_logging_interval_ms_.value();
00112   }
00113   void set_statistics_logging_interval_ms(int64 x) {
00114     set_option(x, &statistics_logging_interval_ms_);
00115   }
00116   const GoogleString& file_cache_path() const {
00117     return file_cache_path_.value();
00118   }
00119   void set_file_cache_path(const GoogleString& x) {
00120     set_option(x, &file_cache_path_);
00121   }
00122   const GoogleString& log_dir() const { return log_dir_.value(); }
00123   void set_log_dir(const GoogleString& x) { set_option(x, &log_dir_); }
00124   const GoogleString& memcached_servers() const {
00125     return memcached_servers_.value();
00126   }
00127   void set_memcached_servers(const GoogleString& x) {
00128     set_option(x, &memcached_servers_);
00129   }
00130   int memcached_threads() const {
00131     return memcached_threads_.value();
00132   }
00133   void set_memcached_threads(int x) {
00134     set_option(x, &memcached_threads_);
00135   }
00136   int memcached_timeout_us() const {
00137     return memcached_timeout_us_.value();
00138   }
00139   bool has_memcached_timeout_us() const {
00140     return memcached_timeout_us_.was_set();
00141   }
00142   void set_memcached_timeout_us(int x) {
00143     set_option(x, &memcached_timeout_us_);
00144   }
00145   const GoogleString& fetcher_proxy() const {
00146     return fetcher_proxy_.value();
00147   }
00148   void set_fetcher_proxy(const GoogleString& x) {
00149     set_option(x, &fetcher_proxy_);
00150   }
00151 
00153   void set_cache_flush_poll_interval_sec(int64 num_seconds) {
00154     set_option(num_seconds, &cache_flush_poll_interval_sec_);
00155   }
00156   int64 cache_flush_poll_interval_sec() const {
00157     return cache_flush_poll_interval_sec_.value();
00158   }
00159   void set_cache_flush_filename(const StringPiece& sp) {
00160     set_option(sp.as_string(), &cache_flush_filename_);
00161   }
00162   const GoogleString& cache_flush_filename() const {
00163     return cache_flush_filename_.value();
00164   }
00165 
00166   const GoogleString& ssl_cert_directory() const {
00167     return ssl_cert_directory_.value();
00168   }
00169   const GoogleString& ssl_cert_file() const {
00170     return ssl_cert_file_.value();
00171   }
00172 
00173   int64 slurp_flush_limit() const {
00174     return slurp_flush_limit_.value();
00175   }
00176   void set_slurp_flush_limit(int64 x) {
00177     set_option(x, &slurp_flush_limit_);
00178   }
00179   bool slurp_read_only() const {
00180     return slurp_read_only_.value();
00181   }
00182   void set_slurp_read_only(bool x) {
00183     set_option(x, &slurp_read_only_);
00184   }
00185   bool rate_limit_background_fetches() const {
00186     return rate_limit_background_fetches_.value();
00187   }
00188   const GoogleString& slurp_directory() const {
00189     return slurp_directory_.value();
00190   }
00191   void set_slurp_directory(GoogleString x) {
00192     set_option(x, &slurp_directory_);
00193   }
00194   bool disable_loopback_routing() const {
00195     return disable_loopback_routing_.value();
00196   }
00197   bool fetch_with_gzip() const {
00198     return fetch_with_gzip_.value();
00199   }
00200   int64 ipro_max_response_bytes() const {
00201     return ipro_max_response_bytes_.value();
00202   }
00203   int64 ipro_max_concurrent_recordings() const {
00204     return ipro_max_concurrent_recordings_.value();
00205   }
00206   int64 default_shared_memory_cache_kb() const {
00207     return default_shared_memory_cache_kb_.value();
00208   }
00209   void set_default_shared_memory_cache_kb(int64 x) {
00210     set_option(x, &default_shared_memory_cache_kb_);
00211   }
00212 
00216   bool test_proxy() const {
00217     return test_proxy_.value();
00218   }
00219   void set_test_proxy(bool x) {
00220     set_option(x, &test_proxy_);
00221   }
00222 
00229   GoogleString test_proxy_slurp() const {
00230     return test_proxy_slurp_.value();
00231   }
00232 
00234   bool slurping_enabled() const {
00235     return !slurp_directory().empty();
00236   }
00237 
00238   bool slurping_enabled_read_only() const {
00239     return slurping_enabled() && slurp_read_only();
00240   }
00241 
00242   virtual SystemRewriteOptions* Clone() const;
00243   virtual SystemRewriteOptions* NewOptions() const;
00244 
00247   static const SystemRewriteOptions* DynamicCast(
00248       const RewriteOptions* instance);
00249   static SystemRewriteOptions* DynamicCast(RewriteOptions* instance);
00250 
00254   StringPiece description() const { return description_; }
00255   void set_description(const StringPiece& x) { x.CopyToString(&description_); }
00256 
00257  protected:
00259   Option<GoogleString> statistics_handler_path_;
00260 
00261  private:
00264   static Properties* system_properties_;
00265 
00268   template<class OptionClass>
00269   static void AddSystemProperty(typename OptionClass::ValueType default_value,
00270                                 OptionClass SystemRewriteOptions::*offset,
00271                                 const char* id,
00272                                 StringPiece option_name,
00273                                 const char* help) {
00274     AddProperty(default_value, offset, id, option_name, kServerScope, help,
00275                 system_properties_);
00276   }
00277 
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                                 OptionScope scope,
00284                                 const char* help) {
00285     AddProperty(default_value, offset, id, option_name, scope, help,
00286                 system_properties_);
00287   }
00288 
00289   static void AddProperties();
00290 
00292   GoogleString description_;
00293 
00294   Option<GoogleString> fetcher_proxy_;
00295   Option<GoogleString> file_cache_path_;
00296   Option<GoogleString> log_dir_;
00297 
00300   Option<GoogleString> memcached_servers_;
00301   Option<GoogleString> statistics_logging_charts_css_;
00302   Option<GoogleString> statistics_logging_charts_js_;
00303   Option<GoogleString> cache_flush_filename_;
00304   Option<GoogleString> ssl_cert_directory_;
00305   Option<GoogleString> ssl_cert_file_;
00306 
00307   Option<GoogleString> slurp_directory_;
00308   Option<GoogleString> test_proxy_slurp_;
00309 
00310   Option<bool> statistics_enabled_;
00311   Option<bool> statistics_logging_enabled_;
00312   Option<bool> use_shared_mem_locking_;
00313   Option<bool> compress_metadata_cache_;
00314 
00315   Option<bool> slurp_read_only_;
00316   Option<bool> test_proxy_;
00317   Option<bool> rate_limit_background_fetches_;
00318 
00321   Option<bool> disable_loopback_routing_;
00322 
00326   Option<bool> fetch_with_gzip_;
00327 
00328   Option<int> memcached_threads_;
00329   Option<int> memcached_timeout_us_;
00330 
00331   Option<int64> file_cache_clean_inode_limit_;
00332   Option<int64> file_cache_clean_interval_ms_;
00333   Option<int64> file_cache_clean_size_kb_;
00334   Option<int64> lru_cache_byte_limit_;
00335   Option<int64> lru_cache_kb_per_process_;
00336   Option<int64> statistics_logging_interval_ms_;
00339   Option<int64> cache_flush_poll_interval_sec_;
00340   Option<int64> statistics_logging_max_file_size_kb_;
00341   Option<int64> slurp_flush_limit_;
00342   Option<int64> ipro_max_response_bytes_;
00343   Option<int64> ipro_max_concurrent_recordings_;
00344   Option<int64> default_shared_memory_cache_kb_;
00345 
00346   DISALLOW_COPY_AND_ASSIGN(SystemRewriteOptions);
00347 };
00348 
00349 }  
00350 
00351 #endif  ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines