Chromium Code Reviews| 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 dcf3bcf9d593e80c22e8e293bff942b704ac5f2a..0977038cd8f58f2cda2456517c6054b666216f73 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" |
| @@ -135,6 +139,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::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,44 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| BrowserContext::EnsureResourceContextInitialized(profile); |
| } |
| -#if defined(OS_ANDROID) |
| -#if defined(SPDY_PROXY_AUTH_ORIGIN) |
| void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread( |
| 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)); |
| 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) |
| + DataReductionProxySettings* proxySettings = |
|
bengr
2014/07/15 16:38:16
proxy_settings
Not at Google. Contact bengr
2014/07/16 22:41:34
Done.
|
| + new DataReductionProxySettings(params); |
| + proxySettings->SetDataReductionProxyUsageStats(usage_stats); |
|
bengr
2014/07/15 16:38:16
Who owns proxy_settings? This is a memory leak.
Not at Google. Contact bengr
2014/07/16 22:41:34
Assigned to scoped_ptr.
|
| + PrefService* prefs = profile->GetPrefs(); |
| + scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
| + configurator(new DataReductionProxyChromeConfigurator(prefs)); |
| + proxySettings->SetProxyConfigurator(configurator.Pass()); |
| + proxySettings->InitDataReductionProxySettings(prefs, |
| + g_browser_process->local_state(), |
| + ProfileManager::GetActiveUserProfile()->GetRequestContext()); |
| +#endif |
| } |
| } |
| -#endif |
| -#endif |
| ProfileIOData::MediaRequestContext::MediaRequestContext() { |
| } |