Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc

Issue 473723002: Update data reduction proxy statistics prefs less often on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tooManyWritesPatch
Patch Set: Addressed bengr comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
index 7cf609a139d3d4a123d0900208a2c563bde4c266..44c79cc5095e0d816ef224095c01d040ea1b7111 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
@@ -10,6 +10,8 @@
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string_number_conversions.h"
+#include "base/test/test_simple_task_runner.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_statistics_prefs.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h"
@@ -83,6 +85,11 @@ DataReductionProxySettingsTestBase::~DataReductionProxySettingsTestBase() {}
// testing::Test implementation:
void DataReductionProxySettingsTestBase::SetUp() {
+ statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs(
+ &pref_service_,
+ scoped_refptr<base::TestSimpleTaskRunner>(
+ new base::TestSimpleTaskRunner()),
+ commit_delay_));
PrefRegistrySimple* registry = pref_service_.registry();
registry->RegisterListPref(prefs::kDailyHttpOriginalContentLength);
registry->RegisterListPref(prefs::kDailyHttpReceivedContentLength);
@@ -106,7 +113,13 @@ void DataReductionProxySettingsTestBase::SetUp() {
received_update->Insert(0, new base::StringValue(base::Int64ToString(i)));
}
last_update_time_ = base::Time::Now().LocalMidnight();
- pref_service_.SetInt64(
+ if (commit_delay_ != base::TimeDelta()) {
+ statistics_prefs_->InitInt64Pref(
+ prefs::kDailyHttpContentLengthLastUpdateDate);
+ statistics_prefs_->InitListPref(prefs::kDailyHttpOriginalContentLength);
+ statistics_prefs_->InitListPref(prefs::kDailyHttpReceivedContentLength);
+ }
+ statistics_prefs_->SetInt64(
prefs::kDailyHttpContentLengthLastUpdateDate,
last_update_time_.ToInternalValue());
expected_params_.reset(new TestDataReductionProxyParams(
@@ -148,6 +161,8 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
settings_.reset(settings);
configurator_.reset(new TestDataReductionProxyConfig());
settings_->configurator_ = configurator_.get();
+ settings_->SetDataReductionProxyStatisticsPrefs(
+ statistics_prefs_.get());
bengr 2014/08/28 21:38:35 Can this fit on the previous line?
megjablon 2014/08/30 01:10:04 Done.
}
// Explicitly generate required instantiations.
@@ -303,7 +318,6 @@ void DataReductionProxySettingsTestBase::CheckInitDataReductionProxy(
settings_->InitDataReductionProxySettings(
&pref_service_,
- &pref_service_,
request_context.get());
settings_->SetOnDataReductionEnabledCallback(
base::Bind(&DataReductionProxySettingsTestBase::

Powered by Google App Engine
This is Rietveld 408576698