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

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

Issue 888713002: DataReductionProxyStatisticsPrefs should support WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Webview fix Created 5 years, 10 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/core/browser/data_reduction_proxy_settings_test_utils.cc
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 053b0bcde26d9b861fc3f4e7fd025b37dc17c6ab..bab1889904b9ef5ccfbefdacf6b0aa12205e6e55 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
@@ -68,11 +68,6 @@ void DataReductionProxySettingsTestBase::SetUp() {
registry->RegisterBooleanPref(prefs::kDataReductionProxyWasEnabledBefore,
false);
- statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs(
- &pref_service_,
- scoped_refptr<base::TestSimpleTaskRunner>(
- new base::TestSimpleTaskRunner()),
- base::TimeDelta()));
event_store_.reset(new DataReductionProxyEventStore(
scoped_refptr<base::TestSimpleTaskRunner>(
new base::TestSimpleTaskRunner())));
@@ -90,9 +85,17 @@ void DataReductionProxySettingsTestBase::SetUp() {
received_update->Insert(0, new base::StringValue(base::Int64ToString(i)));
}
last_update_time_ = base::Time::Now().LocalMidnight();
- statistics_prefs_->SetInt64(
+ scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs(
+ new DataReductionProxyStatisticsPrefs(
+ &pref_service_,
+ scoped_refptr<base::TestSimpleTaskRunner>(
+ new base::TestSimpleTaskRunner()),
+ base::TimeDelta()));
+ statistics_prefs->SetInt64(
prefs::kDailyHttpContentLengthLastUpdateDate,
last_update_time_.ToInternalValue());
+ settings_->SetDataReductionProxyStatisticsPrefs(
+ statistics_prefs.Pass());
expected_params_.reset(new TestDataReductionProxyParams(
DataReductionProxyParams::kAllowed |
DataReductionProxyParams::kFallbackAllowed |
@@ -134,7 +137,6 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
scoped_refptr<base::TestSimpleTaskRunner>(
new base::TestSimpleTaskRunner()), &net_log_, event_store_.get()));
settings_->configurator_ = configurator_.get();
- settings_->SetDataReductionProxyStatisticsPrefs(statistics_prefs_.get());
}
// Explicitly generate required instantiations.
@@ -269,8 +271,13 @@ void DataReductionProxySettingsTestBase::CheckInitDataReductionProxy(
scoped_refptr<net::TestURLRequestContextGetter> request_context =
new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
+ // Delete statistics prefs, otherwise the DCHECK in
+ // InitDataReductionProxySettings fails.
+ settings_->SetDataReductionProxyStatisticsPrefs(
+ scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>());
settings_->InitDataReductionProxySettings(
&pref_service_,
+ scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(),
request_context.get(),
&net_log_,
event_store_.get());

Powered by Google App Engine
This is Rietveld 408576698