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

Unified Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 778463002: Wrapped data reduction proxy initialization into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@network-delegate
Patch Set: Addressed comments from sclittle Created 5 years, 11 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: chrome/browser/profiles/profile_impl_io_data.cc
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index b49d8075939e9c4bd950fb3b872d0f93d9e7a99b..6ed9703ab65b38e804cf444ee2338211e850c616 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -28,19 +28,12 @@
#include "chrome/browser/net/http_server_properties_manager_factory.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/quota_policy_channel_id_store.h"
-#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.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_network_delegate.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h"
-#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
#include "components/domain_reliability/monitor.h"
#include "content/public/browser/browser_thread.h"
@@ -90,7 +83,6 @@ net::BackendType ChooseCacheBackendType() {
} // namespace
using content::BrowserThread;
-using data_reduction_proxy::DataReductionProxyParams;
ProfileImplIOData::Handle::Handle(Profile* profile)
: io_data_(new ProfileImplIOData),
@@ -102,8 +94,6 @@ ProfileImplIOData::Handle::Handle(Profile* profile)
ProfileImplIOData::Handle::~Handle() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- io_data_->data_reduction_proxy_statistics_prefs()->WritePrefs();
-
if (io_data_->predictor_ != NULL) {
// io_data_->predictor_ might be NULL if Init() was never called
// (i.e. we shut down before ProfileImpl::DoFinalInit() got called).
@@ -119,7 +109,7 @@ ProfileImplIOData::Handle::~Handle() {
if (io_data_->http_server_properties_manager_)
io_data_->http_server_properties_manager_->ShutdownOnPrefThread();
- io_data_->data_reduction_proxy_enabled_.Destroy();
+ io_data_->data_reduction_proxy_io_data()->DestroyPrefsOnUIThread();
io_data_->ShutdownOnUIThread(GetAllContextGetters().Pass());
}
@@ -138,15 +128,8 @@ void ProfileImplIOData::Handle::Init(
storage::SpecialStoragePolicy* special_storage_policy,
scoped_ptr<domain_reliability::DomainReliabilityMonitor>
domain_reliability_monitor,
- const base::Callback<void(bool)>& data_reduction_proxy_unavailable,
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
- data_reduction_proxy_configurator,
- scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
- data_reduction_proxy_params,
- scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
- data_reduction_proxy_statistics_prefs,
- scoped_ptr<data_reduction_proxy::DataReductionProxyEventStore>
- data_reduction_proxy_event_store) {
+ scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
+ data_reduction_proxy_io_data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!io_data_->lazy_params_);
DCHECK(predictor);
@@ -179,15 +162,8 @@ void ProfileImplIOData::Handle::Init(
if (io_data_->domain_reliability_monitor_)
io_data_->domain_reliability_monitor_->MoveToNetworkThread();
- io_data_->set_data_reduction_proxy_unavailable_callback(
- data_reduction_proxy_unavailable);
- io_data_->set_data_reduction_proxy_configurator(
- data_reduction_proxy_configurator.Pass());
- io_data_->set_data_reduction_proxy_params(data_reduction_proxy_params.Pass());
- io_data_->set_data_reduction_proxy_statistics_prefs(
- data_reduction_proxy_statistics_prefs.Pass());
- io_data_->set_data_reduction_proxy_event_store(
- data_reduction_proxy_event_store.Pass());
+ io_data_->set_data_reduction_proxy_io_data(
+ data_reduction_proxy_io_data.Pass());
}
content::ResourceContext*
@@ -367,10 +343,7 @@ void ProfileImplIOData::Handle::LazyInitialize() const {
io_data_->safe_browsing_enabled()->MoveToThread(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
#endif
- io_data_->data_reduction_proxy_enabled_.Init(
- data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service);
- io_data_->data_reduction_proxy_enabled_.MoveToThread(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
+ io_data_->data_reduction_proxy_io_data()->InitPrefsOnUIThread(pref_service);
mmenke 2015/01/16 19:03:20 We're already passing the prefs to CreateDataReduc
bengr 2015/01/17 00:20:47 Done.
io_data_->InitializeOnUIThread(profile_);
}
@@ -458,52 +431,6 @@ void ProfileImplIOData::InitializeInternal(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"436671 ProfileImplIOData::InitializeInternal2"));
- set_data_reduction_proxy_auth_request_handler(
- scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
- (new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
- DataReductionProxyChromeSettings::GetClient(),
- data_reduction_proxy_params(),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))));
- set_data_reduction_proxy_usage_stats(
- scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats>
- (new data_reduction_proxy::DataReductionProxyUsageStats(
- data_reduction_proxy_params(),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)
- .get())));
- data_reduction_proxy_usage_stats()->set_unavailable_callback(
- data_reduction_proxy_unavailable_callback());
-
- // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed.
- tracked_objects::ScopedTracker tracking_profile3(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "436671 ProfileImplIOData::InitializeInternal3"));
-
- scoped_ptr<data_reduction_proxy::DataReductionProxyNetworkDelegate>
- data_reduction_proxy_network_delegate(
- new data_reduction_proxy::DataReductionProxyNetworkDelegate(
- chrome_network_delegate.Pass(),
- data_reduction_proxy_params(),
- data_reduction_proxy_auth_request_handler(),
- base::Bind(
- &data_reduction_proxy::DataReductionProxyConfigurator::
- GetProxyConfigOnIOThread,
- base::Unretained(data_reduction_proxy_configurator()))));
- data_reduction_proxy_network_delegate->InitProxyConfigOverrider(
- base::Bind(data_reduction_proxy::OnResolveProxyHandler));
- data_reduction_proxy_network_delegate->InitStatisticsPrefsAndUMA(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
- data_reduction_proxy_statistics_prefs(),
- &data_reduction_proxy_enabled_,
- data_reduction_proxy_usage_stats());
- network_delegate_ = data_reduction_proxy_network_delegate.Pass();
-
- // Initialize context members.
-
- // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed.
- tracked_objects::ScopedTracker tracking_profile4(
- FROM_HERE_WITH_EXPLICIT_FUNCTION(
- "436671 ProfileImplIOData::InitializeInternal4"));
-
ApplyProfileParamsToContext(main_context);
if (http_server_properties_manager_)
@@ -513,6 +440,9 @@ void ProfileImplIOData::InitializeInternal(
main_context->set_net_log(io_thread->net_log());
+ network_delegate_ = data_reduction_proxy_io_data()->CreateNetworkDelegate(
+ chrome_network_delegate.Pass(), true).Pass();
+
main_context->set_network_delegate(network_delegate_.get());
main_context->set_http_server_properties(http_server_properties());
@@ -640,10 +570,7 @@ void ProfileImplIOData::InitializeInternal(
// as possible.
request_interceptors.insert(
request_interceptors.begin(),
- new data_reduction_proxy::DataReductionProxyInterceptor(
- data_reduction_proxy_params(),
- data_reduction_proxy_usage_stats(),
- data_reduction_proxy_event_store()));
+ data_reduction_proxy_io_data()->CreateInterceptor());
main_job_factory_ = SetUpJobFactoryDefaults(
main_job_factory.Pass(),
request_interceptors.Pass(),
@@ -797,10 +724,7 @@ net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext(
// as possible.
request_interceptors.insert(
request_interceptors.begin(),
- new data_reduction_proxy::DataReductionProxyInterceptor(
- data_reduction_proxy_params(),
- data_reduction_proxy_usage_stats(),
- data_reduction_proxy_event_store()));
+ data_reduction_proxy_io_data()->CreateInterceptor());
scoped_ptr<net::URLRequestJobFactory> top_job_factory(
SetUpJobFactoryDefaults(job_factory.Pass(),
request_interceptors.Pass(),
@@ -910,9 +834,3 @@ void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
DCHECK(http_server_properties_manager_);
http_server_properties_manager_->Clear(completion);
}
-
-bool ProfileImplIOData::IsDataReductionProxyEnabled() const {
- return data_reduction_proxy_enabled_.GetValue() ||
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- data_reduction_proxy::switches::kEnableDataReductionProxy);
-}

Powered by Google App Engine
This is Rietveld 408576698