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

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: 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 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #include "net/ssl/client_cert_store_win.h" 133 #include "net/ssl/client_cert_store_win.h"
130 #endif 134 #endif
131 135
132 #if defined(OS_MACOSX) 136 #if defined(OS_MACOSX)
133 #include "net/ssl/client_cert_store_mac.h" 137 #include "net/ssl/client_cert_store_mac.h"
134 #endif 138 #endif
135 139
136 using content::BrowserContext; 140 using content::BrowserContext;
137 using content::BrowserThread; 141 using content::BrowserThread;
138 using content::ResourceContext; 142 using content::ResourceContext;
143 using data_reduction_proxy::DataReductionProxyParams;
144 using data_reduction_proxy::DataReductionProxySettings;
139 using data_reduction_proxy::DataReductionProxyUsageStats; 145 using data_reduction_proxy::DataReductionProxyUsageStats;
140 146
141 namespace { 147 namespace {
142 148
143 #if defined(DEBUG_DEVTOOLS) 149 #if defined(DEBUG_DEVTOOLS)
144 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { 150 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
145 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); 151 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
146 bundled_path_prefix = "/" + bundled_path_prefix + "/"; 152 bundled_path_prefix = "/" + bundled_path_prefix + "/";
147 153
148 if (!url.SchemeIs(content::kChromeDevToolsScheme) || 154 if (!url.SchemeIs(content::kChromeDevToolsScheme) ||
(...skipping 331 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::SetupDataReductionProxyOnIOThread,
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) 506 void ProfileIOData::SetupDataReductionProxyOnIOThread(
505 #if defined(SPDY_PROXY_AUTH_ORIGIN)
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));
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.
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 data_reduction_proxy_settings_.reset(
532 new DataReductionProxySettings(params));
533 data_reduction_proxy_settings_->SetDataReductionProxyUsageStats(
534 usage_stats);
535 PrefService* prefs = profile->GetPrefs();
536 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
537 configurator(new DataReductionProxyChromeConfigurator(prefs));
538 data_reduction_proxy_settings_->SetProxyConfigurator(configurator.Pass());
539 data_reduction_proxy_settings_->InitDataReductionProxySettings(prefs,
540 g_browser_process->local_state(),
541 ProfileManager::GetActiveUserProfile()->GetRequestContext());
542 #endif
526 } 543 }
527 } 544 }
528 #endif
529 #endif
530 545
531 ProfileIOData::MediaRequestContext::MediaRequestContext() { 546 ProfileIOData::MediaRequestContext::MediaRequestContext() {
532 } 547 }
533 548
534 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( 549 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory(
535 scoped_ptr<net::HttpTransactionFactory> http_factory) { 550 scoped_ptr<net::HttpTransactionFactory> http_factory) {
536 http_factory_ = http_factory.Pass(); 551 http_factory_ = http_factory.Pass();
537 set_http_transaction_factory(http_factory_.get()); 552 set_http_transaction_factory(http_factory_.get());
538 } 553 }
539 554
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 // NOTE: Proxy service uses the default io thread network delegate, not the 1045 // NOTE: Proxy service uses the default io thread network delegate, not the
1031 // delegate just created. 1046 // delegate just created.
1032 proxy_service_.reset( 1047 proxy_service_.reset(
1033 ProxyServiceFactory::CreateProxyService( 1048 ProxyServiceFactory::CreateProxyService(
1034 io_thread->net_log(), 1049 io_thread->net_log(),
1035 io_thread_globals->proxy_script_fetcher_context.get(), 1050 io_thread_globals->proxy_script_fetcher_context.get(),
1036 io_thread_globals->system_network_delegate.get(), 1051 io_thread_globals->system_network_delegate.get(),
1037 profile_params_->proxy_config_service.release(), 1052 profile_params_->proxy_config_service.release(),
1038 command_line, 1053 command_line,
1039 quick_check_enabled_.GetValue())); 1054 quick_check_enabled_.GetValue()));
1055 DCHECK(io_thread_globals->data_reduction_proxy_params);
1056 proxy_service_->SetDataReductionProxyOrigins(
1057 io_thread_globals->data_reduction_proxy_params->GetDefaultOrigin(),
1058 io_thread_globals->data_reduction_proxy_params->
1059 GetDefaultFallbackOrigin());
1040 1060
1041 transport_security_state_.reset(new net::TransportSecurityState()); 1061 transport_security_state_.reset(new net::TransportSecurityState());
1042 transport_security_persister_.reset( 1062 transport_security_persister_.reset(
1043 new net::TransportSecurityPersister( 1063 new net::TransportSecurityPersister(
1044 transport_security_state_.get(), 1064 transport_security_state_.get(),
1045 profile_params_->path, 1065 profile_params_->path,
1046 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 1066 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
1047 IsOffTheRecord())); 1067 IsOffTheRecord()));
1048 1068
1049 // Take ownership over these parameters. 1069 // Take ownership over these parameters.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 void ProfileIOData::SetCookieSettingsForTesting( 1281 void ProfileIOData::SetCookieSettingsForTesting(
1262 CookieSettings* cookie_settings) { 1282 CookieSettings* cookie_settings) {
1263 DCHECK(!cookie_settings_.get()); 1283 DCHECK(!cookie_settings_.get());
1264 cookie_settings_ = cookie_settings; 1284 cookie_settings_ = cookie_settings;
1265 } 1285 }
1266 1286
1267 void ProfileIOData::set_signin_names_for_testing( 1287 void ProfileIOData::set_signin_names_for_testing(
1268 SigninNamesOnIOThread* signin_names) { 1288 SigninNamesOnIOThread* signin_names) {
1269 signin_names_.reset(signin_names); 1289 signin_names_.reset(signin_names);
1270 } 1290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698