OLD | NEW |
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_impl_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 21 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
22 #include "chrome/browser/io_thread.h" | 22 #include "chrome/browser/io_thread.h" |
23 #include "chrome/browser/net/chrome_net_log.h" | 23 #include "chrome/browser/net/chrome_net_log.h" |
24 #include "chrome/browser/net/chrome_network_delegate.h" | 24 #include "chrome/browser/net/chrome_network_delegate.h" |
25 #include "chrome/browser/net/connect_interceptor.h" | 25 #include "chrome/browser/net/connect_interceptor.h" |
26 #include "chrome/browser/net/cookie_store_util.h" | 26 #include "chrome/browser/net/cookie_store_util.h" |
27 #include "chrome/browser/net/http_server_properties_manager_factory.h" | 27 #include "chrome/browser/net/http_server_properties_manager_factory.h" |
28 #include "chrome/browser/net/predictor.h" | 28 #include "chrome/browser/net/predictor.h" |
29 #include "chrome/browser/net/quota_policy_channel_id_store.h" | 29 #include "chrome/browser/net/quota_policy_channel_id_store.h" |
30 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" | 30 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" |
| 31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
31 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
| 37 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
| 38 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
36 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic
s_prefs.h" | 39 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic
s_prefs.h" |
| 40 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" |
| 41 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" |
37 #include "components/domain_reliability/monitor.h" | 42 #include "components/domain_reliability/monitor.h" |
38 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
39 #include "content/public/browser/cookie_store_factory.h" | 44 #include "content/public/browser/cookie_store_factory.h" |
40 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
41 #include "content/public/browser/resource_context.h" | 46 #include "content/public/browser/resource_context.h" |
42 #include "content/public/browser/storage_partition.h" | 47 #include "content/public/browser/storage_partition.h" |
43 #include "extensions/browser/extension_protocols.h" | 48 #include "extensions/browser/extension_protocols.h" |
44 #include "extensions/common/constants.h" | 49 #include "extensions/common/constants.h" |
45 #include "net/base/cache_type.h" | 50 #include "net/base/cache_type.h" |
46 #include "net/base/sdch_dictionary_fetcher.h" | 51 #include "net/base/sdch_dictionary_fetcher.h" |
47 #include "net/base/sdch_manager.h" | 52 #include "net/base/sdch_manager.h" |
48 #include "net/ftp/ftp_network_layer.h" | 53 #include "net/ftp/ftp_network_layer.h" |
49 #include "net/http/http_cache.h" | 54 #include "net/http/http_cache.h" |
50 #include "net/http/http_server_properties_manager.h" | 55 #include "net/http/http_server_properties_manager.h" |
51 #include "net/ssl/channel_id_service.h" | 56 #include "net/ssl/channel_id_service.h" |
52 #include "net/url_request/url_request_job_factory_impl.h" | 57 #include "net/url_request/url_request_job_factory_impl.h" |
53 #include "storage/browser/quota/special_storage_policy.h" | 58 #include "storage/browser/quota/special_storage_policy.h" |
54 | 59 |
55 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
56 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
57 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | |
58 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" | |
59 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" | |
60 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" | |
61 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
62 | |
63 namespace { | 60 namespace { |
64 | 61 |
65 net::BackendType ChooseCacheBackendType() { | 62 net::BackendType ChooseCacheBackendType() { |
66 #if defined(OS_ANDROID) | 63 #if defined(OS_ANDROID) |
67 return net::CACHE_BACKEND_SIMPLE; | 64 return net::CACHE_BACKEND_SIMPLE; |
68 #else | 65 #else |
69 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 66 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
70 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { | 67 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { |
71 const std::string opt_value = | 68 const std::string opt_value = |
72 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); | 69 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); |
73 if (LowerCaseEqualsASCII(opt_value, "off")) | 70 if (LowerCaseEqualsASCII(opt_value, "off")) |
74 return net::CACHE_BACKEND_BLOCKFILE; | 71 return net::CACHE_BACKEND_BLOCKFILE; |
75 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) | 72 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) |
76 return net::CACHE_BACKEND_SIMPLE; | 73 return net::CACHE_BACKEND_SIMPLE; |
77 } | 74 } |
78 const std::string experiment_name = | 75 const std::string experiment_name = |
79 base::FieldTrialList::FindFullName("SimpleCacheTrial"); | 76 base::FieldTrialList::FindFullName("SimpleCacheTrial"); |
80 if (experiment_name == "ExperimentYes" || | 77 if (experiment_name == "ExperimentYes" || |
81 experiment_name == "ExperimentYes2") { | 78 experiment_name == "ExperimentYes2") { |
82 return net::CACHE_BACKEND_SIMPLE; | 79 return net::CACHE_BACKEND_SIMPLE; |
83 } | 80 } |
84 return net::CACHE_BACKEND_BLOCKFILE; | 81 return net::CACHE_BACKEND_BLOCKFILE; |
85 #endif | 82 #endif |
86 } | 83 } |
87 | 84 |
88 } // namespace | 85 } // namespace |
89 | 86 |
90 using content::BrowserThread; | 87 using content::BrowserThread; |
91 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
92 using data_reduction_proxy::DataReductionProxyParams; | 88 using data_reduction_proxy::DataReductionProxyParams; |
93 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
94 | 89 |
95 ProfileImplIOData::Handle::Handle(Profile* profile) | 90 ProfileImplIOData::Handle::Handle(Profile* profile) |
96 : io_data_(new ProfileImplIOData), | 91 : io_data_(new ProfileImplIOData), |
97 profile_(profile), | 92 profile_(profile), |
98 initialized_(false) { | 93 initialized_(false) { |
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
100 DCHECK(profile); | 95 DCHECK(profile); |
101 } | 96 } |
102 | 97 |
103 ProfileImplIOData::Handle::~Handle() { | 98 ProfileImplIOData::Handle::~Handle() { |
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
105 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
106 io_data_->data_reduction_proxy_statistics_prefs()->WritePrefs(); | 100 io_data_->data_reduction_proxy_statistics_prefs()->WritePrefs(); |
107 #endif | |
108 | 101 |
109 if (io_data_->predictor_ != NULL) { | 102 if (io_data_->predictor_ != NULL) { |
110 // io_data_->predictor_ might be NULL if Init() was never called | 103 // io_data_->predictor_ might be NULL if Init() was never called |
111 // (i.e. we shut down before ProfileImpl::DoFinalInit() got called). | 104 // (i.e. we shut down before ProfileImpl::DoFinalInit() got called). |
112 bool save_prefs = true; | 105 bool save_prefs = true; |
113 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
114 save_prefs = !chromeos::ProfileHelper::IsSigninProfile(profile_); | 107 save_prefs = !chromeos::ProfileHelper::IsSigninProfile(profile_); |
115 #endif | 108 #endif |
116 if (save_prefs) | 109 if (save_prefs) |
117 io_data_->predictor_->SaveStateForNextStartupAndTrim(); | 110 io_data_->predictor_->SaveStateForNextStartupAndTrim(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 io_data_->app_cache_max_size_ = cache_max_size; | 167 io_data_->app_cache_max_size_ = cache_max_size; |
175 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 168 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
176 | 169 |
177 io_data_->predictor_.reset(predictor); | 170 io_data_->predictor_.reset(predictor); |
178 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); | 171 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); |
179 | 172 |
180 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 173 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
181 if (io_data_->domain_reliability_monitor_) | 174 if (io_data_->domain_reliability_monitor_) |
182 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); | 175 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); |
183 | 176 |
184 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
185 io_data_->set_data_reduction_proxy_unavailable_callback( | 177 io_data_->set_data_reduction_proxy_unavailable_callback( |
186 data_reduction_proxy_unavailable); | 178 data_reduction_proxy_unavailable); |
187 io_data_->set_data_reduction_proxy_chrome_configurator( | 179 io_data_->set_data_reduction_proxy_chrome_configurator( |
188 data_reduction_proxy_chrome_configurator.Pass()); | 180 data_reduction_proxy_chrome_configurator.Pass()); |
189 io_data_->set_data_reduction_proxy_params(data_reduction_proxy_params.Pass()); | 181 io_data_->set_data_reduction_proxy_params(data_reduction_proxy_params.Pass()); |
190 io_data_->set_data_reduction_proxy_statistics_prefs( | 182 io_data_->set_data_reduction_proxy_statistics_prefs( |
191 data_reduction_proxy_statistics_prefs.Pass()); | 183 data_reduction_proxy_statistics_prefs.Pass()); |
192 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
193 } | 184 } |
194 | 185 |
195 content::ResourceContext* | 186 content::ResourceContext* |
196 ProfileImplIOData::Handle::GetResourceContext() const { | 187 ProfileImplIOData::Handle::GetResourceContext() const { |
197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
198 LazyInitialize(); | 189 LazyInitialize(); |
199 return GetResourceContextNoInit(); | 190 return GetResourceContextNoInit(); |
200 } | 191 } |
201 | 192 |
202 content::ResourceContext* | 193 content::ResourceContext* |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 io_data_->session_startup_pref()->Init( | 352 io_data_->session_startup_pref()->Init( |
362 prefs::kRestoreOnStartup, pref_service); | 353 prefs::kRestoreOnStartup, pref_service); |
363 io_data_->session_startup_pref()->MoveToThread( | 354 io_data_->session_startup_pref()->MoveToThread( |
364 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 355 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
365 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 356 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
366 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 357 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
367 pref_service); | 358 pref_service); |
368 io_data_->safe_browsing_enabled()->MoveToThread( | 359 io_data_->safe_browsing_enabled()->MoveToThread( |
369 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 360 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
370 #endif | 361 #endif |
371 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
372 io_data_->data_reduction_proxy_enabled()->Init( | 362 io_data_->data_reduction_proxy_enabled()->Init( |
373 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); | 363 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); |
374 io_data_->data_reduction_proxy_enabled()->MoveToThread( | 364 io_data_->data_reduction_proxy_enabled()->MoveToThread( |
375 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 365 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
376 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
377 io_data_->InitializeOnUIThread(profile_); | 366 io_data_->InitializeOnUIThread(profile_); |
378 } | 367 } |
379 | 368 |
380 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> | 369 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> |
381 ProfileImplIOData::Handle::GetAllContextGetters() { | 370 ProfileImplIOData::Handle::GetAllContextGetters() { |
382 ChromeURLRequestContextGetterMap::iterator iter; | 371 ChromeURLRequestContextGetterMap::iterator iter; |
383 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters( | 372 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters( |
384 new ChromeURLRequestContextGetterVector()); | 373 new ChromeURLRequestContextGetterVector()); |
385 | 374 |
386 iter = isolated_media_request_context_getter_map_.begin(); | 375 iter = isolated_media_request_context_getter_map_.begin(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 | 419 |
431 void ProfileImplIOData::InitializeInternal( | 420 void ProfileImplIOData::InitializeInternal( |
432 ProfileParams* profile_params, | 421 ProfileParams* profile_params, |
433 content::ProtocolHandlerMap* protocol_handlers, | 422 content::ProtocolHandlerMap* protocol_handlers, |
434 content::URLRequestInterceptorScopedVector request_interceptors) const { | 423 content::URLRequestInterceptorScopedVector request_interceptors) const { |
435 net::URLRequestContext* main_context = main_request_context(); | 424 net::URLRequestContext* main_context = main_request_context(); |
436 | 425 |
437 IOThread* const io_thread = profile_params->io_thread; | 426 IOThread* const io_thread = profile_params->io_thread; |
438 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 427 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
439 | 428 |
440 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
441 set_data_reduction_proxy_auth_request_handler( | 429 set_data_reduction_proxy_auth_request_handler( |
442 scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler> | 430 scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler> |
443 (new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | 431 (new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
444 DataReductionProxyChromeSettings::GetClient(), | 432 DataReductionProxyChromeSettings::GetClient(), |
445 data_reduction_proxy_params(), | 433 data_reduction_proxy_params(), |
446 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)))); | 434 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)))); |
447 set_data_reduction_proxy_usage_stats( | 435 set_data_reduction_proxy_usage_stats( |
448 scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats> | 436 scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats> |
449 (new data_reduction_proxy::DataReductionProxyUsageStats( | 437 (new data_reduction_proxy::DataReductionProxyUsageStats( |
450 data_reduction_proxy_params(), | 438 data_reduction_proxy_params(), |
451 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI) | 439 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI) |
452 .get()))); | 440 .get()))); |
453 data_reduction_proxy_usage_stats()->set_unavailable_callback( | 441 data_reduction_proxy_usage_stats()->set_unavailable_callback( |
454 data_reduction_proxy_unavailable_callback()); | 442 data_reduction_proxy_unavailable_callback()); |
455 | 443 |
456 network_delegate()->set_data_reduction_proxy_params( | 444 network_delegate()->set_data_reduction_proxy_params( |
457 data_reduction_proxy_params()); | 445 data_reduction_proxy_params()); |
458 network_delegate()->set_data_reduction_proxy_usage_stats( | 446 network_delegate()->set_data_reduction_proxy_usage_stats( |
459 data_reduction_proxy_usage_stats()); | 447 data_reduction_proxy_usage_stats()); |
460 network_delegate()->set_data_reduction_proxy_auth_request_handler( | 448 network_delegate()->set_data_reduction_proxy_auth_request_handler( |
461 data_reduction_proxy_auth_request_handler()); | 449 data_reduction_proxy_auth_request_handler()); |
462 network_delegate()->set_data_reduction_proxy_statistics_prefs( | 450 network_delegate()->set_data_reduction_proxy_statistics_prefs( |
463 data_reduction_proxy_statistics_prefs()); | 451 data_reduction_proxy_statistics_prefs()); |
464 network_delegate()->set_on_resolve_proxy_handler( | 452 network_delegate()->set_on_resolve_proxy_handler( |
465 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | 453 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); |
466 network_delegate()->set_proxy_config_getter( | 454 network_delegate()->set_proxy_config_getter( |
467 base::Bind( | 455 base::Bind( |
468 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO, | 456 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO, |
469 base::Unretained(data_reduction_proxy_chrome_configurator()))); | 457 base::Unretained(data_reduction_proxy_chrome_configurator()))); |
470 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
471 | |
472 network_delegate()->set_predictor(predictor_.get()); | 458 network_delegate()->set_predictor(predictor_.get()); |
473 | 459 |
474 // Initialize context members. | 460 // Initialize context members. |
475 | 461 |
476 ApplyProfileParamsToContext(main_context); | 462 ApplyProfileParamsToContext(main_context); |
477 | 463 |
478 if (http_server_properties_manager_) | 464 if (http_server_properties_manager_) |
479 http_server_properties_manager_->InitializeOnNetworkThread(); | 465 http_server_properties_manager_->InitializeOnNetworkThread(); |
480 | 466 |
481 main_context->set_transport_security_state(transport_security_state()); | 467 main_context->set_transport_security_state(transport_security_state()); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 const base::Closure& completion) { | 825 const base::Closure& completion) { |
840 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 826 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
841 DCHECK(initialized()); | 827 DCHECK(initialized()); |
842 | 828 |
843 DCHECK(transport_security_state()); | 829 DCHECK(transport_security_state()); |
844 // Completes synchronously. | 830 // Completes synchronously. |
845 transport_security_state()->DeleteAllDynamicDataSince(time); | 831 transport_security_state()->DeleteAllDynamicDataSince(time); |
846 DCHECK(http_server_properties_manager_); | 832 DCHECK(http_server_properties_manager_); |
847 http_server_properties_manager_->Clear(completion); | 833 http_server_properties_manager_->Clear(completion); |
848 } | 834 } |
OLD | NEW |