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

Side by Side 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: Patch to run tests overnight. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/extensions/extension_resource_protocols.h" 35 #include "chrome/browser/extensions/extension_resource_protocols.h"
36 #include "chrome/browser/io_thread.h" 36 #include "chrome/browser/io_thread.h"
37 #include "chrome/browser/media/media_device_id_salt.h" 37 #include "chrome/browser/media/media_device_id_salt.h"
38 #include "chrome/browser/net/about_protocol_handler.h" 38 #include "chrome/browser/net/about_protocol_handler.h"
39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h"
41 #include "chrome/browser/net/chrome_net_log.h" 41 #include "chrome/browser/net/chrome_net_log.h"
42 #include "chrome/browser/net/chrome_network_delegate.h" 42 #include "chrome/browser/net/chrome_network_delegate.h"
43 #include "chrome/browser/net/cookie_store_util.h" 43 #include "chrome/browser/net/cookie_store_util.h"
44 #include "chrome/browser/net/proxy_service_factory.h" 44 #include "chrome/browser/net/proxy_service_factory.h"
45 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator. h"
45 #include "chrome/browser/profiles/profile.h" 46 #include "chrome/browser/profiles/profile.h"
46 #include "chrome/browser/profiles/profile_manager.h" 47 #include "chrome/browser/profiles/profile_manager.h"
47 #include "chrome/browser/signin/signin_names_io_thread.h" 48 #include "chrome/browser/signin/signin_names_io_thread.h"
48 #include "chrome/common/chrome_paths.h" 49 #include "chrome/common/chrome_paths.h"
49 #include "chrome/common/chrome_switches.h" 50 #include "chrome/common/chrome_switches.h"
50 #include "chrome/common/pref_names.h" 51 #include "chrome/common/pref_names.h"
51 #include "chrome/common/url_constants.h" 52 #include "chrome/common/url_constants.h"
53 #include "components/data_reduction_proxy/browser/data_reduction_proxy_config_se rvice.h"
54 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura tor.h"
55 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
52 #include "components/startup_metric_utils/startup_metric_utils.h" 56 #include "components/startup_metric_utils/startup_metric_utils.h"
53 #include "components/sync_driver/pref_names.h" 57 #include "components/sync_driver/pref_names.h"
54 #include "components/url_fixer/url_fixer.h" 58 #include "components/url_fixer/url_fixer.h"
55 #include "content/public/browser/browser_thread.h" 59 #include "content/public/browser/browser_thread.h"
56 #include "content/public/browser/host_zoom_map.h" 60 #include "content/public/browser/host_zoom_map.h"
57 #include "content/public/browser/notification_service.h" 61 #include "content/public/browser/notification_service.h"
58 #include "content/public/browser/resource_context.h" 62 #include "content/public/browser/resource_context.h"
59 #include "extensions/browser/extension_protocols.h" 63 #include "extensions/browser/extension_protocols.h"
60 #include "extensions/browser/extension_system.h" 64 #include "extensions/browser/extension_system.h"
61 #include "extensions/browser/info_map.h" 65 #include "extensions/browser/info_map.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 #include "net/ssl/client_cert_store_win.h" 132 #include "net/ssl/client_cert_store_win.h"
129 #endif 133 #endif
130 134
131 #if defined(OS_MACOSX) 135 #if defined(OS_MACOSX)
132 #include "net/ssl/client_cert_store_mac.h" 136 #include "net/ssl/client_cert_store_mac.h"
133 #endif 137 #endif
134 138
135 using content::BrowserContext; 139 using content::BrowserContext;
136 using content::BrowserThread; 140 using content::BrowserThread;
137 using content::ResourceContext; 141 using content::ResourceContext;
142 using data_reduction_proxy::DataReductionProxyParams;
143 using data_reduction_proxy::DataReductionProxySettings;
138 using data_reduction_proxy::DataReductionProxyUsageStats; 144 using data_reduction_proxy::DataReductionProxyUsageStats;
139 145
140 namespace { 146 namespace {
141 147
142 #if defined(DEBUG_DEVTOOLS) 148 #if defined(DEBUG_DEVTOOLS)
143 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { 149 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
144 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); 150 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
145 bundled_path_prefix = "/" + bundled_path_prefix + "/"; 151 bundled_path_prefix = "/" + bundled_path_prefix + "/";
146 152
147 if (!url.SchemeIs(content::kChromeDevToolsScheme) || 153 if (!url.SchemeIs(content::kChromeDevToolsScheme) ||
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 486 }
481 } 487 }
482 #endif 488 #endif
483 489
484 incognito_availibility_pref_.Init( 490 incognito_availibility_pref_.Init(
485 prefs::kIncognitoModeAvailability, pref_service); 491 prefs::kIncognitoModeAvailability, pref_service);
486 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); 492 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy);
487 493
488 initialized_on_UI_thread_ = true; 494 initialized_on_UI_thread_ = true;
489 495
490 #if defined(OS_ANDROID)
491 #if defined(SPDY_PROXY_AUTH_ORIGIN)
492 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 496 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
493 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread, 497 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread,
494 base::Unretained(this), g_browser_process->io_thread(), profile)); 498 base::Unretained(this), g_browser_process->io_thread(), profile));
495 #endif
496 #endif
497 499
498 // We need to make sure that content initializes its own data structures that 500 // We need to make sure that content initializes its own data structures that
499 // are associated with each ResourceContext because we might post this 501 // are associated with each ResourceContext because we might post this
500 // object to the IO thread after this function. 502 // object to the IO thread after this function.
501 BrowserContext::EnsureResourceContextInitialized(profile); 503 BrowserContext::EnsureResourceContextInitialized(profile);
502 } 504 }
503 505
504 #if defined(OS_ANDROID)
505 #if defined(SPDY_PROXY_AUTH_ORIGIN)
506 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread( 506 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread(
507 IOThread* io_thread, Profile* profile) { 507 IOThread* io_thread, Profile* profile) {
508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
509 IOThread::Globals* globals = io_thread->globals(); 509 IOThread::Globals* globals = io_thread->globals();
510 DataReductionProxyParams* params = globals->data_reduction_proxy_params.get();
510 DataReductionProxyUsageStats* usage_stats = 511 DataReductionProxyUsageStats* usage_stats =
511 globals->data_reduction_proxy_usage_stats.get(); 512 globals->data_reduction_proxy_usage_stats.get();
512 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 513 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
513 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread, 514 base::Bind(&ProfileIOData::SetupDataReductionProxyOnUIThread,
514 base::Unretained(this), profile, usage_stats)); 515 base::Unretained(this), profile, params, usage_stats));
515 } 516 }
516 517
517 void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread( 518 void ProfileIOData::SetupDataReductionProxyOnUIThread(
518 Profile* profile, 519 Profile* profile,
520 DataReductionProxyParams* params,
519 DataReductionProxyUsageStats* usage_stats) { 521 DataReductionProxyUsageStats* usage_stats) {
520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
521 if (g_browser_process->profile_manager()->IsValidProfile(profile)) { 523 if (g_browser_process->profile_manager()->IsValidProfile(profile)) {
524 // TODO(kundaji): Combine code to initialize DRP on different platforms.
525 #if defined(OS_ANDROID)
522 DataReductionProxySettingsAndroid* proxySettingsAndroid = 526 DataReductionProxySettingsAndroid* proxySettingsAndroid =
523 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile); 527 DataReductionProxySettingsFactoryAndroid::GetForBrowserContext(profile);
524 if (proxySettingsAndroid) 528 if (proxySettingsAndroid)
525 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats); 529 proxySettingsAndroid->SetDataReductionProxyUsageStats(usage_stats);
530 #elif !defined(OS_IOS)
531 DataReductionProxySettings* proxySettings =
bengr 2014/07/15 16:38:16 proxy_settings
Not at Google. Contact bengr 2014/07/16 22:41:34 Done.
532 new DataReductionProxySettings(params);
533 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.
534 PrefService* prefs = profile->GetPrefs();
535 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
536 configurator(new DataReductionProxyChromeConfigurator(prefs));
537 proxySettings->SetProxyConfigurator(configurator.Pass());
538 proxySettings->InitDataReductionProxySettings(prefs,
539 g_browser_process->local_state(),
540 ProfileManager::GetActiveUserProfile()->GetRequestContext());
541 #endif
526 } 542 }
527 } 543 }
528 #endif
529 #endif
530 544
531 ProfileIOData::MediaRequestContext::MediaRequestContext() { 545 ProfileIOData::MediaRequestContext::MediaRequestContext() {
532 } 546 }
533 547
534 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( 548 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory(
535 scoped_ptr<net::HttpTransactionFactory> http_factory) { 549 scoped_ptr<net::HttpTransactionFactory> http_factory) {
536 http_factory_ = http_factory.Pass(); 550 http_factory_ = http_factory.Pass();
537 set_http_transaction_factory(http_factory_.get()); 551 set_http_transaction_factory(http_factory_.get());
538 } 552 }
539 553
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 void ProfileIOData::SetCookieSettingsForTesting( 1265 void ProfileIOData::SetCookieSettingsForTesting(
1252 CookieSettings* cookie_settings) { 1266 CookieSettings* cookie_settings) {
1253 DCHECK(!cookie_settings_.get()); 1267 DCHECK(!cookie_settings_.get());
1254 cookie_settings_ = cookie_settings; 1268 cookie_settings_ = cookie_settings;
1255 } 1269 }
1256 1270
1257 void ProfileIOData::set_signin_names_for_testing( 1271 void ProfileIOData::set_signin_names_for_testing(
1258 SigninNamesOnIOThread* signin_names) { 1272 SigninNamesOnIOThread* signin_names) {
1259 signin_names_.reset(signin_names); 1273 signin_names_.reset(signin_names);
1260 } 1274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698