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" |
11 #include "base/prefs/pref_member.h" | 11 #include "base/prefs/pref_member.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "base/threading/worker_pool.h" | 17 #include "base/threading/worker_pool.h" |
18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
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/spdyproxy/data_reduction_proxy_chrome_configurator.
h" | 29 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" |
| 30 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
30 #include "chrome/browser/net/sqlite_channel_id_store.h" | 31 #include "chrome/browser/net/sqlite_channel_id_store.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" |
| 39 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" |
| 40 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" |
36 #include "components/domain_reliability/monitor.h" | 41 #include "components/domain_reliability/monitor.h" |
37 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/cookie_store_factory.h" | 43 #include "content/public/browser/cookie_store_factory.h" |
39 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/resource_context.h" | 45 #include "content/public/browser/resource_context.h" |
41 #include "content/public/browser/storage_partition.h" | 46 #include "content/public/browser/storage_partition.h" |
42 #include "extensions/browser/extension_protocols.h" | 47 #include "extensions/browser/extension_protocols.h" |
43 #include "extensions/common/constants.h" | 48 #include "extensions/common/constants.h" |
44 #include "net/base/cache_type.h" | 49 #include "net/base/cache_type.h" |
45 #include "net/base/sdch_dictionary_fetcher.h" | 50 #include "net/base/sdch_dictionary_fetcher.h" |
46 #include "net/base/sdch_manager.h" | 51 #include "net/base/sdch_manager.h" |
47 #include "net/ftp/ftp_network_layer.h" | 52 #include "net/ftp/ftp_network_layer.h" |
48 #include "net/http/http_cache.h" | 53 #include "net/http/http_cache.h" |
49 #include "net/http/http_server_properties_manager.h" | 54 #include "net/http/http_server_properties_manager.h" |
50 #include "net/ssl/channel_id_service.h" | 55 #include "net/ssl/channel_id_service.h" |
51 #include "net/url_request/url_request_job_factory_impl.h" | 56 #include "net/url_request/url_request_job_factory_impl.h" |
52 #include "webkit/browser/quota/special_storage_policy.h" | 57 #include "webkit/browser/quota/special_storage_policy.h" |
53 | 58 |
54 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
55 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
56 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | |
57 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" | |
58 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" | |
59 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" | |
60 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
61 | |
62 namespace { | 59 namespace { |
63 | 60 |
64 net::BackendType ChooseCacheBackendType() { | 61 net::BackendType ChooseCacheBackendType() { |
65 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
66 return net::CACHE_BACKEND_SIMPLE; | 63 return net::CACHE_BACKEND_SIMPLE; |
67 #else | 64 #else |
68 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 65 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
69 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { | 66 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { |
70 const std::string opt_value = | 67 const std::string opt_value = |
71 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); | 68 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); |
72 if (LowerCaseEqualsASCII(opt_value, "off")) | 69 if (LowerCaseEqualsASCII(opt_value, "off")) |
73 return net::CACHE_BACKEND_BLOCKFILE; | 70 return net::CACHE_BACKEND_BLOCKFILE; |
74 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) | 71 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) |
75 return net::CACHE_BACKEND_SIMPLE; | 72 return net::CACHE_BACKEND_SIMPLE; |
76 } | 73 } |
77 const std::string experiment_name = | 74 const std::string experiment_name = |
78 base::FieldTrialList::FindFullName("SimpleCacheTrial"); | 75 base::FieldTrialList::FindFullName("SimpleCacheTrial"); |
79 if (experiment_name == "ExperimentYes" || | 76 if (experiment_name == "ExperimentYes" || |
80 experiment_name == "ExperimentYes2") { | 77 experiment_name == "ExperimentYes2") { |
81 return net::CACHE_BACKEND_SIMPLE; | 78 return net::CACHE_BACKEND_SIMPLE; |
82 } | 79 } |
83 return net::CACHE_BACKEND_BLOCKFILE; | 80 return net::CACHE_BACKEND_BLOCKFILE; |
84 #endif | 81 #endif |
85 } | 82 } |
86 | 83 |
87 } // namespace | 84 } // namespace |
88 | 85 |
89 using content::BrowserThread; | 86 using content::BrowserThread; |
90 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
91 using data_reduction_proxy::DataReductionProxyParams; | 87 using data_reduction_proxy::DataReductionProxyParams; |
92 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
93 | 88 |
94 ProfileImplIOData::Handle::Handle(Profile* profile) | 89 ProfileImplIOData::Handle::Handle(Profile* profile) |
95 : io_data_(new ProfileImplIOData), | 90 : io_data_(new ProfileImplIOData), |
96 profile_(profile), | 91 profile_(profile), |
97 initialized_(false) { | 92 initialized_(false) { |
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
99 DCHECK(profile); | 94 DCHECK(profile); |
100 } | 95 } |
101 | 96 |
102 ProfileImplIOData::Handle::~Handle() { | 97 ProfileImplIOData::Handle::~Handle() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 io_data_->app_cache_max_size_ = cache_max_size; | 162 io_data_->app_cache_max_size_ = cache_max_size; |
168 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 163 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
169 | 164 |
170 io_data_->predictor_.reset(predictor); | 165 io_data_->predictor_.reset(predictor); |
171 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); | 166 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); |
172 | 167 |
173 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 168 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
174 if (io_data_->domain_reliability_monitor_) | 169 if (io_data_->domain_reliability_monitor_) |
175 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); | 170 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); |
176 | 171 |
177 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
178 io_data_->data_reduction_proxy_unavailable_callback_ = | 172 io_data_->data_reduction_proxy_unavailable_callback_ = |
179 data_reduction_proxy_unavailable; | 173 data_reduction_proxy_unavailable; |
180 io_data_->data_reduction_proxy_chrome_configurator_ = | 174 io_data_->data_reduction_proxy_chrome_configurator_ = |
181 data_reduction_proxy_chrome_configurator.Pass(); | 175 data_reduction_proxy_chrome_configurator.Pass(); |
182 io_data_->data_reduction_proxy_params_ = | 176 io_data_->data_reduction_proxy_params_ = |
183 data_reduction_proxy_params.Pass(); | 177 data_reduction_proxy_params.Pass(); |
184 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
185 } | 178 } |
186 | 179 |
187 content::ResourceContext* | 180 content::ResourceContext* |
188 ProfileImplIOData::Handle::GetResourceContext() const { | 181 ProfileImplIOData::Handle::GetResourceContext() const { |
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
190 LazyInitialize(); | 183 LazyInitialize(); |
191 return GetResourceContextNoInit(); | 184 return GetResourceContextNoInit(); |
192 } | 185 } |
193 | 186 |
194 content::ResourceContext* | 187 content::ResourceContext* |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 io_data_->session_startup_pref()->Init( | 346 io_data_->session_startup_pref()->Init( |
354 prefs::kRestoreOnStartup, pref_service); | 347 prefs::kRestoreOnStartup, pref_service); |
355 io_data_->session_startup_pref()->MoveToThread( | 348 io_data_->session_startup_pref()->MoveToThread( |
356 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 349 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
357 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 350 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
358 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 351 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
359 pref_service); | 352 pref_service); |
360 io_data_->safe_browsing_enabled()->MoveToThread( | 353 io_data_->safe_browsing_enabled()->MoveToThread( |
361 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 354 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
362 #endif | 355 #endif |
363 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
364 io_data_->data_reduction_proxy_enabled()->Init( | 356 io_data_->data_reduction_proxy_enabled()->Init( |
365 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); | 357 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); |
366 io_data_->data_reduction_proxy_enabled()->MoveToThread( | 358 io_data_->data_reduction_proxy_enabled()->MoveToThread( |
367 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 359 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
368 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
369 io_data_->InitializeOnUIThread(profile_); | 360 io_data_->InitializeOnUIThread(profile_); |
370 } | 361 } |
371 | 362 |
372 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> | 363 scoped_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> |
373 ProfileImplIOData::Handle::GetAllContextGetters() { | 364 ProfileImplIOData::Handle::GetAllContextGetters() { |
374 ChromeURLRequestContextGetterMap::iterator iter; | 365 ChromeURLRequestContextGetterMap::iterator iter; |
375 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters( | 366 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters( |
376 new ChromeURLRequestContextGetterVector()); | 367 new ChromeURLRequestContextGetterVector()); |
377 | 368 |
378 iter = isolated_media_request_context_getter_map_.begin(); | 369 iter = isolated_media_request_context_getter_map_.begin(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 413 |
423 void ProfileImplIOData::InitializeInternal( | 414 void ProfileImplIOData::InitializeInternal( |
424 ProfileParams* profile_params, | 415 ProfileParams* profile_params, |
425 content::ProtocolHandlerMap* protocol_handlers, | 416 content::ProtocolHandlerMap* protocol_handlers, |
426 content::URLRequestInterceptorScopedVector request_interceptors) const { | 417 content::URLRequestInterceptorScopedVector request_interceptors) const { |
427 net::URLRequestContext* main_context = main_request_context(); | 418 net::URLRequestContext* main_context = main_request_context(); |
428 | 419 |
429 IOThread* const io_thread = profile_params->io_thread; | 420 IOThread* const io_thread = profile_params->io_thread; |
430 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 421 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
431 | 422 |
432 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
433 data_reduction_proxy_auth_request_handler_.reset( | 423 data_reduction_proxy_auth_request_handler_.reset( |
434 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | 424 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
435 DataReductionProxyChromeSettings::GetClient(), | 425 DataReductionProxyChromeSettings::GetClient(), |
436 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), | 426 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), |
437 data_reduction_proxy_params_.get(), | 427 data_reduction_proxy_params_.get(), |
438 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 428 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
439 data_reduction_proxy_usage_stats_.reset( | 429 data_reduction_proxy_usage_stats_.reset( |
440 new data_reduction_proxy::DataReductionProxyUsageStats( | 430 new data_reduction_proxy::DataReductionProxyUsageStats( |
441 data_reduction_proxy_params_.get(), | 431 data_reduction_proxy_params_.get(), |
442 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | 432 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); |
443 data_reduction_proxy_usage_stats_->set_unavailable_callback( | 433 data_reduction_proxy_usage_stats_->set_unavailable_callback( |
444 data_reduction_proxy_unavailable_callback_); | 434 data_reduction_proxy_unavailable_callback_); |
445 | 435 |
446 | |
447 network_delegate()->set_data_reduction_proxy_params( | 436 network_delegate()->set_data_reduction_proxy_params( |
448 data_reduction_proxy_params_.get()); | 437 data_reduction_proxy_params_.get()); |
449 network_delegate()->set_data_reduction_proxy_usage_stats( | 438 network_delegate()->set_data_reduction_proxy_usage_stats( |
450 data_reduction_proxy_usage_stats_.get()); | 439 data_reduction_proxy_usage_stats_.get()); |
451 network_delegate()->set_data_reduction_proxy_auth_request_handler( | 440 network_delegate()->set_data_reduction_proxy_auth_request_handler( |
452 data_reduction_proxy_auth_request_handler_.get()); | 441 data_reduction_proxy_auth_request_handler_.get()); |
453 network_delegate()->set_on_resolve_proxy_handler( | 442 network_delegate()->set_on_resolve_proxy_handler( |
454 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | 443 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); |
455 network_delegate()->set_proxy_config_getter( | 444 network_delegate()->set_proxy_config_getter( |
456 base::Bind( | 445 base::Bind( |
457 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO, | 446 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO, |
458 base::Unretained(data_reduction_proxy_chrome_configurator_.get()))); | 447 base::Unretained(data_reduction_proxy_chrome_configurator_.get()))); |
459 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
460 | 448 |
461 network_delegate()->set_predictor(predictor_.get()); | 449 network_delegate()->set_predictor(predictor_.get()); |
462 | 450 |
463 // Initialize context members. | 451 // Initialize context members. |
464 | 452 |
465 ApplyProfileParamsToContext(main_context); | 453 ApplyProfileParamsToContext(main_context); |
466 | 454 |
467 if (http_server_properties_manager_) | 455 if (http_server_properties_manager_) |
468 http_server_properties_manager_->InitializeOnNetworkThread(); | 456 http_server_properties_manager_->InitializeOnNetworkThread(); |
469 | 457 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 const base::Closure& completion) { | 823 const base::Closure& completion) { |
836 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 824 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
837 DCHECK(initialized()); | 825 DCHECK(initialized()); |
838 | 826 |
839 DCHECK(transport_security_state()); | 827 DCHECK(transport_security_state()); |
840 // Completes synchronously. | 828 // Completes synchronously. |
841 transport_security_state()->DeleteAllDynamicDataSince(time); | 829 transport_security_state()->DeleteAllDynamicDataSince(time); |
842 DCHECK(http_server_properties_manager_); | 830 DCHECK(http_server_properties_manager_); |
843 http_server_properties_manager_->Clear(completion); | 831 http_server_properties_manager_->Clear(completion); |
844 } | 832 } |
OLD | NEW |