diff options
26 files changed, 210 insertions, 214 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc index fd551e1..caa221f 100644 --- a/android_webview/browser/aw_browser_context.cc +++ b/android_webview/browser/aw_browser_context.cc @@ -19,11 +19,11 @@ #include "base/prefs/pref_service.h" #include "base/prefs/pref_service_factory.h" #include "components/autofill/core/common/autofill_pref_names.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/user_prefs/user_prefs.h" #include "components/visitedlink/browser/visitedlink_master.h" @@ -166,7 +166,8 @@ void AwBrowserContext::PreMainMessageLoopRun() { new data_reduction_proxy::DataReductionProxySettings()); data_reduction_proxy_service_.reset( new data_reduction_proxy::DataReductionProxyService( - scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), + scoped_ptr< + data_reduction_proxy::DataReductionProxyCompressionStats>(), data_reduction_proxy_settings_.get(), GetAwURLRequestContext())); data_reduction_proxy_io_data_->SetDataReductionProxyService( data_reduction_proxy_service_->GetWeakPtr()); @@ -373,7 +374,7 @@ void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { data_reduction_proxy_service = GetDataReductionProxySettings()->data_reduction_proxy_service(); DCHECK(data_reduction_proxy_service); - if (data_reduction_proxy_service->statistics_prefs()) + if (data_reduction_proxy_service->compression_stats()) return; // We don't care about commit_delay for now. It is just a dummy value. base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc index fb52580..a0fe851 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc @@ -16,11 +16,11 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/pref_names.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "net/url_request/url_request_context_getter.h" @@ -91,14 +91,13 @@ void DataReductionProxyChromeSettings::InitDataReductionProxySettings( base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); #endif - scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> - statistics_prefs = make_scoped_ptr( - new data_reduction_proxy::DataReductionProxyStatisticsPrefs( + scoped_ptr<data_reduction_proxy::DataReductionProxyCompressionStats> + compression_stats = make_scoped_ptr( + new data_reduction_proxy::DataReductionProxyCompressionStats( profile_prefs, ui_task_runner, commit_delay)); - scoped_ptr<data_reduction_proxy::DataReductionProxyService> - service = make_scoped_ptr( - new data_reduction_proxy::DataReductionProxyService( - statistics_prefs.Pass(), this, request_context_getter)); + scoped_ptr<data_reduction_proxy::DataReductionProxyService> service = + make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService( + compression_stats.Pass(), this, request_context_getter)); data_reduction_proxy::DataReductionProxySettings:: InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); io_data->SetDataReductionProxyService( diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc index e99e25b..28162a8 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc @@ -45,9 +45,9 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/url_constants.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h" #include "components/onc/onc_constants.h" #include "components/url_fixer/url_fixer.h" @@ -622,10 +622,12 @@ void NetInternalsMessageHandler::OnGetHistoricNetworkStats( DataReductionProxyChromeSettings* data_reduction_proxy_settings = DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile); if (data_reduction_proxy_settings) { - data_reduction_proxy::DataReductionProxyStatisticsPrefs* statistics_prefs = - data_reduction_proxy_settings->data_reduction_proxy_service()-> - statistics_prefs(); - historic_network_info = statistics_prefs->HistoricNetworkStatsInfoToValue(); + data_reduction_proxy::DataReductionProxyCompressionStats* + compression_stats = + data_reduction_proxy_settings->data_reduction_proxy_service() + ->compression_stats(); + historic_network_info = + compression_stats->HistoricNetworkStatsInfoToValue(); } SendJavascriptCommand("receivedHistoricNetworkStats", historic_network_info); } diff --git a/components/components_tests.gyp b/components/components_tests.gyp index aa307e3..32f270b 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -107,6 +107,7 @@ 'data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc', + 'data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_configurator_unittest.cc', @@ -117,7 +118,6 @@ 'data_reduction_proxy/core/browser/data_reduction_proxy_prefs_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc', - 'data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_tamper_detection_unittest.cc', 'data_reduction_proxy/core/common/data_reduction_proxy_client_config_parser_unittest.cc', 'data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc', diff --git a/components/data_reduction_proxy.gypi b/components/data_reduction_proxy.gypi index b44250e8..a6485e8 100644 --- a/components/data_reduction_proxy.gypi +++ b/components/data_reduction_proxy.gypi @@ -96,6 +96,8 @@ 'data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.h', 'data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h', + 'data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc', + 'data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h', 'data_reduction_proxy/core/browser/data_reduction_proxy_config.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_config.h', 'data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc', @@ -122,8 +124,6 @@ 'data_reduction_proxy/core/browser/data_reduction_proxy_service.h', 'data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_settings.h', - 'data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc', - 'data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h', 'data_reduction_proxy/core/browser/data_reduction_proxy_tamper_detection.cc', 'data_reduction_proxy/core/browser/data_reduction_proxy_tamper_detection.h', ], diff --git a/components/data_reduction_proxy/core/browser/BUILD.gn b/components/data_reduction_proxy/core/browser/BUILD.gn index 3808026..5330d25 100644 --- a/components/data_reduction_proxy/core/browser/BUILD.gn +++ b/components/data_reduction_proxy/core/browser/BUILD.gn @@ -8,6 +8,8 @@ static_library("browser") { "data_reduction_proxy_bypass_protocol.h", "data_reduction_proxy_bypass_stats.cc", "data_reduction_proxy_bypass_stats.h", + "data_reduction_proxy_compression_stats.cc", + "data_reduction_proxy_compression_stats.h", "data_reduction_proxy_config.cc", "data_reduction_proxy_config.h", "data_reduction_proxy_config_service_client.cc", @@ -35,8 +37,6 @@ static_library("browser") { "data_reduction_proxy_service.h", "data_reduction_proxy_settings.cc", "data_reduction_proxy_settings.h", - "data_reduction_proxy_statistics_prefs.cc", - "data_reduction_proxy_statistics_prefs.h", "data_reduction_proxy_tamper_detection.cc", "data_reduction_proxy_tamper_detection.h", ] diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc index 281cd96..0652786 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "base/bind.h" #include "base/command_line.h" @@ -19,7 +19,7 @@ namespace data_reduction_proxy { -DataReductionProxyStatisticsPrefs::DataReductionProxyStatisticsPrefs( +DataReductionProxyCompressionStats::DataReductionProxyCompressionStats( PrefService* prefs, scoped_refptr<base::SequencedTaskRunner> task_runner, const base::TimeDelta& delay) @@ -34,14 +34,14 @@ DataReductionProxyStatisticsPrefs::DataReductionProxyStatisticsPrefs( Init(); } -DataReductionProxyStatisticsPrefs::~DataReductionProxyStatisticsPrefs() { +DataReductionProxyCompressionStats::~DataReductionProxyCompressionStats() { DCHECK(thread_checker_.CalledOnValidThread()); WritePrefs(); pref_change_registrar_->RemoveAll(); weak_factory_.InvalidateWeakPtrs(); } -void DataReductionProxyStatisticsPrefs::Init() { +void DataReductionProxyCompressionStats::Init() { DCHECK(thread_checker_.CalledOnValidThread()); if (delay_ == base::TimeDelta()) return; @@ -73,17 +73,18 @@ void DataReductionProxyStatisticsPrefs::Init() { kDailyOriginalContentLengthWithDataReductionProxyEnabled); if (base::CommandLine::ForCurrentProcess()->HasSwitch( - data_reduction_proxy::switches::kClearDataReductionProxyDataSavings)) { + data_reduction_proxy::switches:: + kClearDataReductionProxyDataSavings)) { ClearDataSavingStatistics(); } pref_change_registrar_->Init(pref_service_); pref_change_registrar_->Add(prefs::kUpdateDailyReceivedContentLengths, - base::Bind(&DataReductionProxyStatisticsPrefs::OnUpdateContentLengths, + base::Bind(&DataReductionProxyCompressionStats::OnUpdateContentLengths, GetWeakPtr())); } -void DataReductionProxyStatisticsPrefs::OnUpdateContentLengths() { +void DataReductionProxyCompressionStats::OnUpdateContentLengths() { DCHECK(thread_checker_.CalledOnValidThread()); if (!pref_service_->GetBoolean(prefs::kUpdateDailyReceivedContentLengths)) return; @@ -92,18 +93,18 @@ void DataReductionProxyStatisticsPrefs::OnUpdateContentLengths() { pref_service_->SetBoolean(prefs::kUpdateDailyReceivedContentLengths, false); } -void DataReductionProxyStatisticsPrefs::InitInt64Pref(const char* pref) { +void DataReductionProxyCompressionStats::InitInt64Pref(const char* pref) { int64 pref_value = pref_service_->GetInt64(pref); pref_map_[pref] = pref_value; } -void DataReductionProxyStatisticsPrefs::InitListPref(const char* pref) { +void DataReductionProxyCompressionStats::InitListPref(const char* pref) { scoped_ptr<base::ListValue> pref_value = scoped_ptr<base::ListValue>( pref_service_->GetList(pref)->DeepCopy()); list_pref_map_.add(pref, pref_value.Pass()); } -int64 DataReductionProxyStatisticsPrefs::GetInt64(const char* pref_path) { +int64 DataReductionProxyCompressionStats::GetInt64(const char* pref_path) { if (delay_ == base::TimeDelta()) return pref_service_->GetInt64(pref_path); @@ -111,8 +112,8 @@ int64 DataReductionProxyStatisticsPrefs::GetInt64(const char* pref_path) { return iter->second; } -void DataReductionProxyStatisticsPrefs::SetInt64(const char* pref_path, - int64 pref_value) { +void DataReductionProxyCompressionStats::SetInt64(const char* pref_path, + int64 pref_value) { if (delay_ == base::TimeDelta()) { pref_service_->SetInt64(pref_path, pref_value); return; @@ -122,7 +123,7 @@ void DataReductionProxyStatisticsPrefs::SetInt64(const char* pref_path, pref_map_[pref_path] = pref_value; } -base::ListValue* DataReductionProxyStatisticsPrefs::GetList( +base::ListValue* DataReductionProxyCompressionStats::GetList( const char* pref_path) { if (delay_ == base::TimeDelta()) return ListPrefUpdate(pref_service_, pref_path).Get(); @@ -131,10 +132,10 @@ base::ListValue* DataReductionProxyStatisticsPrefs::GetList( return list_pref_map_.get(pref_path); } -void DataReductionProxyStatisticsPrefs::WritePrefs() { +void DataReductionProxyCompressionStats::WritePrefs() { DCHECK(thread_checker_.CalledOnValidThread()); if (delay_ == base::TimeDelta()) - return; + return; for (DataReductionProxyPrefMap::iterator iter = pref_map_.begin(); iter != pref_map_.end(); ++iter) { @@ -151,7 +152,7 @@ void DataReductionProxyStatisticsPrefs::WritePrefs() { } base::Value* -DataReductionProxyStatisticsPrefs::HistoricNetworkStatsInfoToValue() { +DataReductionProxyCompressionStats::HistoricNetworkStatsInfoToValue() { DCHECK(thread_checker_.CalledOnValidThread()); int64 total_received = GetInt64( data_reduction_proxy::prefs::kHttpReceivedContentLength); @@ -167,21 +168,20 @@ DataReductionProxyStatisticsPrefs::HistoricNetworkStatsInfoToValue() { return dict; } -void DataReductionProxyStatisticsPrefs::DelayedWritePrefs() { +void DataReductionProxyCompressionStats::DelayedWritePrefs() { // Only write after the first time posting the task. if (delayed_task_posted_) return; task_runner_->PostDelayedTask( FROM_HERE, - base::Bind(&DataReductionProxyStatisticsPrefs::WritePrefs, - GetWeakPtr()), - delay_); + base::Bind(&DataReductionProxyCompressionStats::WritePrefs, GetWeakPtr()), + delay_); delayed_task_posted_ = true; } -void DataReductionProxyStatisticsPrefs::TransferList( +void DataReductionProxyCompressionStats::TransferList( const base::ListValue& from_list, base::ListValue* to_list) { to_list->Clear(); @@ -191,7 +191,7 @@ void DataReductionProxyStatisticsPrefs::TransferList( } } -int64 DataReductionProxyStatisticsPrefs::GetListPrefInt64Value( +int64 DataReductionProxyCompressionStats::GetListPrefInt64Value( const base::ListValue& list, size_t index) { std::string string_value; @@ -206,7 +206,7 @@ int64 DataReductionProxyStatisticsPrefs::GetListPrefInt64Value( return value; } -void DataReductionProxyStatisticsPrefs::ClearDataSavingStatistics() { +void DataReductionProxyCompressionStats::ClearDataSavingStatistics() { list_pref_map_.get(data_reduction_proxy::prefs:: kDailyContentLengthHttpsWithDataReductionProxyEnabled)->Clear(); list_pref_map_.get(data_reduction_proxy::prefs:: @@ -232,8 +232,8 @@ void DataReductionProxyStatisticsPrefs::ClearDataSavingStatistics() { WritePrefs(); } -base::WeakPtr<DataReductionProxyStatisticsPrefs> -DataReductionProxyStatisticsPrefs::GetWeakPtr() { +base::WeakPtr<DataReductionProxyCompressionStats> +DataReductionProxyCompressionStats::GetWeakPtr() { return weak_factory_.GetWeakPtr(); } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h index 2da0361..286b3bf 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STATISTICS_PREFS_H_ -#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STATISTICS_PREFS_H_ +#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRESSION_STATS_H_ +#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRESSION_STATS_H_ #include <map> @@ -31,19 +31,18 @@ namespace data_reduction_proxy { // |delay| amount of time. If |delay| is zero, the delayed pref service writes // directly to the PrefService and does not store the prefs in memory. All // prefs must be stored and read on the UI thread. -// TODO(bengr): Rename as DataReductionProxyCompressionStats. -class DataReductionProxyStatisticsPrefs { -public: +class DataReductionProxyCompressionStats { + public: // Constructs a data reduction proxy delayed pref service object using // |pref_service|. Writes prefs to |pref_service| after |delay| // and stores them in |pref_map_| and |list_pref_map| between writes. // If |delay| is zero, writes directly to the PrefService and does not store // in the maps. - DataReductionProxyStatisticsPrefs( + DataReductionProxyCompressionStats( PrefService* pref_service, scoped_refptr<base::SequencedTaskRunner> task_runner, const base::TimeDelta& delay); - ~DataReductionProxyStatisticsPrefs(); + ~DataReductionProxyCompressionStats(); // Loads all data_reduction_proxy::prefs into the |pref_map_| and // |list_pref_map_|. @@ -70,9 +69,9 @@ public: // Must be called on the UI thread. base::Value* HistoricNetworkStatsInfoToValue(); - base::WeakPtr<DataReductionProxyStatisticsPrefs> GetWeakPtr(); + base::WeakPtr<DataReductionProxyCompressionStats> GetWeakPtr(); -private: + private: typedef std::map<const char*, int64> DataReductionProxyPrefMap; typedef base::ScopedPtrHashMap<const char*, base::ListValue> DataReductionProxyListPrefMap; @@ -110,11 +109,11 @@ private: scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; base::ThreadChecker thread_checker_; - base::WeakPtrFactory<DataReductionProxyStatisticsPrefs> weak_factory_; + base::WeakPtrFactory<DataReductionProxyCompressionStats> weak_factory_; - DISALLOW_COPY_AND_ASSIGN(DataReductionProxyStatisticsPrefs); + DISALLOW_COPY_AND_ASSIGN(DataReductionProxyCompressionStats); }; } // namespace data_reduction_proxy -#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STATISTICS_PREFS_H_ +#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRESSION_STATS_H_ diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc index 004e96b5..6bdaba8 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc @@ -10,8 +10,8 @@ #include "base/test/test_simple_task_runner.h" #include "base/time/time.h" #include "base/values.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "testing/gtest/include/gtest/gtest.h" @@ -36,9 +36,9 @@ int64 GetListPrefInt64Value( namespace data_reduction_proxy { -class DataReductionProxyStatisticsPrefsTest : public testing::Test { +class DataReductionProxyCompressionStatsTest : public testing::Test { protected: - DataReductionProxyStatisticsPrefsTest() + DataReductionProxyCompressionStatsTest() : task_runner_(scoped_refptr<base::TestSimpleTaskRunner>( new base::TestSimpleTaskRunner())) {} @@ -51,15 +51,15 @@ class DataReductionProxyStatisticsPrefsTest : public testing::Test { const int64 kOriginalLength = 150; const int64 kReceivedLength = 100; - statistics_prefs_->SetInt64( + compression_stats_->SetInt64( prefs::kHttpOriginalContentLength, kOriginalLength); - statistics_prefs_->SetInt64( + compression_stats_->SetInt64( prefs::kHttpReceivedContentLength, kReceivedLength); base::ListValue* original_daily_content_length_list = - statistics_prefs_->GetList(prefs::kDailyHttpOriginalContentLength); + compression_stats_->GetList(prefs::kDailyHttpOriginalContentLength); base::ListValue* received_daily_content_length_list = - statistics_prefs_->GetList(prefs::kDailyHttpReceivedContentLength); + compression_stats_->GetList(prefs::kDailyHttpReceivedContentLength); for (size_t i = 0; i < kNumDaysInHistory; ++i) { original_daily_content_length_list->Set( @@ -67,7 +67,7 @@ class DataReductionProxyStatisticsPrefsTest : public testing::Test { } received_daily_content_length_list->Clear(); - for (size_t i = 0; i < kNumDaysInHistory/2; ++i) { + for (size_t i = 0; i < kNumDaysInHistory / 2; ++i) { received_daily_content_length_list->Set( i, new base::StringValue(base::Int64ToString(i))); } @@ -75,7 +75,7 @@ class DataReductionProxyStatisticsPrefsTest : public testing::Test { // Create daily pref list of |kNumDaysInHistory| zero values. void CreatePrefList(const char* pref) { - base::ListValue* update = statistics_prefs_->GetList(pref); + base::ListValue* update = compression_stats_->GetList(pref); update->Clear(); for (size_t i = 0; i < kNumDaysInHistory; ++i) { update->Insert(0, new base::StringValue(base::Int64ToString(0))); @@ -85,7 +85,7 @@ class DataReductionProxyStatisticsPrefsTest : public testing::Test { // Verify the pref list values in |pref_service_| are equal to those in // |simple_pref_service| for |pref|. void VerifyPrefListWasWritten(const char* pref) { - const base::ListValue* delayed_list = statistics_prefs_->GetList(pref); + const base::ListValue* delayed_list = compression_stats_->GetList(pref); const base::ListValue* written_list = simple_pref_service_.GetList(pref); ASSERT_EQ(delayed_list->GetSize(), written_list->GetSize()); size_t count = delayed_list->GetSize(); @@ -99,12 +99,12 @@ class DataReductionProxyStatisticsPrefsTest : public testing::Test { // Verify the pref value in |pref_service_| are equal to that in // |simple_pref_service|. void VerifyPrefWasWritten(const char* pref) { - int64 delayed_pref = statistics_prefs_->GetInt64(pref); + int64 delayed_pref = compression_stats_->GetInt64(pref); int64 written_pref = simple_pref_service_.GetInt64(pref); EXPECT_EQ(delayed_pref, written_pref); } - // Verify the pref values in |dict| are equal to that in |statistics_prefs_|. + // Verify the pref values in |dict| are equal to that in |compression_stats_|. void VerifyPrefs(base::DictionaryValue* dict) { base::string16 dict_pref_string; int64 dict_pref; @@ -112,24 +112,24 @@ class DataReductionProxyStatisticsPrefsTest : public testing::Test { dict->GetString("historic_original_content_length", &dict_pref_string); base::StringToInt64(dict_pref_string, &dict_pref); - service_pref = statistics_prefs_->GetInt64( - prefs::kHttpOriginalContentLength); + service_pref = + compression_stats_->GetInt64(prefs::kHttpOriginalContentLength); EXPECT_EQ(service_pref, dict_pref); dict->GetString("historic_received_content_length", &dict_pref_string); base::StringToInt64(dict_pref_string, &dict_pref); - service_pref = statistics_prefs_->GetInt64( - prefs::kHttpReceivedContentLength); + service_pref = + compression_stats_->GetInt64(prefs::kHttpReceivedContentLength); EXPECT_EQ(service_pref, dict_pref); } scoped_refptr<base::TestSimpleTaskRunner> task_runner_; TestingPrefServiceSimple simple_pref_service_; - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; + scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; }; -TEST_F(DataReductionProxyStatisticsPrefsTest, WritePrefsDirect) { - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( +TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDirect) { + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta())); @@ -141,8 +141,8 @@ TEST_F(DataReductionProxyStatisticsPrefsTest, WritePrefsDirect) { VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); } -TEST_F(DataReductionProxyStatisticsPrefsTest, WritePrefsDelayed) { - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( +TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDelayed) { + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta::FromMinutes(kWriteDelayMinutes))); @@ -156,9 +156,9 @@ TEST_F(DataReductionProxyStatisticsPrefsTest, WritePrefsDelayed) { VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); } -TEST_F(DataReductionProxyStatisticsPrefsTest, +TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsOnUpdateDailyReceivedContentLengths) { - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta::FromMinutes(kWriteDelayMinutes))); @@ -173,57 +173,57 @@ TEST_F(DataReductionProxyStatisticsPrefsTest, VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); } -TEST_F(DataReductionProxyStatisticsPrefsTest, +TEST_F(DataReductionProxyCompressionStatsTest, HistoricNetworkStatsInfoToValue) { const int64 kOriginalLength = 150; const int64 kReceivedLength = 100; - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta::FromMinutes(kWriteDelayMinutes))); base::DictionaryValue* dict = nullptr; scoped_ptr<base::Value> stats_value( - statistics_prefs_->HistoricNetworkStatsInfoToValue()); + compression_stats_->HistoricNetworkStatsInfoToValue()); EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); VerifyPrefs(dict); - statistics_prefs_->SetInt64(prefs::kHttpOriginalContentLength, - kOriginalLength); - statistics_prefs_->SetInt64(prefs::kHttpReceivedContentLength, - kReceivedLength); + compression_stats_->SetInt64(prefs::kHttpOriginalContentLength, + kOriginalLength); + compression_stats_->SetInt64(prefs::kHttpReceivedContentLength, + kReceivedLength); - stats_value.reset(statistics_prefs_->HistoricNetworkStatsInfoToValue()); + stats_value.reset(compression_stats_->HistoricNetworkStatsInfoToValue()); EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); VerifyPrefs(dict); } -TEST_F(DataReductionProxyStatisticsPrefsTest, +TEST_F(DataReductionProxyCompressionStatsTest, HistoricNetworkStatsInfoToValueDirect) { const int64 kOriginalLength = 150; const int64 kReceivedLength = 100; - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta())); base::DictionaryValue* dict = nullptr; scoped_ptr<base::Value> stats_value( - statistics_prefs_->HistoricNetworkStatsInfoToValue()); + compression_stats_->HistoricNetworkStatsInfoToValue()); EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); VerifyPrefs(dict); - statistics_prefs_->SetInt64(prefs::kHttpOriginalContentLength, - kOriginalLength); - statistics_prefs_->SetInt64(prefs::kHttpReceivedContentLength, - kReceivedLength); + compression_stats_->SetInt64(prefs::kHttpOriginalContentLength, + kOriginalLength); + compression_stats_->SetInt64(prefs::kHttpReceivedContentLength, + kReceivedLength); - stats_value.reset(statistics_prefs_->HistoricNetworkStatsInfoToValue()); + stats_value.reset(compression_stats_->HistoricNetworkStatsInfoToValue()); EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); VerifyPrefs(dict); } -TEST_F(DataReductionProxyStatisticsPrefsTest, +TEST_F(DataReductionProxyCompressionStatsTest, ClearPrefsOnRestartEnabled) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); command_line->AppendSwitch( @@ -233,7 +233,7 @@ TEST_F(DataReductionProxyStatisticsPrefsTest, list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value); - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta::FromMinutes(kWriteDelayMinutes))); @@ -243,13 +243,13 @@ TEST_F(DataReductionProxyStatisticsPrefsTest, EXPECT_EQ(0u, value->GetSize()); } -TEST_F(DataReductionProxyStatisticsPrefsTest, +TEST_F(DataReductionProxyCompressionStatsTest, ClearPrefsOnRestartDisabled) { base::ListValue list_value; list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value); - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + compression_stats_.reset(new DataReductionProxyCompressionStats( &simple_pref_service_, task_runner_, base::TimeDelta::FromMinutes(kWriteDelayMinutes))); diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc index 3e38f32..accd013 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc @@ -10,6 +10,7 @@ #include "base/single_thread_task_runner.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" @@ -19,7 +20,6 @@ #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h index 6e2e199..80eab78 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h @@ -25,7 +25,6 @@ class DataReductionProxyConfigServiceClient; class DataReductionProxyConfigurator; class DataReductionProxyEventStore; class DataReductionProxyService; -class DataReductionProxyStatisticsPrefs; class DataReductionProxyBypassStats; // Contains and initializes all Data Reduction Proxy objects that operate on diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.cc index 728188d..0408a7b 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.cc @@ -8,9 +8,9 @@ #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "net/base/host_port_pair.h" @@ -197,9 +197,8 @@ void MaintainContentLengthPrefsWindow(base::ListValue* list, size_t length) { class DailyContentLengthUpdate { public: DailyContentLengthUpdate(const char* pref, - DataReductionProxyStatisticsPrefs* pref_service) - : update_(pref_service->GetList(pref)) { - } + DataReductionProxyCompressionStats* pref_service) + : update_(pref_service->GetList(pref)) {} void UpdateForDataChange(int days_since_last_update) { // New empty lists may have been created. Maintain the invariant that @@ -266,10 +265,9 @@ class DailyDataSavingUpdate { public: DailyDataSavingUpdate(const char* pref_original, const char* pref_received, - DataReductionProxyStatisticsPrefs* prefs) - : original_(pref_original, prefs), - received_(pref_received, prefs) { - } + DataReductionProxyCompressionStats* compression_stats) + : original_(pref_original, compression_stats), + received_(pref_received, compression_stats) {} void UpdateForDataChange(int days_since_last_update) { original_.UpdateForDataChange(days_since_last_update); @@ -358,7 +356,7 @@ void UpdateContentLengthPrefsForDataReductionProxy( bool with_data_reduction_proxy_enabled, DataReductionProxyRequestType request_type, base::Time now, - DataReductionProxyStatisticsPrefs* prefs) { + DataReductionProxyCompressionStats* compression_stats) { // TODO(bengr): Remove this check once the underlying cause of // http://crbug.com/287821 is fixed. For now, only continue if the current // year is reported as being between 1972 and 2970. @@ -371,7 +369,7 @@ void UpdateContentLengthPrefsForDataReductionProxy( } // Determine how many days it has been since the last update. - int64 then_internal = prefs->GetInt64( + int64 then_internal = compression_stats->GetInt64( data_reduction_proxy::prefs::kDailyHttpContentLengthLastUpdateDate); // Local midnight could have been shifted due to time zone change. @@ -393,7 +391,7 @@ void UpdateContentLengthPrefsForDataReductionProxy( DailyDataSavingUpdate total( data_reduction_proxy::prefs::kDailyHttpOriginalContentLength, data_reduction_proxy::prefs::kDailyHttpReceivedContentLength, - prefs); + compression_stats); total.UpdateForDataChange(days_since_last_update); DailyDataSavingUpdate proxy_enabled( @@ -401,7 +399,7 @@ void UpdateContentLengthPrefsForDataReductionProxy( kDailyOriginalContentLengthWithDataReductionProxyEnabled, data_reduction_proxy::prefs:: kDailyContentLengthWithDataReductionProxyEnabled, - prefs); + compression_stats); proxy_enabled.UpdateForDataChange(days_since_last_update); DailyDataSavingUpdate via_proxy( @@ -409,31 +407,31 @@ void UpdateContentLengthPrefsForDataReductionProxy( kDailyOriginalContentLengthViaDataReductionProxy, data_reduction_proxy::prefs:: kDailyContentLengthViaDataReductionProxy, - prefs); + compression_stats); via_proxy.UpdateForDataChange(days_since_last_update); DailyContentLengthUpdate https( data_reduction_proxy::prefs:: kDailyContentLengthHttpsWithDataReductionProxyEnabled, - prefs); + compression_stats); https.UpdateForDataChange(days_since_last_update); DailyContentLengthUpdate short_bypass( data_reduction_proxy::prefs:: kDailyContentLengthShortBypassWithDataReductionProxyEnabled, - prefs); + compression_stats); short_bypass.UpdateForDataChange(days_since_last_update); DailyContentLengthUpdate long_bypass( data_reduction_proxy::prefs:: kDailyContentLengthLongBypassWithDataReductionProxyEnabled, - prefs); + compression_stats); long_bypass.UpdateForDataChange(days_since_last_update); DailyContentLengthUpdate unknown( data_reduction_proxy::prefs:: kDailyContentLengthUnknownWithDataReductionProxyEnabled, - prefs); + compression_stats); unknown.UpdateForDataChange(days_since_last_update); total.Add(original_content_length, received_content_length); @@ -462,7 +460,7 @@ void UpdateContentLengthPrefsForDataReductionProxy( if (days_since_last_update) { // Record the last update time in microseconds in UTC. - prefs->SetInt64( + compression_stats->SetInt64( data_reduction_proxy::prefs::kDailyHttpContentLengthLastUpdateDate, midnight.ToInternalValue()); diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h index 60b38f6..22d47ed 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h @@ -17,7 +17,7 @@ class PrefService; namespace data_reduction_proxy { class DataReductionProxyConfig; -class DataReductionProxyStatisticsPrefs; +class DataReductionProxyCompressionStats; enum DataReductionProxyRequestType { VIA_DATA_REDUCTION_PROXY, // A request served by the data reduction proxy. @@ -53,7 +53,7 @@ void UpdateContentLengthPrefsForDataReductionProxy( bool with_data_reduction_proxy_enabled, DataReductionProxyRequestType request_type, base::Time now, - DataReductionProxyStatisticsPrefs* prefs); + DataReductionProxyCompressionStats* compression_stats); } // namespace data_reduction_proxy diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc index 1abf5c2..4d372e8 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc @@ -14,8 +14,8 @@ #include "base/strings/string_number_conversions.h" #include "base/test/test_simple_task_runner.h" #include "base/time/time.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" @@ -52,7 +52,7 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test { ChromeNetworkDataSavingMetricsTest() {} void SetUp() override { - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + compression_stats_.reset(new DataReductionProxyCompressionStats( &pref_service_, scoped_refptr<base::TestSimpleTaskRunner>( new base::TestSimpleTaskRunner()), @@ -99,7 +99,7 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test { } TestingPrefServiceSimple pref_service_; - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; + scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; }; // The initial last update time used in test. There is no leap second a few @@ -139,7 +139,7 @@ class ChromeNetworkDailyDataSavingMetricsTest // Create daily pref list of |kNumDaysInHistory| zero values. void CreatePrefList(const char* pref) { - base::ListValue* update = statistics_prefs_->GetList(pref); + base::ListValue* update = compression_stats_->GetList(pref); update->Clear(); for (size_t i = 0; i < kNumDaysInHistory; ++i) { update->Insert(0, new base::StringValue(base::Int64ToString(0))); @@ -151,7 +151,7 @@ class ChromeNetworkDailyDataSavingMetricsTest // at the beginning. void VerifyPrefList(const char* pref, const int64* values, size_t count) { ASSERT_GE(kNumDaysInHistory, count); - base::ListValue* update = statistics_prefs_->GetList(pref); + base::ListValue* update = compression_stats_->GetList(pref); ASSERT_EQ(kNumDaysInHistory, update->GetSize()) << "Pref: " << pref; for (size_t i = 0; i < count; ++i) { @@ -269,7 +269,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, OneResponse) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); VerifyDailyDataSavingContentLengthPrefLists( original, 1, received, 1, original, 1, received, 1, @@ -284,7 +284,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, false, UNKNOWN_TYPE, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); VerifyDailyDataSavingContentLengthPrefLists( original, 1, received, 1, NULL, 0, NULL, 0, NULL, 0, NULL, 0); @@ -292,7 +292,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, UNKNOWN_TYPE, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); original[0] += kOriginalLength; received[0] += kReceivedLength; int64 original_proxy_enabled[] = {kOriginalLength}; @@ -305,7 +305,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); original[0] += kOriginalLength; received[0] += kReceivedLength; original_proxy_enabled[0] += kOriginalLength; @@ -319,7 +319,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, - true, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); + true, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); original[0] += kOriginalLength; received[0] += kReceivedLength; original_proxy_enabled[0] += kOriginalLength; @@ -331,7 +331,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, - false, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); + false, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); original[0] += kOriginalLength; received[0] += kReceivedLength; VerifyDailyDataSavingContentLengthPrefLists( @@ -350,7 +350,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { UpdateContentLengthPrefsForDataReductionProxy( kContentLength, kContentLength, true, HTTPS, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); total_received[0] += kContentLength; proxy_enabled_received[0] += kContentLength; https_received[0] += kContentLength; @@ -366,7 +366,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { UpdateContentLengthPrefsForDataReductionProxy( kContentLength, kContentLength, false, HTTPS, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); total_received[0] += kContentLength; VerifyDailyRequestTypeContentLengthPrefLists( total_received, 1, total_received, 1, @@ -379,7 +379,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { UpdateContentLengthPrefsForDataReductionProxy( kContentLength, kContentLength, true, HTTPS, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); total_received[0] += kContentLength; proxy_enabled_received[0] += kContentLength; https_received[0] += kContentLength; @@ -394,7 +394,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { UpdateContentLengthPrefsForDataReductionProxy( kContentLength, kContentLength, true, SHORT_BYPASS, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); total_received[0] += kContentLength; proxy_enabled_received[0] += kContentLength; received[0] += kContentLength; @@ -409,7 +409,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { UpdateContentLengthPrefsForDataReductionProxy( kContentLength, kContentLength, true, LONG_BYPASS, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); total_received[0] += kContentLength; proxy_enabled_received[0] += kContentLength; VerifyDailyRequestTypeContentLengthPrefLists( @@ -423,7 +423,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { UpdateContentLengthPrefsForDataReductionProxy( kContentLength, kContentLength, true, UNKNOWN_TYPE, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); total_received[0] += kContentLength; proxy_enabled_received[0] += kContentLength; VerifyDailyRequestTypeContentLengthPrefLists( @@ -442,7 +442,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); // Forward one day. SetFakeTimeDeltaInHours(24); @@ -450,7 +450,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { // Proxy not enabled. Not via proxy. UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, - false, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); + false, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); int64 original[] = {kOriginalLength, kOriginalLength}; int64 received[] = {kReceivedLength, kReceivedLength}; @@ -469,7 +469,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { // Proxy enabled. Not via proxy. UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, - true, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); + true, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); original[1] += kOriginalLength; received[1] += kReceivedLength; original_with_data_reduction_proxy_enabled[1] += kOriginalLength; @@ -486,7 +486,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); original[1] += kOriginalLength; received[1] += kReceivedLength; original_with_data_reduction_proxy_enabled[1] += kOriginalLength; @@ -511,7 +511,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); VerifyDailyDataSavingContentLengthPrefLists( original, 2, received, 2, original, 2, received, 2, @@ -523,7 +523,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); original[1] += kOriginalLength; received[1] += kReceivedLength; VerifyDailyDataSavingContentLengthPrefLists( @@ -536,7 +536,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); int64 original2[] = {kOriginalLength * 2, kOriginalLength}; int64 received2[] = {kReceivedLength * 2, kReceivedLength}; VerifyDailyDataSavingContentLengthPrefLists( @@ -551,7 +551,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); // Forward three days. SetFakeTimeDeltaInHours(3 * 24); @@ -559,7 +559,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); int64 original[] = {kOriginalLength, 0, 0, kOriginalLength}; int64 received[] = {kReceivedLength, 0, 0, kReceivedLength}; @@ -573,7 +573,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); int64 original2[] = { kOriginalLength, 0, 0, kOriginalLength, 0, 0, 0, kOriginalLength, }; @@ -590,7 +590,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); int64 original3[] = {kOriginalLength}; int64 received3[] = {kReceivedLength}; VerifyDailyDataSavingContentLengthPrefLists( @@ -603,7 +603,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); VerifyDailyDataSavingContentLengthPrefLists( original3, 1, received3, 1, original3, 1, received3, 1, @@ -619,14 +619,14 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); // Backward one day. SetFakeTimeDeltaInHours(-24); UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); original[0] += kOriginalLength; received[0] += kReceivedLength; VerifyDailyDataSavingContentLengthPrefLists( @@ -639,7 +639,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); int64 original2[] = {kOriginalLength * 2, kOriginalLength}; int64 received2[] = {kReceivedLength * 2, kReceivedLength}; VerifyDailyDataSavingContentLengthPrefLists( @@ -657,13 +657,13 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardTwoDays) { UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); // Backward two days. SetFakeTimeDeltaInHours(-2 * 24); UpdateContentLengthPrefsForDataReductionProxy( kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, - FakeNow(), statistics_prefs_.get()); + FakeNow(), compression_stats_.get()); VerifyDailyDataSavingContentLengthPrefLists( original, 1, received, 1, original, 1, received, 1, diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc index fd49cdb..fbe71f6 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc @@ -12,12 +12,12 @@ #include "base/strings/string_number_conversions.h" #include "base/time/time.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "net/base/load_flags.h" #include "net/http/http_response_headers.h" @@ -238,18 +238,18 @@ void DataReductionProxyNetworkDelegate::UpdateContentLengthPrefs( DataReductionProxyRequestType request_type) { if (data_reduction_proxy_io_data_ && data_reduction_proxy_io_data_->service()) { - DataReductionProxyStatisticsPrefs* data_reduction_proxy_statistics_prefs = - data_reduction_proxy_io_data_->service()->statistics_prefs(); - int64 total_received = data_reduction_proxy_statistics_prefs->GetInt64( + DataReductionProxyCompressionStats* data_reduction_proxy_compression_stats = + data_reduction_proxy_io_data_->service()->compression_stats(); + int64 total_received = data_reduction_proxy_compression_stats->GetInt64( data_reduction_proxy::prefs::kHttpReceivedContentLength); - int64 total_original = data_reduction_proxy_statistics_prefs->GetInt64( + int64 total_original = data_reduction_proxy_compression_stats->GetInt64( data_reduction_proxy::prefs::kHttpOriginalContentLength); total_received += received_content_length; total_original += original_content_length; - data_reduction_proxy_statistics_prefs->SetInt64( + data_reduction_proxy_compression_stats->SetInt64( data_reduction_proxy::prefs::kHttpReceivedContentLength, total_received); - data_reduction_proxy_statistics_prefs->SetInt64( + data_reduction_proxy_compression_stats->SetInt64( data_reduction_proxy::prefs::kHttpOriginalContentLength, total_original); @@ -259,7 +259,7 @@ void DataReductionProxyNetworkDelegate::UpdateContentLengthPrefs( data_reduction_proxy_enabled, request_type, base::Time::Now(), - data_reduction_proxy_statistics_prefs); + data_reduction_proxy_compression_stats); } } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc index d3b534f..8ca2474 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc @@ -12,10 +12,10 @@ #include "base/strings/string_number_conversions.h" #include "base/test/histogram_tester.h" #include "base/time/time.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" @@ -151,8 +151,8 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test { return test_context_->config(); } - DataReductionProxyStatisticsPrefs* statistics_prefs() const { - return test_context_->data_reduction_proxy_service()->statistics_prefs(); + DataReductionProxyCompressionStats* compression_stats() const { + return test_context_->data_reduction_proxy_service()->compression_stats(); } scoped_ptr<DataReductionProxyNetworkDelegate> @@ -425,12 +425,12 @@ TEST_F(DataReductionProxyNetworkDelegateTest, TotalLengths) { UNKNOWN_TYPE); EXPECT_EQ(kReceivedLength, - statistics_prefs()->GetInt64( + compression_stats()->GetInt64( data_reduction_proxy::prefs::kHttpReceivedContentLength)); EXPECT_FALSE(pref_service()->GetBoolean( data_reduction_proxy::prefs::kDataReductionProxyEnabled)); EXPECT_EQ(kOriginalLength, - statistics_prefs()->GetInt64( + compression_stats()->GetInt64( data_reduction_proxy::prefs::kHttpOriginalContentLength)); // Record the same numbers again, and total lengths should be doubled. @@ -441,12 +441,12 @@ TEST_F(DataReductionProxyNetworkDelegateTest, TotalLengths) { UNKNOWN_TYPE); EXPECT_EQ(kReceivedLength * 2, - statistics_prefs()->GetInt64( + compression_stats()->GetInt64( data_reduction_proxy::prefs::kHttpReceivedContentLength)); EXPECT_FALSE(pref_service()->GetBoolean( data_reduction_proxy::prefs::kDataReductionProxyEnabled)); EXPECT_EQ(kOriginalLength * 2, - statistics_prefs()->GetInt64( + compression_stats()->GetInt64( data_reduction_proxy::prefs::kHttpOriginalContentLength)); } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.cc index 3652fcb..00acd88 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.cc @@ -109,7 +109,7 @@ void RegisterSimpleProfilePrefs(PrefRegistrySimple* registry) { } // Add any new data reduction proxy prefs to the |pref_map_| or the -// |list_pref_map_| in Init() of DataReductionProxyStatisticsPrefs. +// |list_pref_map_| in Init() of DataReductionProxyCompressionStats. void RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterInt64Pref( prefs::kHttpReceivedContentLength, 0); diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc index 947f451..b4ec8e3 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc @@ -5,7 +5,7 @@ #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "base/sequenced_task_runner.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "net/base/load_flags.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_request_status.h" @@ -13,14 +13,14 @@ namespace data_reduction_proxy { DataReductionProxyService::DataReductionProxyService( - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, + scoped_ptr<DataReductionProxyCompressionStats> compression_stats, DataReductionProxySettings* settings, net::URLRequestContextGetter* request_context_getter) : url_request_context_getter_(request_context_getter), settings_(settings), weak_factory_(this) { DCHECK(settings); - statistics_prefs_ = statistics_prefs.Pass(); + compression_stats_ = compression_stats.Pass(); } DataReductionProxyService::~DataReductionProxyService() { @@ -35,8 +35,8 @@ void DataReductionProxyService::EnableCompressionStatisticsLogging( PrefService* prefs, scoped_refptr<base::SequencedTaskRunner> ui_task_runner, const base::TimeDelta& commit_delay) { - DCHECK(!statistics_prefs_); - statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( + DCHECK(!compression_stats_); + compression_stats_.reset(new DataReductionProxyCompressionStats( prefs, ui_task_runner, commit_delay)); } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h index 5343635..1760c10 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h @@ -32,8 +32,7 @@ typedef base::Callback<void(const std::string&, const net::URLRequestStatus&)> FetcherResponseCallback; class DataReductionProxySettings; -class DataReductionProxyStatisticsPrefs; - +class DataReductionProxyCompressionStats; // Contains and initializes all Data Reduction Proxy objects that have a // lifetime based on the UI thread. @@ -42,11 +41,11 @@ class DataReductionProxyService : public base::NonThreadSafe, public: // The caller must ensure that |settings| and |request_context| remain alive // for the lifetime of the |DataReductionProxyService| instance. This instance - // will take ownership of |statistics_prefs|. + // will take ownership of |compression_stats|. // TODO(jeremyim): DataReductionProxyService should own // DataReductionProxySettings and not vice versa. DataReductionProxyService( - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, + scoped_ptr<DataReductionProxyCompressionStats> compression_stats, DataReductionProxySettings* settings, net::URLRequestContextGetter* request_context_getter); @@ -60,15 +59,15 @@ class DataReductionProxyService : public base::NonThreadSafe, virtual void SecureProxyCheck(const GURL& secure_proxy_check_url, FetcherResponseCallback fetcher_callback); - // Constructs statistics prefs. This should not be called if a valid - // statistics prefs is passed into the constructor. + // Constructs compression stats. This should not be called if a valid + // compression stats is passed into the constructor. void EnableCompressionStatisticsLogging( PrefService* prefs, scoped_refptr<base::SequencedTaskRunner> ui_task_runner, const base::TimeDelta& commit_delay); - DataReductionProxyStatisticsPrefs* statistics_prefs() const { - return statistics_prefs_.get(); + DataReductionProxyCompressionStats* compression_stats() const { + return compression_stats_.get(); } DataReductionProxySettings* settings() const { @@ -94,7 +93,7 @@ class DataReductionProxyService : public base::NonThreadSafe, FetcherResponseCallback fetcher_callback_; // Tracks compression statistics to be displayed to the user. - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; + scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; DataReductionProxySettings* settings_; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc index 26b3a7e..838689e 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc @@ -11,10 +11,10 @@ #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" @@ -166,9 +166,9 @@ void DataReductionProxySettings::SetDataReductionProxyAlternativeEnabled( int64 DataReductionProxySettings::GetDataReductionLastUpdateTime() { DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK(data_reduction_proxy_service_->statistics_prefs()); + DCHECK(data_reduction_proxy_service_->compression_stats()); int64 last_update_internal = - data_reduction_proxy_service_->statistics_prefs()->GetInt64( + data_reduction_proxy_service_->compression_stats()->GetInt64( prefs::kDailyHttpContentLengthLastUpdateDate); base::Time last_update = base::Time::FromInternalValue(last_update_internal); return static_cast<int64>(last_update.ToJsTime()); @@ -236,12 +236,12 @@ void DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange() { void DataReductionProxySettings::ResetDataReductionStatistics() { DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK(data_reduction_proxy_service_->statistics_prefs()); + DCHECK(data_reduction_proxy_service_->compression_stats()); base::ListValue* original_update = - data_reduction_proxy_service_->statistics_prefs()->GetList( + data_reduction_proxy_service_->compression_stats()->GetList( prefs::kDailyHttpOriginalContentLength); base::ListValue* received_update = - data_reduction_proxy_service_->statistics_prefs()->GetList( + data_reduction_proxy_service_->compression_stats()->GetList( prefs::kDailyHttpReceivedContentLength); original_update->Clear(); received_update->Clear(); @@ -296,9 +296,9 @@ DataReductionProxySettings::ContentLengthList DataReductionProxySettings::GetDailyContentLengths(const char* pref_name) { DCHECK(thread_checker_.CalledOnValidThread()); DataReductionProxySettings::ContentLengthList content_lengths; - DCHECK(data_reduction_proxy_service_->statistics_prefs()); + DCHECK(data_reduction_proxy_service_->compression_stats()); const base::ListValue* list_value = - data_reduction_proxy_service_->statistics_prefs()->GetList(pref_name); + data_reduction_proxy_service_->compression_stats()->GetList(pref_name); if (list_value->GetSize() == kNumDaysInHistory) { for (size_t i = 0; i < kNumDaysInHistory; ++i) { content_lengths.push_back(GetInt64PrefValue(*list_value, i)); @@ -314,13 +314,13 @@ void DataReductionProxySettings::GetContentLengths( int64* last_update_time) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_LE(days, kNumDaysInHistory); - DCHECK(data_reduction_proxy_service_->statistics_prefs()); + DCHECK(data_reduction_proxy_service_->compression_stats()); const base::ListValue* original_list = - data_reduction_proxy_service_->statistics_prefs()->GetList( + data_reduction_proxy_service_->compression_stats()->GetList( prefs::kDailyHttpOriginalContentLength); const base::ListValue* received_list = - data_reduction_proxy_service_->statistics_prefs()->GetList( + data_reduction_proxy_service_->compression_stats()->GetList( prefs::kDailyHttpReceivedContentLength); if (original_list->GetSize() != kNumDaysInHistory || @@ -342,7 +342,7 @@ void DataReductionProxySettings::GetContentLengths( *original_content_length = orig; *received_content_length = recv; *last_update_time = - data_reduction_proxy_service_->statistics_prefs()->GetInt64( + data_reduction_proxy_service_->compression_stats()->GetInt64( prefs::kDailyHttpContentLengthLastUpdateDate); } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h index 211b126..ca19611 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h @@ -25,7 +25,7 @@ class DataReductionProxyConfig; class DataReductionProxyEventStore; class DataReductionProxyIOData; class DataReductionProxyService; -class DataReductionProxyStatisticsPrefs; +class DataReductionProxyCompressionStats; // The number of days of bandwidth usage statistics that are tracked. const unsigned int kNumDaysInHistory = 60; @@ -74,7 +74,7 @@ class DataReductionProxySettings { DataReductionProxyIOData* io_data, scoped_ptr<DataReductionProxyService> data_reduction_proxy_service); - base::WeakPtr<DataReductionProxyStatisticsPrefs> statistics_prefs(); + base::WeakPtr<DataReductionProxyCompressionStats> compression_stats(); // Sets the |register_synthetic_field_trial_| callback and runs to register // the DataReductionProxyEnabled and the DataReductionProxyLoFiEnabled diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc index e2c0a70..5fda507 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc @@ -11,9 +11,9 @@ #include "base/prefs/testing_pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/time/time.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator_test_utils.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" @@ -75,7 +75,7 @@ void DataReductionProxySettingsTestBase::SetUp() { received_update->Insert(0, new base::StringValue(base::Int64ToString(i))); } last_update_time_ = base::Time::Now().LocalMidnight(); - settings_->data_reduction_proxy_service()->statistics_prefs()->SetInt64( + settings_->data_reduction_proxy_service()->compression_stats()->SetInt64( prefs::kDailyHttpContentLengthLastUpdateDate, last_update_time_.ToInternalValue()); } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h index 72c5afe..5361154 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h @@ -24,7 +24,6 @@ class TestingPrefServiceSimple; namespace data_reduction_proxy { class DataReductionProxyConfigurator; -class DataReductionProxyStatisticsPrefs; class DataReductionProxyTestContext; class MockDataReductionProxyConfig; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc index fe091dc..92bb811 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc @@ -7,10 +7,10 @@ #include "base/command_line.h" #include "base/md5.h" #include "base/metrics/field_trial.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc index 7f1927e..abdf5cc 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc @@ -6,6 +6,7 @@ #include "base/message_loop/message_loop.h" #include "base/prefs/testing_pref_service.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator_test_utils.h" @@ -14,7 +15,6 @@ #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" @@ -160,11 +160,11 @@ TestDataReductionProxyConfigServiceClient::TestBackoffEntry::ImplGetTimeNow() } MockDataReductionProxyService::MockDataReductionProxyService( - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, + scoped_ptr<DataReductionProxyCompressionStats> compression_stats, DataReductionProxySettings* settings, net::URLRequestContextGetter* request_context) : DataReductionProxyService( - statistics_prefs.Pass(), settings, request_context) { + compression_stats.Pass(), settings, request_context) { } MockDataReductionProxyService::~MockDataReductionProxyService() { @@ -450,17 +450,17 @@ DataReductionProxyTestContext::CreateDataReductionProxyService() { scoped_ptr<DataReductionProxyService> DataReductionProxyTestContext::CreateDataReductionProxyServiceInternal() { - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs = - make_scoped_ptr(new DataReductionProxyStatisticsPrefs( + scoped_ptr<DataReductionProxyCompressionStats> compression_stats = + make_scoped_ptr(new DataReductionProxyCompressionStats( simple_pref_service_.get(), task_runner_, base::TimeDelta())); if (test_context_flags_ & DataReductionProxyTestContext::USE_MOCK_SERVICE) { return make_scoped_ptr(new MockDataReductionProxyService( - statistics_prefs.Pass(), settings_.get(), + compression_stats.Pass(), settings_.get(), request_context_getter_.get())); } else { return make_scoped_ptr( - new DataReductionProxyService(statistics_prefs.Pass(), settings_.get(), + new DataReductionProxyService(compression_stats.Pass(), settings_.get(), request_context_getter_.get())); } } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h index 722fd8c..d0012ff 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h @@ -43,7 +43,7 @@ class DataReductionProxyEventStore; class DataReductionProxyMutableConfigValues; class DataReductionProxyRequestOptions; class DataReductionProxySettings; -class DataReductionProxyStatisticsPrefs; +class DataReductionProxyCompressionStats; class MockDataReductionProxyConfig; class TestDataReductionProxyConfig; class TestDataReductionProxyConfigurator; @@ -155,7 +155,7 @@ class TestDataReductionProxyConfigServiceClient class MockDataReductionProxyService : public DataReductionProxyService { public: MockDataReductionProxyService( - scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, + scoped_ptr<DataReductionProxyCompressionStats> compression_stats, DataReductionProxySettings* settings, net::URLRequestContextGetter* request_context); ~MockDataReductionProxyService() override; |