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/chrome_version_info.h" | 35 #include "chrome/common/chrome_version_info.h" |
35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
36 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
| 39 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
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 "webkit/browser/quota/special_storage_policy.h" | 58 #include "webkit/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() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 io_data_->app_cache_max_size_ = cache_max_size; | 163 io_data_->app_cache_max_size_ = cache_max_size; |
169 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 164 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
170 | 165 |
171 io_data_->predictor_.reset(predictor); | 166 io_data_->predictor_.reset(predictor); |
172 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); | 167 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); |
173 | 168 |
174 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 169 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
175 if (io_data_->domain_reliability_monitor_) | 170 if (io_data_->domain_reliability_monitor_) |
176 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); | 171 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); |
177 | 172 |
178 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
179 io_data_->data_reduction_proxy_unavailable_callback_ = | 173 io_data_->data_reduction_proxy_unavailable_callback_ = |
180 data_reduction_proxy_unavailable; | 174 data_reduction_proxy_unavailable; |
181 io_data_->data_reduction_proxy_chrome_configurator_ = | 175 io_data_->data_reduction_proxy_chrome_configurator_ = |
182 data_reduction_proxy_chrome_configurator.Pass(); | 176 data_reduction_proxy_chrome_configurator.Pass(); |
183 io_data_->data_reduction_proxy_params_ = | 177 io_data_->data_reduction_proxy_params_ = |
184 data_reduction_proxy_params.Pass(); | 178 data_reduction_proxy_params.Pass(); |
185 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
186 } | 179 } |
187 | 180 |
188 content::ResourceContext* | 181 content::ResourceContext* |
189 ProfileImplIOData::Handle::GetResourceContext() const { | 182 ProfileImplIOData::Handle::GetResourceContext() const { |
190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
191 LazyInitialize(); | 184 LazyInitialize(); |
192 return GetResourceContextNoInit(); | 185 return GetResourceContextNoInit(); |
193 } | 186 } |
194 | 187 |
195 content::ResourceContext* | 188 content::ResourceContext* |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 io_data_->session_startup_pref()->Init( | 347 io_data_->session_startup_pref()->Init( |
355 prefs::kRestoreOnStartup, pref_service); | 348 prefs::kRestoreOnStartup, pref_service); |
356 io_data_->session_startup_pref()->MoveToThread( | 349 io_data_->session_startup_pref()->MoveToThread( |
357 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 350 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
358 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 351 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
359 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 352 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
360 pref_service); | 353 pref_service); |
361 io_data_->safe_browsing_enabled()->MoveToThread( | 354 io_data_->safe_browsing_enabled()->MoveToThread( |
362 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 355 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
363 #endif | 356 #endif |
364 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
365 io_data_->data_reduction_proxy_enabled()->Init( | 357 io_data_->data_reduction_proxy_enabled()->Init( |
366 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); | 358 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); |
367 io_data_->data_reduction_proxy_enabled()->MoveToThread( | 359 io_data_->data_reduction_proxy_enabled()->MoveToThread( |
368 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 360 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
369 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
370 io_data_->InitializeOnUIThread(profile_); | 361 io_data_->InitializeOnUIThread(profile_); |
371 } | 362 } |
372 | 363 |
373 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> | 364 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> |
374 ProfileImplIOData::Handle::GetAllContextGetters() { | 365 ProfileImplIOData::Handle::GetAllContextGetters() { |
375 ChromeURLRequestContextGetterMap::iterator iter; | 366 ChromeURLRequestContextGetterMap::iterator iter; |
376 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters( | 367 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters( |
377 new ChromeURLRequestContextGetterVector()); | 368 new ChromeURLRequestContextGetterVector()); |
378 | 369 |
379 iter = isolated_media_request_context_getter_map_.begin(); | 370 iter = isolated_media_request_context_getter_map_.begin(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 414 |
424 void ProfileImplIOData::InitializeInternal( | 415 void ProfileImplIOData::InitializeInternal( |
425 ProfileParams* profile_params, | 416 ProfileParams* profile_params, |
426 content::ProtocolHandlerMap* protocol_handlers, | 417 content::ProtocolHandlerMap* protocol_handlers, |
427 content::URLRequestInterceptorScopedVector request_interceptors) const { | 418 content::URLRequestInterceptorScopedVector request_interceptors) const { |
428 net::URLRequestContext* main_context = main_request_context(); | 419 net::URLRequestContext* main_context = main_request_context(); |
429 | 420 |
430 IOThread* const io_thread = profile_params->io_thread; | 421 IOThread* const io_thread = profile_params->io_thread; |
431 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 422 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
432 | 423 |
433 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
434 data_reduction_proxy_auth_request_handler_.reset( | 424 data_reduction_proxy_auth_request_handler_.reset( |
435 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | 425 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
436 DataReductionProxyChromeSettings::GetClient(), | 426 DataReductionProxyChromeSettings::GetClient(), |
437 chrome::VersionInfo().Version(), | 427 chrome::VersionInfo().Version(), |
438 data_reduction_proxy_params_.get(), | 428 data_reduction_proxy_params_.get(), |
439 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 429 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
440 data_reduction_proxy_usage_stats_.reset( | 430 data_reduction_proxy_usage_stats_.reset( |
441 new data_reduction_proxy::DataReductionProxyUsageStats( | 431 new data_reduction_proxy::DataReductionProxyUsageStats( |
442 data_reduction_proxy_params_.get(), | 432 data_reduction_proxy_params_.get(), |
443 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | 433 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); |
444 data_reduction_proxy_usage_stats_->set_unavailable_callback( | 434 data_reduction_proxy_usage_stats_->set_unavailable_callback( |
445 data_reduction_proxy_unavailable_callback_); | 435 data_reduction_proxy_unavailable_callback_); |
446 | 436 |
447 | |
448 network_delegate()->set_data_reduction_proxy_params( | 437 network_delegate()->set_data_reduction_proxy_params( |
449 data_reduction_proxy_params_.get()); | 438 data_reduction_proxy_params_.get()); |
450 network_delegate()->set_data_reduction_proxy_usage_stats( | 439 network_delegate()->set_data_reduction_proxy_usage_stats( |
451 data_reduction_proxy_usage_stats_.get()); | 440 data_reduction_proxy_usage_stats_.get()); |
452 network_delegate()->set_data_reduction_proxy_auth_request_handler( | 441 network_delegate()->set_data_reduction_proxy_auth_request_handler( |
453 data_reduction_proxy_auth_request_handler_.get()); | 442 data_reduction_proxy_auth_request_handler_.get()); |
454 network_delegate()->set_on_resolve_proxy_handler( | 443 network_delegate()->set_on_resolve_proxy_handler( |
455 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | 444 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); |
456 network_delegate()->set_proxy_config_getter( | 445 network_delegate()->set_proxy_config_getter( |
457 base::Bind( | 446 base::Bind( |
458 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO, | 447 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO, |
459 base::Unretained(data_reduction_proxy_chrome_configurator_.get()))); | 448 base::Unretained(data_reduction_proxy_chrome_configurator_.get()))); |
460 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
461 | 449 |
462 network_delegate()->set_predictor(predictor_.get()); | 450 network_delegate()->set_predictor(predictor_.get()); |
463 | 451 |
464 // Initialize context members. | 452 // Initialize context members. |
465 | 453 |
466 ApplyProfileParamsToContext(main_context); | 454 ApplyProfileParamsToContext(main_context); |
467 | 455 |
468 if (http_server_properties_manager_) | 456 if (http_server_properties_manager_) |
469 http_server_properties_manager_->InitializeOnNetworkThread(); | 457 http_server_properties_manager_->InitializeOnNetworkThread(); |
470 | 458 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 const base::Closure& completion) { | 824 const base::Closure& completion) { |
837 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 825 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
838 DCHECK(initialized()); | 826 DCHECK(initialized()); |
839 | 827 |
840 DCHECK(transport_security_state()); | 828 DCHECK(transport_security_state()); |
841 // Completes synchronously. | 829 // Completes synchronously. |
842 transport_security_state()->DeleteAllDynamicDataSince(time); | 830 transport_security_state()->DeleteAllDynamicDataSince(time); |
843 DCHECK(http_server_properties_manager_); | 831 DCHECK(http_server_properties_manager_); |
844 http_server_properties_manager_->Clear(completion); | 832 http_server_properties_manager_->Clear(completion); |
845 } | 833 } |
OLD | NEW |