Page Speed Optimization Libraries  1.7.30.4
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& https_options() const {
00167     return https_options_.value();
00168   }
00169   const GoogleString& ssl_cert_directory() const {
00170     return ssl_cert_directory_.value();
00171   }
00172   const GoogleString& ssl_cert_file() const {
00173     return ssl_cert_file_.value();
00174   }
00175 
00176   int64 slurp_flush_limit() const {
00177     return slurp_flush_limit_.value();
00178   }
00179   void set_slurp_flush_limit(int64 x) {
00180     set_option(x, &slurp_flush_limit_);
00181   }
00182   bool slurp_read_only() const {
00183     return slurp_read_only_.value();
00184   }
00185   void set_slurp_read_only(bool x) {
00186     set_option(x, &slurp_read_only_);
00187   }
00188   bool rate_limit_background_fetches() const {
00189     return rate_limit_background_fetches_.value();
00190   }
00191   const GoogleString& slurp_directory() const {
00192     return slurp_directory_.value();
00193   }
00194   void set_slurp_directory(GoogleString x) {
00195     set_option(x, &slurp_directory_);
00196   }
00197   bool disable_loopback_routing() const {
00198     return disable_loopback_routing_.value();
00199   }
00200   bool fetch_with_gzip() const {
00201     return fetch_with_gzip_.value();
00202   }
00203   int64 ipro_max_response_bytes() const {
00204     return ipro_max_response_bytes_.value();
00205   }
00206   int64 ipro_max_concurrent_recordings() const {
00207     return ipro_max_concurrent_recordings_.value();
00208   }
00209   int64 default_shared_memory_cache_kb() const {
00210     return default_shared_memory_cache_kb_.value();
00211   }
00212   void set_default_shared_memory_cache_kb(int64 x) {
00213     set_option(x, &default_shared_memory_cache_kb_);
00214   }
00215 
00219   bool test_proxy() const {
00220     return test_proxy_.value();
00221   }
00222   void set_test_proxy(bool x) {
00223     set_option(x, &test_proxy_);
00224   }
00225 
00232   GoogleString test_proxy_slurp() const {
00233     return test_proxy_slurp_.value();
00234   }
00235 
00237   bool slurping_enabled() const {
00238     return !slurp_directory().empty();
00239   }
00240 
00241   bool slurping_enabled_read_only() const {
00242     return slurping_enabled() && slurp_read_only();
00243   }
00244 
00245   virtual SystemRewriteOptions* Clone() const;
00246   virtual SystemRewriteOptions* NewOptions() const;
00247 
00250   static const SystemRewriteOptions* DynamicCast(
00251       const RewriteOptions* instance);
00252   static SystemRewriteOptions* DynamicCast(RewriteOptions* instance);
00253 
00257   StringPiece description() const { return description_; }
00258   void set_description(const StringPiece& x) { x.CopyToString(&description_); }
00259 
00260  protected:
00262   Option<GoogleString> statistics_handler_path_;
00263 
00264  private:
00267   class HttpsOptions : public Option<GoogleString> {
00268    public:
00269     virtual bool SetFromString(StringPiece value_string,
00270                                GoogleString* error_detail);
00271   };
00272 
00275   static Properties* system_properties_;
00276 
00279   template<class OptionClass>
00280   static void AddSystemProperty(typename OptionClass::ValueType default_value,
00281                                 OptionClass SystemRewriteOptions::*offset,
00282                                 const char* id,
00283                                 StringPiece option_name,
00284                                 const char* help) {
00285     AddProperty(default_value, offset, id, option_name, kServerScope, help,
00286                 system_properties_);
00287   }
00288 
00289   template<class OptionClass>
00290   static void AddSystemProperty(typename OptionClass::ValueType default_value,
00291                                 OptionClass SystemRewriteOptions::*offset,
00292                                 const char* id,
00293                                 StringPiece option_name,
00294                                 OptionScope scope,
00295                                 const char* help) {
00296     AddProperty(default_value, offset, id, option_name, scope, help,
00297                 system_properties_);
00298   }
00299 
00300   static void AddProperties();
00301 
00303   GoogleString description_;
00304 
00305   Option<GoogleString> fetcher_proxy_;
00306   Option<GoogleString> file_cache_path_;
00307   Option<GoogleString> log_dir_;
00308 
00311   Option<GoogleString> memcached_servers_;
00312   Option<GoogleString> statistics_logging_charts_css_;
00313   Option<GoogleString> statistics_logging_charts_js_;
00314   Option<GoogleString> cache_flush_filename_;
00315   Option<GoogleString> ssl_cert_directory_;
00316   Option<GoogleString> ssl_cert_file_;
00317   HttpsOptions https_options_;
00318 
00319   Option<GoogleString> slurp_directory_;
00320   Option<GoogleString> test_proxy_slurp_;
00321 
00322   Option<bool> statistics_enabled_;
00323   Option<bool> statistics_logging_enabled_;
00324   Option<bool> use_shared_mem_locking_;
00325   Option<bool> compress_metadata_cache_;
00326 
00327   Option<bool> slurp_read_only_;
00328   Option<bool> test_proxy_;
00329   Option<bool> rate_limit_background_fetches_;
00330 
00333   Option<bool> disable_loopback_routing_;
00334 
00338   Option<bool> fetch_with_gzip_;
00339 
00340   Option<int> memcached_threads_;
00341   Option<int> memcached_timeout_us_;
00342 
00343   Option<int64> file_cache_clean_inode_limit_;
00344   Option<int64> file_cache_clean_interval_ms_;
00345   Option<int64> file_cache_clean_size_kb_;
00346   Option<int64> lru_cache_byte_limit_;
00347   Option<int64> lru_cache_kb_per_process_;
00348   Option<int64> statistics_logging_interval_ms_;
00351   Option<int64> cache_flush_poll_interval_sec_;
00352   Option<int64> statistics_logging_max_file_size_kb_;
00353   Option<int64> slurp_flush_limit_;
00354   Option<int64> ipro_max_response_bytes_;
00355   Option<int64> ipro_max_concurrent_recordings_;
00356   Option<int64> default_shared_memory_cache_kb_;
00357 
00358   DISALLOW_COPY_AND_ASSIGN(SystemRewriteOptions);
00359 };
00360 
00361 }  
00362 
00363 #endif  ///< NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_REWRITE_OPTIONS_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines