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/sqlite_server_bound_cert_store.h" | 29 #include "chrome/browser/net/sqlite_channel_id_store.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
35 #include "components/domain_reliability/monitor.h" | 35 #include "components/domain_reliability/monitor.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/cookie_store_factory.h" | 37 #include "content/public/browser/cookie_store_factory.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/resource_context.h" | 39 #include "content/public/browser/resource_context.h" |
40 #include "content/public/browser/storage_partition.h" | 40 #include "content/public/browser/storage_partition.h" |
41 #include "extensions/browser/extension_protocols.h" | 41 #include "extensions/browser/extension_protocols.h" |
42 #include "extensions/common/constants.h" | 42 #include "extensions/common/constants.h" |
43 #include "net/base/cache_type.h" | 43 #include "net/base/cache_type.h" |
44 #include "net/base/sdch_dictionary_fetcher.h" | 44 #include "net/base/sdch_dictionary_fetcher.h" |
45 #include "net/base/sdch_manager.h" | 45 #include "net/base/sdch_manager.h" |
46 #include "net/ftp/ftp_network_layer.h" | 46 #include "net/ftp/ftp_network_layer.h" |
47 #include "net/http/http_cache.h" | 47 #include "net/http/http_cache.h" |
48 #include "net/http/http_server_properties_manager.h" | 48 #include "net/http/http_server_properties_manager.h" |
49 #include "net/ssl/server_bound_cert_service.h" | 49 #include "net/ssl/channel_id_service.h" |
50 #include "net/url_request/url_request_job_factory_impl.h" | 50 #include "net/url_request/url_request_job_factory_impl.h" |
51 #include "webkit/browser/quota/special_storage_policy.h" | 51 #include "webkit/browser/quota/special_storage_policy.h" |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 net::BackendType ChooseCacheBackendType() { | 55 net::BackendType ChooseCacheBackendType() { |
56 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
57 return net::CACHE_BACKEND_SIMPLE; | 57 return net::CACHE_BACKEND_SIMPLE; |
58 #else | 58 #else |
59 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 59 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 io_data_->predictor_->ShutdownOnUIThread(); | 101 io_data_->predictor_->ShutdownOnUIThread(); |
102 } | 102 } |
103 | 103 |
104 if (io_data_->http_server_properties_manager_) | 104 if (io_data_->http_server_properties_manager_) |
105 io_data_->http_server_properties_manager_->ShutdownOnPrefThread(); | 105 io_data_->http_server_properties_manager_->ShutdownOnPrefThread(); |
106 io_data_->ShutdownOnUIThread(); | 106 io_data_->ShutdownOnUIThread(); |
107 } | 107 } |
108 | 108 |
109 void ProfileImplIOData::Handle::Init( | 109 void ProfileImplIOData::Handle::Init( |
110 const base::FilePath& cookie_path, | 110 const base::FilePath& cookie_path, |
111 const base::FilePath& server_bound_cert_path, | 111 const base::FilePath& channel_id_path, |
112 const base::FilePath& cache_path, | 112 const base::FilePath& cache_path, |
113 int cache_max_size, | 113 int cache_max_size, |
114 const base::FilePath& media_cache_path, | 114 const base::FilePath& media_cache_path, |
115 int media_cache_max_size, | 115 int media_cache_max_size, |
116 const base::FilePath& extensions_cookie_path, | 116 const base::FilePath& extensions_cookie_path, |
117 const base::FilePath& profile_path, | 117 const base::FilePath& profile_path, |
118 const base::FilePath& infinite_cache_path, | 118 const base::FilePath& infinite_cache_path, |
119 chrome_browser_net::Predictor* predictor, | 119 chrome_browser_net::Predictor* predictor, |
120 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, | 120 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, |
121 quota::SpecialStoragePolicy* special_storage_policy, | 121 quota::SpecialStoragePolicy* special_storage_policy, |
122 scoped_ptr<domain_reliability::DomainReliabilityMonitor> | 122 scoped_ptr<domain_reliability::DomainReliabilityMonitor> |
123 domain_reliability_monitor) { | 123 domain_reliability_monitor) { |
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
125 DCHECK(!io_data_->lazy_params_); | 125 DCHECK(!io_data_->lazy_params_); |
126 DCHECK(predictor); | 126 DCHECK(predictor); |
127 | 127 |
128 LazyParams* lazy_params = new LazyParams(); | 128 LazyParams* lazy_params = new LazyParams(); |
129 | 129 |
130 lazy_params->cookie_path = cookie_path; | 130 lazy_params->cookie_path = cookie_path; |
131 lazy_params->server_bound_cert_path = server_bound_cert_path; | 131 lazy_params->channel_id_path = channel_id_path; |
132 lazy_params->cache_path = cache_path; | 132 lazy_params->cache_path = cache_path; |
133 lazy_params->cache_max_size = cache_max_size; | 133 lazy_params->cache_max_size = cache_max_size; |
134 lazy_params->media_cache_path = media_cache_path; | 134 lazy_params->media_cache_path = media_cache_path; |
135 lazy_params->media_cache_max_size = media_cache_max_size; | 135 lazy_params->media_cache_max_size = media_cache_max_size; |
136 lazy_params->extensions_cookie_path = extensions_cookie_path; | 136 lazy_params->extensions_cookie_path = extensions_cookie_path; |
137 lazy_params->infinite_cache_path = infinite_cache_path; | 137 lazy_params->infinite_cache_path = infinite_cache_path; |
138 lazy_params->session_cookie_mode = session_cookie_mode; | 138 lazy_params->session_cookie_mode = session_cookie_mode; |
139 lazy_params->special_storage_policy = special_storage_policy; | 139 lazy_params->special_storage_policy = special_storage_policy; |
140 | 140 |
141 io_data_->lazy_params_.reset(lazy_params); | 141 io_data_->lazy_params_.reset(lazy_params); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 main_context->set_fraudulent_certificate_reporter( | 398 main_context->set_fraudulent_certificate_reporter( |
399 fraudulent_certificate_reporter()); | 399 fraudulent_certificate_reporter()); |
400 | 400 |
401 main_context->set_throttler_manager( | 401 main_context->set_throttler_manager( |
402 io_thread_globals->throttler_manager.get()); | 402 io_thread_globals->throttler_manager.get()); |
403 | 403 |
404 main_context->set_proxy_service(proxy_service()); | 404 main_context->set_proxy_service(proxy_service()); |
405 | 405 |
406 scoped_refptr<net::CookieStore> cookie_store = NULL; | 406 scoped_refptr<net::CookieStore> cookie_store = NULL; |
407 net::ServerBoundCertService* server_bound_cert_service = NULL; | 407 net::ChannelIDService* channel_id_service = NULL; |
408 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { | 408 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
409 // Don't use existing cookies and use an in-memory store. | 409 // Don't use existing cookies and use an in-memory store. |
410 using content::CookieStoreConfig; | 410 using content::CookieStoreConfig; |
411 cookie_store = content::CreateCookieStore(CookieStoreConfig( | 411 cookie_store = content::CreateCookieStore(CookieStoreConfig( |
412 base::FilePath(), | 412 base::FilePath(), |
413 CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, | 413 CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
414 NULL, | 414 NULL, |
415 profile_params->cookie_monster_delegate.get())); | 415 profile_params->cookie_monster_delegate.get())); |
416 // Don't use existing server-bound certs and use an in-memory store. | 416 // Don't use existing channel ids and use an in-memory store. |
417 server_bound_cert_service = new net::ServerBoundCertService( | 417 channel_id_service = new net::ChannelIDService( |
418 new net::DefaultServerBoundCertStore(NULL), | 418 new net::DefaultChannelIDStore(NULL), |
419 base::WorkerPool::GetTaskRunner(true)); | 419 base::WorkerPool::GetTaskRunner(true)); |
420 } | 420 } |
421 | 421 |
422 | 422 |
423 // setup cookie store | 423 // setup cookie store |
424 if (!cookie_store.get()) { | 424 if (!cookie_store.get()) { |
425 DCHECK(!lazy_params_->cookie_path.empty()); | 425 DCHECK(!lazy_params_->cookie_path.empty()); |
426 | 426 |
427 content::CookieStoreConfig cookie_config( | 427 content::CookieStoreConfig cookie_config( |
428 lazy_params_->cookie_path, | 428 lazy_params_->cookie_path, |
429 lazy_params_->session_cookie_mode, | 429 lazy_params_->session_cookie_mode, |
430 lazy_params_->special_storage_policy.get(), | 430 lazy_params_->special_storage_policy.get(), |
431 profile_params->cookie_monster_delegate.get()); | 431 profile_params->cookie_monster_delegate.get()); |
432 cookie_config.crypto_delegate = | 432 cookie_config.crypto_delegate = |
433 chrome_browser_net::GetCookieCryptoDelegate(); | 433 chrome_browser_net::GetCookieCryptoDelegate(); |
434 cookie_store = content::CreateCookieStore(cookie_config); | 434 cookie_store = content::CreateCookieStore(cookie_config); |
435 } | 435 } |
436 | 436 |
437 main_context->set_cookie_store(cookie_store.get()); | 437 main_context->set_cookie_store(cookie_store.get()); |
438 | 438 |
439 // Setup server bound cert service. | 439 // Setup server bound cert service. |
440 if (!server_bound_cert_service) { | 440 if (!channel_id_service) { |
441 DCHECK(!lazy_params_->server_bound_cert_path.empty()); | 441 DCHECK(!lazy_params_->channel_id_path.empty()); |
442 | 442 |
443 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db = | 443 scoped_refptr<SQLiteChannelIDStore> channel_id_db = |
444 new SQLiteServerBoundCertStore( | 444 new SQLiteChannelIDStore( |
445 lazy_params_->server_bound_cert_path, | 445 lazy_params_->channel_id_path, |
446 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 446 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
447 BrowserThread::GetBlockingPool()->GetSequenceToken()), | 447 BrowserThread::GetBlockingPool()->GetSequenceToken()), |
448 lazy_params_->special_storage_policy.get()); | 448 lazy_params_->special_storage_policy.get()); |
449 server_bound_cert_service = new net::ServerBoundCertService( | 449 channel_id_service = new net::ChannelIDService( |
450 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()), | 450 new net::DefaultChannelIDStore(channel_id_db.get()), |
451 base::WorkerPool::GetTaskRunner(true)); | 451 base::WorkerPool::GetTaskRunner(true)); |
452 } | 452 } |
453 | 453 |
454 set_server_bound_cert_service(server_bound_cert_service); | 454 set_channel_id_service(channel_id_service); |
455 main_context->set_server_bound_cert_service(server_bound_cert_service); | 455 main_context->set_channel_id_service(channel_id_service); |
456 | 456 |
457 net::HttpCache::DefaultBackend* main_backend = | 457 net::HttpCache::DefaultBackend* main_backend = |
458 new net::HttpCache::DefaultBackend( | 458 new net::HttpCache::DefaultBackend( |
459 net::DISK_CACHE, | 459 net::DISK_CACHE, |
460 ChooseCacheBackendType(), | 460 ChooseCacheBackendType(), |
461 lazy_params_->cache_path, | 461 lazy_params_->cache_path, |
462 lazy_params_->cache_max_size, | 462 lazy_params_->cache_max_size, |
463 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) | 463 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE) |
464 .get()); | 464 .get()); |
465 scoped_ptr<net::HttpCache> main_cache = CreateMainHttpFactory( | 465 scoped_ptr<net::HttpCache> main_cache = CreateMainHttpFactory( |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 const base::Closure& completion) { | 751 const base::Closure& completion) { |
752 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 752 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
753 DCHECK(initialized()); | 753 DCHECK(initialized()); |
754 | 754 |
755 DCHECK(transport_security_state()); | 755 DCHECK(transport_security_state()); |
756 // Completes synchronously. | 756 // Completes synchronously. |
757 transport_security_state()->DeleteAllDynamicDataSince(time); | 757 transport_security_state()->DeleteAllDynamicDataSince(time); |
758 DCHECK(http_server_properties_manager_); | 758 DCHECK(http_server_properties_manager_); |
759 http_server_properties_manager_->Clear(completion); | 759 http_server_properties_manager_->Clear(completion); |
760 } | 760 } |
OLD | NEW |