| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_RETRIEVAL_PARAMS_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_RETRIEVAL_PARAMS_H_ |
| 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_RETRIEVAL_PARAMS_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_RETRIEVAL_PARAMS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 | 14 |
| 14 class PrefService; | 15 class PrefService; |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class HistogramBase; | 18 class HistogramBase; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace data_reduction_proxy { | 21 namespace data_reduction_proxy { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 public: | 71 public: |
| 71 Variation(int index, const base::Time& simulated_config_retrieved); | 72 Variation(int index, const base::Time& simulated_config_retrieved); |
| 72 | 73 |
| 73 // Returns the current state of the Data Reduction Proxy configuration. | 74 // Returns the current state of the Data Reduction Proxy configuration. |
| 74 // Virtual for testing. | 75 // Virtual for testing. |
| 75 virtual ConfigState GetState(const base::Time& request_time, | 76 virtual ConfigState GetState(const base::Time& request_time, |
| 76 const base::Time& config_expiration) const; | 77 const base::Time& config_expiration) const; |
| 77 | 78 |
| 78 // Records content length statistics if potentially uncompressed bytes have | 79 // Records content length statistics if potentially uncompressed bytes have |
| 79 // been detected for this variation. | 80 // been detected for this variation. |
| 80 void RecordStats(int64 received_content_length, | 81 void RecordStats(int64_t received_content_length, |
| 81 int64 original_content_length) const; | 82 int64_t original_content_length) const; |
| 82 | 83 |
| 83 // Visible for testing. | 84 // Visible for testing. |
| 84 const base::Time& simulated_config_retrieved() const { | 85 const base::Time& simulated_config_retrieved() const { |
| 85 return simulated_config_retrieved_; | 86 return simulated_config_retrieved_; |
| 86 } | 87 } |
| 87 | 88 |
| 88 private: | 89 private: |
| 89 // The time at which the simulated Data Reduction Proxy configuration is | 90 // The time at which the simulated Data Reduction Proxy configuration is |
| 90 // considered to have been received. | 91 // considered to have been received. |
| 91 base::Time simulated_config_retrieved_; | 92 base::Time simulated_config_retrieved_; |
| 92 | 93 |
| 93 // Histograms for recording stats. | 94 // Histograms for recording stats. |
| 94 base::HistogramBase* lost_bytes_ocl_; | 95 base::HistogramBase* lost_bytes_ocl_; |
| 95 base::HistogramBase* lost_bytes_rcl_; | 96 base::HistogramBase* lost_bytes_rcl_; |
| 96 base::HistogramBase* lost_bytes_diff_; | 97 base::HistogramBase* lost_bytes_diff_; |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 static scoped_ptr<DataReductionProxyConfigRetrievalParams> Create( | 100 static scoped_ptr<DataReductionProxyConfigRetrievalParams> Create( |
| 100 PrefService* pref_service); | 101 PrefService* pref_service); |
| 101 | 102 |
| 102 virtual ~DataReductionProxyConfigRetrievalParams(); | 103 virtual ~DataReductionProxyConfigRetrievalParams(); |
| 103 | 104 |
| 104 // Records content length statistics against any variations for which | 105 // Records content length statistics against any variations for which |
| 105 // potentially uncompressed bytes have been detected. | 106 // potentially uncompressed bytes have been detected. |
| 106 void RecordStats(const base::Time& request_time, | 107 void RecordStats(const base::Time& request_time, |
| 107 int64 received_content_length, | 108 int64_t received_content_length, |
| 108 int64 original_content_length) const; | 109 int64_t original_content_length) const; |
| 109 | 110 |
| 110 // Simulates retrieving a new configuration. | 111 // Simulates retrieving a new configuration. |
| 111 void RefreshConfig(); | 112 void RefreshConfig(); |
| 112 | 113 |
| 113 bool loaded_expired_config() const { return loaded_expired_config_; } | 114 bool loaded_expired_config() const { return loaded_expired_config_; } |
| 114 | 115 |
| 115 // Returns the expiration time of the current configuration. | 116 // Returns the expiration time of the current configuration. |
| 116 const base::Time& config_expiration() const { return config_expiration_; } | 117 const base::Time& config_expiration() const { return config_expiration_; } |
| 117 | 118 |
| 118 // Returns how often the configuration should be retrieved. | 119 // Returns how often the configuration should be retrieved. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 145 // The duration after which a simulated retrieval of a new Data Reduction | 146 // The duration after which a simulated retrieval of a new Data Reduction |
| 146 // Proxy configuration should be performed. | 147 // Proxy configuration should be performed. |
| 147 base::TimeDelta config_refresh_interval_; | 148 base::TimeDelta config_refresh_interval_; |
| 148 | 149 |
| 149 // The different variations on roundtrip time that can take place. | 150 // The different variations on roundtrip time that can take place. |
| 150 std::vector<Variation> variations_; | 151 std::vector<Variation> variations_; |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace data_reduction_proxy | 154 } // namespace data_reduction_proxy |
| 154 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CON
FIG_RETRIEVAL_PARAMS_H_ | 155 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CON
FIG_RETRIEVAL_PARAMS_H_ |
| OLD | NEW |