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

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

Issue 412143009: Moved data reduction proxy initialization logic to ProfileImplIOData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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: 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 eff5ad5e245e72955b73626a7522fb1773a50f43..08fd5fadfaa1881938c5cdfc6e8cc6319f5d8c0f 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -50,6 +50,13 @@
#include "net/url_request/url_request_job_factory_impl.h"
#include "webkit/browser/quota/special_storage_policy.h"
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
+#include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names.h"
+#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
+
namespace {
net::BackendType ChooseCacheBackendType() {
@@ -78,6 +85,9 @@ net::BackendType ChooseCacheBackendType() {
} // namespace
using content::BrowserThread;
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+using data_reduction_proxy::DataReductionProxyParams;
+#endif // defined(OS_ANDROID) || defined(OS_IOS)
ProfileImplIOData::Handle::Handle(Profile* profile)
: io_data_(new ProfileImplIOData),
@@ -120,7 +130,8 @@ void ProfileImplIOData::Handle::Init(
content::CookieStoreConfig::SessionCookieMode session_cookie_mode,
quota::SpecialStoragePolicy* special_storage_policy,
scoped_ptr<domain_reliability::DomainReliabilityMonitor>
- domain_reliability_monitor) {
+ domain_reliability_monitor,
+ const base::Callback<void(bool)>& data_reduction_proxy_unavailable) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!io_data_->lazy_params_);
DCHECK(predictor);
@@ -150,6 +161,11 @@ void ProfileImplIOData::Handle::Init(
io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass();
io_data_->InitializeMetricsEnabledStateOnUIThread();
+
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+ io_data_->data_reduction_proxy_unavailable_callback_ =
+ data_reduction_proxy_unavailable;
+#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
}
content::ResourceContext*
@@ -328,12 +344,12 @@ void ProfileImplIOData::Handle::LazyInitialize() const {
io_data_->safe_browsing_enabled()->MoveToThread(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
#endif
-#if defined(OS_ANDROID) || defined(OS_IOS)
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
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));
-#endif
+#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
io_data_->InitializeOnUIThread(profile_);
}
@@ -371,6 +387,39 @@ void ProfileImplIOData::InitializeInternal(
IOThread* const io_thread = profile_params->io_thread;
IOThread::Globals* const io_thread_globals = io_thread->globals();
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+ // TODO(bengr): Extract parameters from DataReductionProxySettings.
+ int drp_flags = DataReductionProxyParams::kFallbackAllowed;
+ if (DataReductionProxyParams::IsIncludedInFieldTrial())
+ drp_flags |= DataReductionProxyParams::kAllowed;
+ if (DataReductionProxyParams::IsIncludedInAlternativeFieldTrial())
+ drp_flags |= DataReductionProxyParams::kAlternativeAllowed;
+ if (DataReductionProxyParams::IsIncludedInPromoFieldTrial())
+ drp_flags |= DataReductionProxyParams::kPromoAllowed;
+ data_reduction_proxy_params_.reset(
+ new DataReductionProxyParams(drp_flags));
+ data_reduction_proxy_auth_request_handler_.reset(
+ new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
+ data_reduction_proxy_params_.get()));
+ data_reduction_proxy_usage_stats_.reset(
+ new data_reduction_proxy::DataReductionProxyUsageStats(
+ data_reduction_proxy_params_.get(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
+ data_reduction_proxy_usage_stats_->set_unavailable_callback(
+ data_reduction_proxy_unavailable_callback_);
+
+
+ network_delegate()->set_data_reduction_proxy_params(
+ data_reduction_proxy_params_.get());
+ network_delegate()->set_data_reduction_proxy_usage_stats(
+ data_reduction_proxy_usage_stats_.get());
+ network_delegate()->set_data_reduction_proxy_auth_request_handler(
+ data_reduction_proxy_auth_request_handler_.get());
+ network_delegate()->set_on_resolve_proxy_handler(
+ base::Bind(data_reduction_proxy::OnResolveProxyHandler));
+#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
+
network_delegate()->set_predictor(predictor_.get());
// Initialize context members.

Powered by Google App Engine
This is Rietveld 408576698