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

Side by Side Diff: chrome/browser/profiles/profile_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: nit Created 6 years, 4 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 #include "net/ssl/client_cert_store_win.h" 136 #include "net/ssl/client_cert_store_win.h"
137 #endif 137 #endif
138 138
139 #if defined(OS_MACOSX) 139 #if defined(OS_MACOSX)
140 #include "net/ssl/client_cert_store_mac.h" 140 #include "net/ssl/client_cert_store_mac.h"
141 #endif 141 #endif
142 142
143 using content::BrowserContext; 143 using content::BrowserContext;
144 using content::BrowserThread; 144 using content::BrowserThread;
145 using content::ResourceContext; 145 using content::ResourceContext;
146 using data_reduction_proxy::DataReductionProxyUsageStats;
147 146
148 namespace { 147 namespace {
149 148
150 #if defined(DEBUG_DEVTOOLS) 149 #if defined(DEBUG_DEVTOOLS)
151 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { 150 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
152 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); 151 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
153 bundled_path_prefix = "/" + bundled_path_prefix + "/"; 152 bundled_path_prefix = "/" + bundled_path_prefix + "/";
154 153
155 if (!url.SchemeIs(content::kChromeDevToolsScheme) || 154 if (!url.SchemeIs(content::kChromeDevToolsScheme) ||
156 url.host() != chrome::kChromeUIDevToolsHost || 155 url.host() != chrome::kChromeUIDevToolsHost ||
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 497 }
499 } 498 }
500 #endif 499 #endif
501 500
502 incognito_availibility_pref_.Init( 501 incognito_availibility_pref_.Init(
503 prefs::kIncognitoModeAvailability, pref_service); 502 prefs::kIncognitoModeAvailability, pref_service);
504 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); 503 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy);
505 504
506 initialized_on_UI_thread_ = true; 505 initialized_on_UI_thread_ = true;
507 506
508 #if defined(OS_ANDROID)
509 #if defined(SPDY_PROXY_AUTH_ORIGIN)
510 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
511 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread,
512 base::Unretained(this), g_browser_process->io_thread(), profile));
513 #endif
514 #endif
515
516 // We need to make sure that content initializes its own data structures that 507 // We need to make sure that content initializes its own data structures that
517 // are associated with each ResourceContext because we might post this 508 // are associated with each ResourceContext because we might post this
518 // object to the IO thread after this function. 509 // object to the IO thread after this function.
519 BrowserContext::EnsureResourceContextInitialized(profile); 510 BrowserContext::EnsureResourceContextInitialized(profile);
520 } 511 }
521 512
522 #if defined(OS_ANDROID)
523 #if defined(SPDY_PROXY_AUTH_ORIGIN)
524 void ProfileIOData::SetDataReductionProxyUsageStatsOnIOThread(
525 IOThread* io_thread, Profile* profile) {
526 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
527 IOThread::Globals* globals = io_thread->globals();
528 DataReductionProxyUsageStats* usage_stats =
529 globals->data_reduction_proxy_usage_stats.get();
530 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
531 base::Bind(&ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread,
532 base::Unretained(this), profile, usage_stats));
533 }
534
535 void ProfileIOData::SetDataReductionProxyUsageStatsOnUIThread(
536 Profile* profile,
537 DataReductionProxyUsageStats* usage_stats) {
538 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
539 if (g_browser_process->profile_manager()->IsValidProfile(profile)) {
540 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings =
541 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile);
542 if (data_reduction_proxy_chrome_settings) {
543 data_reduction_proxy_chrome_settings->SetDataReductionProxyUsageStats(
544 usage_stats);
545 }
546 }
547 }
548 #endif
549 #endif
550
551 ProfileIOData::MediaRequestContext::MediaRequestContext() { 513 ProfileIOData::MediaRequestContext::MediaRequestContext() {
552 } 514 }
553 515
554 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory( 516 void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory(
555 scoped_ptr<net::HttpTransactionFactory> http_factory) { 517 scoped_ptr<net::HttpTransactionFactory> http_factory) {
556 http_factory_ = http_factory.Pass(); 518 http_factory_ = http_factory.Pass();
557 set_http_transaction_factory(http_factory_.get()); 519 set_http_transaction_factory(http_factory_.get());
558 } 520 }
559 521
560 ProfileIOData::MediaRequestContext::~MediaRequestContext() { 522 ProfileIOData::MediaRequestContext::~MediaRequestContext() {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 833 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
872 #if defined(OS_CHROMEOS) 834 #if defined(OS_CHROMEOS)
873 return enable_metrics_; 835 return enable_metrics_;
874 #else 836 #else
875 return enable_metrics_.GetValue(); 837 return enable_metrics_.GetValue();
876 #endif // defined(OS_CHROMEOS) 838 #endif // defined(OS_CHROMEOS)
877 } 839 }
878 840
879 #if defined(OS_ANDROID) 841 #if defined(OS_ANDROID)
880 bool ProfileIOData::IsDataReductionProxyEnabled() const { 842 bool ProfileIOData::IsDataReductionProxyEnabled() const {
843 #if defined(SPDY_PROXY_AUTH_ORIGIN)
881 return data_reduction_proxy_enabled_.GetValue() || 844 return data_reduction_proxy_enabled_.GetValue() ||
882 CommandLine::ForCurrentProcess()->HasSwitch( 845 CommandLine::ForCurrentProcess()->HasSwitch(
883 data_reduction_proxy::switches::kEnableDataReductionProxy); 846 data_reduction_proxy::switches::kEnableDataReductionProxy);
847 #else
848 return false;
849 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
884 } 850 }
885 #endif 851 #endif
886 852
887 base::WeakPtr<net::HttpServerProperties> 853 base::WeakPtr<net::HttpServerProperties>
888 ProfileIOData::http_server_properties() const { 854 ProfileIOData::http_server_properties() const {
889 return http_server_properties_->GetWeakPtr(); 855 return http_server_properties_->GetWeakPtr();
890 } 856 }
891 857
892 void ProfileIOData::set_http_server_properties( 858 void ProfileIOData::set_http_server_properties(
893 scoped_ptr<net::HttpServerProperties> http_server_properties) const { 859 scoped_ptr<net::HttpServerProperties> http_server_properties) const {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 extensions_request_context_.reset(new net::URLRequestContext()); 1000 extensions_request_context_.reset(new net::URLRequestContext());
1035 1001
1036 ChromeNetworkDelegate* network_delegate = 1002 ChromeNetworkDelegate* network_delegate =
1037 new ChromeNetworkDelegate( 1003 new ChromeNetworkDelegate(
1038 #if defined(ENABLE_EXTENSIONS) 1004 #if defined(ENABLE_EXTENSIONS)
1039 io_thread_globals->extension_event_router_forwarder.get(), 1005 io_thread_globals->extension_event_router_forwarder.get(),
1040 #else 1006 #else
1041 NULL, 1007 NULL,
1042 #endif 1008 #endif
1043 &enable_referrers_); 1009 &enable_referrers_);
1044 network_delegate->set_data_reduction_proxy_params(
1045 io_thread_globals->data_reduction_proxy_params.get());
1046 network_delegate->set_data_reduction_proxy_usage_stats(
1047 io_thread_globals->data_reduction_proxy_usage_stats.get());
1048 network_delegate->set_data_reduction_proxy_auth_request_handler(
1049 io_thread_globals->data_reduction_proxy_auth_request_handler.get());
1050 network_delegate->set_on_resolve_proxy_handler(
1051 io_thread_globals->on_resolve_proxy_handler);
1052 if (command_line.HasSwitch(switches::kEnableClientHints)) 1010 if (command_line.HasSwitch(switches::kEnableClientHints))
1053 network_delegate->SetEnableClientHints(); 1011 network_delegate->SetEnableClientHints();
1054 #if defined(ENABLE_EXTENSIONS) 1012 #if defined(ENABLE_EXTENSIONS)
1055 network_delegate->set_extension_info_map( 1013 network_delegate->set_extension_info_map(
1056 profile_params_->extension_info_map.get()); 1014 profile_params_->extension_info_map.get());
1057 #endif 1015 #endif
1058 #if defined(ENABLE_CONFIGURATION_POLICY) 1016 #if defined(ENABLE_CONFIGURATION_POLICY)
1059 network_delegate->set_url_blacklist_manager(url_blacklist_manager_.get()); 1017 network_delegate->set_url_blacklist_manager(url_blacklist_manager_.get());
1060 #endif 1018 #endif
1061 network_delegate->set_profile(profile_params_->profile); 1019 network_delegate->set_profile(profile_params_->profile);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 void ProfileIOData::SetCookieSettingsForTesting( 1274 void ProfileIOData::SetCookieSettingsForTesting(
1317 CookieSettings* cookie_settings) { 1275 CookieSettings* cookie_settings) {
1318 DCHECK(!cookie_settings_.get()); 1276 DCHECK(!cookie_settings_.get());
1319 cookie_settings_ = cookie_settings; 1277 cookie_settings_ = cookie_settings;
1320 } 1278 }
1321 1279
1322 void ProfileIOData::set_signin_names_for_testing( 1280 void ProfileIOData::set_signin_names_for_testing(
1323 SigninNamesOnIOThread* signin_names) { 1281 SigninNamesOnIOThread* signin_names) {
1324 signin_names_.reset(signin_names); 1282 signin_names_.reset(signin_names);
1325 } 1283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698