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

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

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra new line. 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_io_data.cc
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 6b6c086cd0c8b88eea9237894782540f098eda57..75b43d3f63e74b29fb67ca21aed5e483b10fedec 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -42,6 +42,7 @@
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/proxy_service_factory.h"
+#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_names_io_thread.h"
@@ -49,6 +50,9 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_config_service.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_configurator.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h"
#include "components/startup_metric_utils/startup_metric_utils.h"
#include "components/sync_driver/pref_names.h"
#include "components/url_fixer/url_fixer.h"
@@ -136,6 +140,8 @@
using content::BrowserContext;
using content::BrowserThread;
using content::ResourceContext;
+using data_reduction_proxy::DataReductionProxyParams;
+using data_reduction_proxy::DataReductionProxySettings;
using data_reduction_proxy::DataReductionProxyUsageStats;
namespace {
@@ -487,13 +493,9 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
initialized_on_UI_thread_ = true;
-#if defined(OS_ANDROID)
-#if defined(SPDY_PROXY_AUTH_ORIGIN)
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread,
+ base::Bind(&ProfileIOData::SetupDataReductionProxyOnIOThread,
base::Unretained(this), g_browser_process->io_thread(), profile));
-#endif
-#endif
// We need to make sure that content initializes its own data structures that
// are associated with each ResourceContext because we might post this
@@ -501,32 +503,45 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
BrowserContext::EnsureResourceContextInitialized(profile);
}
-#if defined(OS_ANDROID)
-#if defined(SPDY_PROXY_AUTH_ORIGIN)
-void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread(
+void ProfileIOData::SetupDataReductionProxyOnIOThread(
IOThread* io_thread, Profile* profile) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
IOThread::Globals* globals = io_thread->globals();
+ DataReductionProxyParams* params = globals->data_reduction_proxy_params.get();
DataReductionProxyUsageStats* usage_stats =
globals->data_reduction_proxy_usage_stats.get();
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread,
- base::Unretained(this), profile, usage_stats));
+ base::Bind(&ProfileIOData::SetupDataReductionProxyOnUIThread,
+ base::Unretained(this), profile, params, usage_stats));
}
-void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread(
+void ProfileIOData::SetupDataReductionProxyOnUIThread(
Profile* profile,
+ DataReductionProxyParams* params,
DataReductionProxyUsageStats* usage_stats) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
bengr 2014/07/18 19:41:43 Do we expect all the params to be non-NULL? If so,
Not at Google. Contact bengr 2014/07/21 17:46:25 Done.
if (g_browser_process->profile_manager()->IsValidProfile(profile)) {
+// TODO(kundaji): Combine code to initialize DRP on different platforms.
+#if defined(OS_ANDROID)
DataReductionProxySettingsAndroid* proxySettingsAndroid =
DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile);
if (proxySettingsAndroid)
proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats);
+#elif !defined(OS_IOS)
+ data_reduction_proxy_settings_.reset(
+ new DataReductionProxySettings(params));
+ data_reduction_proxy_settings_->SetDataReductionProxyUsageStats(
+ usage_stats);
+ PrefService* prefs = profile->GetPrefs();
+ scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
+ configurator(new DataReductionProxyChromeConfigurator(prefs));
+ data_reduction_proxy_settings_->SetProxyConfigurator(configurator.Pass());
+ data_reduction_proxy_settings_->InitDataReductionProxySettings(prefs,
+ g_browser_process->local_state(),
+ ProfileManager::GetActiveUserProfile()->GetRequestContext());
+#endif
}
}
-#endif
-#endif
ProfileIOData::MediaRequestContext::MediaRequestContext() {
}
@@ -1037,6 +1052,11 @@ void ProfileIOData::Init(
profile_params_->proxy_config_service.release(),
command_line,
quick_check_enabled_.GetValue()));
+ DCHECK(io_thread_globals->data_reduction_proxy_params);
+ proxy_service_->SetDataReductionProxyOrigins(
+ io_thread_globals->data_reduction_proxy_params->GetDefaultOrigin(),
+ io_thread_globals->data_reduction_proxy_params->
+ GetDefaultFallbackOrigin());
transport_security_state_.reset(new net::TransportSecurityState());
transport_security_persister_.reset(

Powered by Google App Engine
This is Rietveld 408576698