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

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

Issue 1221663009: Expose API to store and load data usage stats from UI task runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Breakdown
Patch Set: Sync to head Created 5 years, 5 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_test_utils.cc
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 3ce2a52c00588cd8ee3907b47dfaf4809bbd62e5..6811e25a4baff7247cb408061e0f9e2c778ed619 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
@@ -15,6 +15,7 @@
#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_store.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h"
@@ -167,19 +168,21 @@ MockDataReductionProxyService::MockDataReductionProxyService(
DataReductionProxySettings* settings,
PrefService* prefs,
net::URLRequestContextGetter* request_context,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: DataReductionProxyService(compression_stats.Pass(),
settings,
prefs,
request_context,
- io_task_runner) {
+ make_scoped_ptr(new DataStore()),
+ task_runner,
+ task_runner) {
}
MockDataReductionProxyService::~MockDataReductionProxyService() {
}
TestDataReductionProxyIOData::TestDataReductionProxyIOData(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_ptr<DataReductionProxyConfig> config,
scoped_ptr<DataReductionProxyEventCreator> event_creator,
scoped_ptr<DataReductionProxyRequestOptions> request_options,
@@ -201,8 +204,6 @@ TestDataReductionProxyIOData::TestDataReductionProxyIOData(
bypass_stats_.reset(new DataReductionProxyBypassStats(
config_.get(), base::Bind(&DataReductionProxyIOData::SetUnreachable,
base::Unretained(this))));
- io_task_runner_ = task_runner;
- ui_task_runner_ = task_runner;
enabled_ = enabled;
}
@@ -438,7 +439,7 @@ DataReductionProxyTestContext::Builder::Build() {
}
DataReductionProxyTestContext::DataReductionProxyTestContext(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_ptr<TestingPrefServiceSimple> simple_pref_service,
scoped_ptr<net::TestNetLog> net_log,
scoped_refptr<net::URLRequestContextGetter> request_context_getter,
@@ -463,6 +464,7 @@ DataReductionProxyTestContext::DataReductionProxyTestContext(
}
DataReductionProxyTestContext::~DataReductionProxyTestContext() {
+ DestroySettings();
}
void DataReductionProxyTestContext::RunUntilIdle() {
@@ -475,6 +477,15 @@ void DataReductionProxyTestContext::InitSettings() {
InitSettingsWithoutCheck();
}
+void DataReductionProxyTestContext::DestroySettings() {
+ // Force destruction of |DBDataOwner|, which lives on DB task runner and is
+ // indirectly owned by |settings_|.
+ if (settings_.get()) {
+ settings_.reset();
+ RunUntilIdle();
+ }
+}
+
void DataReductionProxyTestContext::InitSettingsWithoutCheck() {
settings_->InitDataReductionProxySettings(
simple_pref_service_.get(), io_data_.get(),
@@ -509,7 +520,8 @@ DataReductionProxyTestContext::CreateDataReductionProxyServiceInternal() {
} else {
return make_scoped_ptr(new DataReductionProxyService(
compression_stats.Pass(), settings_.get(), simple_pref_service_.get(),
- request_context_getter_.get(), task_runner_));
+ request_context_getter_.get(), make_scoped_ptr(new DataStore()),
+ task_runner_, task_runner_));
}
}

Powered by Google App Engine
This is Rietveld 408576698