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

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

Issue 2076663004: Control data saver pingback reporting fraction with protobuf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 6 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 a9740dc09d357213413c8b567e8bec0c66049aaf..bef5d0969d1b8fa50daa2586d029dadcc2eab75a 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
@@ -8,20 +8,21 @@
#include <utility>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.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.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_interceptor.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.h"
#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"
#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"
@@ -96,28 +97,30 @@ MockDataReductionProxyRequestOptions::MockDataReductionProxyRequestOptions(
MockDataReductionProxyRequestOptions::~MockDataReductionProxyRequestOptions() {
}
TestDataReductionProxyConfigServiceClient::
TestDataReductionProxyConfigServiceClient(
std::unique_ptr<DataReductionProxyParams> params,
DataReductionProxyRequestOptions* request_options,
DataReductionProxyMutableConfigValues* config_values,
DataReductionProxyConfig* config,
DataReductionProxyEventCreator* event_creator,
+ DataReductionProxyIOData* io_data,
net::NetLog* net_log,
ConfigStorer config_storer)
: DataReductionProxyConfigServiceClient(std::move(params),
kTestBackoffPolicy,
request_options,
config_values,
config,
event_creator,
+ io_data,
net_log,
config_storer),
#if defined(OS_ANDROID)
is_application_state_background_(false),
#endif
tick_clock_(base::Time::UnixEpoch()),
test_backoff_entry_(&kTestBackoffPolicy, &tick_clock_) {
}
TestDataReductionProxyConfigServiceClient::
@@ -210,41 +213,46 @@ MockDataReductionProxyService::MockDataReductionProxyService(
MockDataReductionProxyService::~MockDataReductionProxyService() {
}
TestDataReductionProxyIOData::TestDataReductionProxyIOData(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
std::unique_ptr<DataReductionProxyConfig> config,
std::unique_ptr<DataReductionProxyEventCreator> event_creator,
std::unique_ptr<DataReductionProxyRequestOptions> request_options,
std::unique_ptr<DataReductionProxyConfigurator> configurator,
- std::unique_ptr<DataReductionProxyConfigServiceClient> config_client,
net::NetLog* net_log,
bool enabled)
- : DataReductionProxyIOData(), service_set_(false) {
+ : DataReductionProxyIOData(),
+ service_set_(false),
+ pingback_reporting_fraction_(0.0f) {
io_task_runner_ = task_runner;
ui_task_runner_ = task_runner;
config_ = std::move(config);
event_creator_ = std::move(event_creator);
request_options_ = std::move(request_options);
configurator_ = std::move(configurator);
- config_client_ = std::move(config_client);
net_log_ = net_log;
bypass_stats_.reset(new DataReductionProxyBypassStats(
config_.get(), base::Bind(&DataReductionProxyIOData::SetUnreachable,
base::Unretained(this))));
enabled_ = enabled;
}
TestDataReductionProxyIOData::~TestDataReductionProxyIOData() {
}
+void TestDataReductionProxyIOData::SetPingbackReportingFraction(
+ float pingback_reporting_fraction) {
+ pingback_reporting_fraction_ = pingback_reporting_fraction;
+}
+
void TestDataReductionProxyIOData::SetDataReductionProxyService(
base::WeakPtr<DataReductionProxyService> data_reduction_proxy_service) {
if (!service_set_)
DataReductionProxyIOData::SetDataReductionProxyService(
data_reduction_proxy_service);
service_set_ = true;
}
TestDataStore::TestDataStore() {}
@@ -422,57 +430,59 @@ DataReductionProxyTestContext::Builder::Build() {
std::unique_ptr<DataReductionProxyRequestOptions> request_options;
if (use_mock_request_options_) {
test_context_flags |= USE_MOCK_REQUEST_OPTIONS;
request_options.reset(
new MockDataReductionProxyRequestOptions(client_, config.get()));
} else {
request_options.reset(
new DataReductionProxyRequestOptions(client_, config.get()));
}
- if (use_test_config_client_) {
- test_context_flags |= USE_TEST_CONFIG_CLIENT;
- config_client.reset(new TestDataReductionProxyConfigServiceClient(
- std::move(params), request_options.get(), raw_mutable_config,
- config.get(), event_creator.get(), net_log.get(),
- base::Bind(&TestConfigStorer::StoreSerializedConfig,
- base::Unretained(config_storer.get()))));
- } else if (use_config_client_) {
- config_client.reset(new DataReductionProxyConfigServiceClient(
- std::move(params), GetBackoffPolicy(), request_options.get(),
- raw_mutable_config, config.get(), event_creator.get(), net_log.get(),
- base::Bind(&TestConfigStorer::StoreSerializedConfig,
- base::Unretained(config_storer.get()))));
- }
-
std::unique_ptr<DataReductionProxySettings> settings(
new DataReductionProxySettings());
if (skip_settings_initialization_) {
settings->set_data_reduction_proxy_enabled_pref_name_for_test(
kDataReductionProxyEnabled);
test_context_flags |= SKIP_SETTINGS_INITIALIZATION;
}
if (use_mock_service_)
test_context_flags |= USE_MOCK_SERVICE;
pref_service->registry()->RegisterBooleanPref(kDataReductionProxyEnabled,
false);
RegisterSimpleProfilePrefs(pref_service->registry());
std::unique_ptr<TestDataReductionProxyIOData> io_data(
new TestDataReductionProxyIOData(
task_runner, std::move(config), std::move(event_creator),
- std::move(request_options), std::move(configurator),
- std::move(config_client), net_log.get(), true /* enabled */));
+ std::move(request_options), std::move(configurator), net_log.get(),
+ true /* enabled */));
io_data->SetSimpleURLRequestContextGetter(request_context_getter);
+ if (use_test_config_client_) {
+ test_context_flags |= USE_TEST_CONFIG_CLIENT;
+ config_client.reset(new TestDataReductionProxyConfigServiceClient(
+ std::move(params), io_data->request_options(), raw_mutable_config,
+ io_data->config(), io_data->event_creator(), io_data.get(),
+ net_log.get(), base::Bind(&TestConfigStorer::StoreSerializedConfig,
+ base::Unretained(config_storer.get()))));
+ } else if (use_config_client_) {
+ config_client.reset(new DataReductionProxyConfigServiceClient(
+ std::move(params), GetBackoffPolicy(), io_data->request_options(),
+ raw_mutable_config, io_data->config(), io_data->event_creator(),
+ io_data.get(), net_log.get(),
+ base::Bind(&TestConfigStorer::StoreSerializedConfig,
+ base::Unretained(config_storer.get()))));
+ }
+ io_data->set_config_client(std::move(config_client));
+
std::unique_ptr<DataReductionProxyTestContext> test_context(
new DataReductionProxyTestContext(
task_runner, std::move(pref_service), std::move(net_log),
request_context_getter, mock_socket_factory_, std::move(io_data),
std::move(settings), std::move(storage_delegate),
std::move(config_storer), raw_params, test_context_flags));
if (!skip_settings_initialization_)
test_context->InitSettingsWithoutCheck();

Powered by Google App Engine
This is Rietveld 408576698