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

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: Created 6 years 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 8b3943958d0f4b30f2a011e7f4998dee43722a5d..8216330998e3334421a1356b505d6ee31b4f7bd0 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -28,21 +28,14 @@
#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_configurator.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_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_protocol.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/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/domain_reliability/monitor.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h"
@@ -89,7 +82,6 @@ net::BackendType ChooseCacheBackendType() {
} // namespace
using content::BrowserThread;
-using data_reduction_proxy::DataReductionProxyParams;
ProfileImplIOData::Handle::Handle(Profile* profile)
: io_data_(new ProfileImplIOData),
@@ -101,8 +93,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).
@@ -118,7 +108,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());
}
@@ -137,15 +127,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<DataReductionProxyChromeConfigurator>
- data_reduction_proxy_chrome_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);
@@ -178,15 +161,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_chrome_configurator(
- data_reduction_proxy_chrome_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*
@@ -366,9 +342,8 @@ 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(
+ io_data_->data_reduction_proxy_io_data()->InitPrefsOnUIThread(
+ pref_service,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
io_data_->InitializeOnUIThread(profile_);
}
@@ -442,38 +417,9 @@ void ProfileImplIOData::InitializeInternal(
chrome_network_delegate->set_domain_reliability_monitor(monitor);
}
- 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());
-
- 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(
- &DataReductionProxyChromeConfigurator::GetProxyConfigOnIOThread,
- base::Unretained(data_reduction_proxy_chrome_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();
+ data_reduction_proxy_io_data()->Init(
+ chrome_network_delegate.Pass(),
+ true, true, false);
// Initialize context members.
@@ -486,7 +432,8 @@ void ProfileImplIOData::InitializeInternal(
main_context->set_net_log(io_thread->net_log());
- main_context->set_network_delegate(network_delegate_.get());
+ main_context->set_network_delegate(
+ data_reduction_proxy_io_data()->network_delegate());
main_context->set_http_server_properties(http_server_properties());
@@ -588,10 +535,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(),
@@ -740,10 +684,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(),
@@ -853,9 +794,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() ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- data_reduction_proxy::switches::kEnableDataReductionProxy);
-}

Powered by Google App Engine
This is Rietveld 408576698