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