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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include "components/domain_reliability/monitor.h" | 47 #include "components/domain_reliability/monitor.h" |
48 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
49 #include "content/public/browser/cookie_store_factory.h" | 49 #include "content/public/browser/cookie_store_factory.h" |
50 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
51 #include "content/public/browser/resource_context.h" | 51 #include "content/public/browser/resource_context.h" |
52 #include "content/public/browser/storage_partition.h" | 52 #include "content/public/browser/storage_partition.h" |
53 #include "extensions/browser/extension_protocols.h" | 53 #include "extensions/browser/extension_protocols.h" |
54 #include "extensions/common/constants.h" | 54 #include "extensions/common/constants.h" |
55 #include "net/base/cache_type.h" | 55 #include "net/base/cache_type.h" |
56 #include "net/base/sdch_manager.h" | 56 #include "net/base/sdch_manager.h" |
57 #include "net/cert/cert_policy_enforcer.h" | |
58 #include "net/cert/cert_verifier.h" | |
59 #include "net/cert/multi_log_ct_verifier.h" | |
60 #include "net/dns/host_resolver.h" | |
57 #include "net/ftp/ftp_network_layer.h" | 61 #include "net/ftp/ftp_network_layer.h" |
58 #include "net/http/http_cache.h" | 62 #include "net/http/http_cache.h" |
59 #include "net/http/http_server_properties_manager.h" | 63 #include "net/http/http_server_properties_manager.h" |
60 #include "net/sdch/sdch_owner.h" | 64 #include "net/sdch/sdch_owner.h" |
61 #include "net/ssl/channel_id_service.h" | 65 #include "net/ssl/channel_id_service.h" |
66 #include "net/ssl/ssl_config_service_defaults.h" | |
62 #include "net/url_request/url_request_intercepting_job_factory.h" | 67 #include "net/url_request/url_request_intercepting_job_factory.h" |
63 #include "net/url_request/url_request_job_factory_impl.h" | 68 #include "net/url_request/url_request_job_factory_impl.h" |
64 #include "storage/browser/quota/special_storage_policy.h" | 69 #include "storage/browser/quota/special_storage_policy.h" |
65 | 70 |
66 namespace { | 71 namespace { |
67 | 72 |
68 net::BackendType ChooseCacheBackendType() { | 73 net::BackendType ChooseCacheBackendType() { |
69 #if defined(OS_ANDROID) | 74 #if defined(OS_ANDROID) |
70 return net::CACHE_BACKEND_SIMPLE; | 75 return net::CACHE_BACKEND_SIMPLE; |
71 #else | 76 #else |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 | 643 |
639 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( | 644 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( |
640 net::URLRequestContext* main_context, | 645 net::URLRequestContext* main_context, |
641 const StoragePartitionDescriptor& partition_descriptor, | 646 const StoragePartitionDescriptor& partition_descriptor, |
642 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 647 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
643 protocol_handler_interceptor, | 648 protocol_handler_interceptor, |
644 content::ProtocolHandlerMap* protocol_handlers, | 649 content::ProtocolHandlerMap* protocol_handlers, |
645 content::URLRequestInterceptorScopedVector request_interceptors) const { | 650 content::URLRequestInterceptorScopedVector request_interceptors) const { |
646 // Copy most state from the main context. | 651 // Copy most state from the main context. |
647 AppRequestContext* context = new AppRequestContext(); | 652 AppRequestContext* context = new AppRequestContext(); |
648 context->CopyFrom(main_context); | 653 context->CopyFrom(main_context); |
mmenke
2015/07/09 18:36:54
And just to help motivate my comment about sharing
| |
649 | 654 |
650 base::FilePath cookie_path = partition_descriptor.path.Append( | 655 base::FilePath cookie_path = partition_descriptor.path.Append( |
651 chrome::kCookieFilename); | 656 chrome::kCookieFilename); |
652 base::FilePath cache_path = | 657 base::FilePath cache_path = |
653 partition_descriptor.path.Append(chrome::kCacheDirname); | 658 partition_descriptor.path.Append(chrome::kCacheDirname); |
654 | 659 |
655 // Use a separate HTTP disk cache for isolated apps. | 660 // Use a separate HTTP disk cache for isolated apps. |
656 net::HttpCache::BackendFactory* app_backend = NULL; | 661 net::HttpCache::BackendFactory* app_backend = NULL; |
657 if (partition_descriptor.in_memory) { | 662 if (partition_descriptor.in_memory) { |
658 app_backend = net::HttpCache::DefaultBackend::InMemory(0); | 663 app_backend = net::HttpCache::DefaultBackend::InMemory(0); |
659 } else { | 664 } else { |
660 app_backend = new net::HttpCache::DefaultBackend( | 665 app_backend = new net::HttpCache::DefaultBackend( |
661 net::DISK_CACHE, | 666 net::DISK_CACHE, |
662 ChooseCacheBackendType(), | 667 ChooseCacheBackendType(), |
663 cache_path, | 668 cache_path, |
664 app_cache_max_size_, | 669 app_cache_max_size_, |
665 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 670 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
666 } | 671 } |
667 net::HttpNetworkSession* main_network_session = | 672 |
668 main_http_factory_->GetSession(); | 673 // Clone network session parameters from the main HttpNetworkSession, then |
674 // create a unique HttpNetworkSession. Below we create isolated versions of | |
675 // the state elements necessary to get a completely isolated socket pool for | |
676 // the app. | |
677 net::HttpNetworkSession::Params params = | |
678 main_http_factory_->GetSession()->params(); | |
679 | |
680 // Create isolated HostResolver. Assume it's ok to re-use the net_log | |
681 // from the main_context. | |
682 context->SetHostResolver( | |
683 net::HostResolver::CreateDefaultResolver(main_context->net_log())); | |
684 params.host_resolver = context->host_resolver(); | |
685 params.client_socket_factory = nullptr; // Force creation of new sockets. | |
686 context->SetCertVerifier(make_scoped_ptr(net::CertVerifier::CreateDefault())); | |
687 params.cert_verifier = context->cert_verifier(); | |
688 context->SetChannelIDService(make_scoped_ptr( | |
689 new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr), | |
690 base::WorkerPool::GetTaskRunner(true)))); | |
691 params.channel_id_service = context->channel_id_service(); | |
692 context->SetTransportSecurityState( | |
693 make_scoped_ptr(new net::TransportSecurityState)); | |
694 params.transport_security_state = context->transport_security_state(); | |
695 context->SetCertTransparencyVerifier( | |
696 make_scoped_ptr(new net::MultiLogCTVerifier())); | |
697 params.cert_transparency_verifier = context->cert_transparency_verifier(); | |
698 context->SetCertPolicyEnforcer(make_scoped_ptr(new net::CertPolicyEnforcer)); | |
699 params.cert_policy_enforcer = context->cert_policy_enforcer(); | |
700 context->SetSSLConfigService(new net::SSLConfigServiceDefaults); | |
701 params.ssl_config_service = context->ssl_config_service(); | |
702 | |
703 // Create new, isolated-state HttpNetworkSession. | |
704 net::HttpNetworkSession* new_network_session = | |
705 new net::HttpNetworkSession(params); | |
669 scoped_ptr<net::HttpCache> app_http_cache = | 706 scoped_ptr<net::HttpCache> app_http_cache = |
670 CreateHttpFactory(main_network_session, app_backend); | 707 CreateHttpFactory(new_network_session, app_backend); |
671 | 708 |
672 scoped_refptr<net::CookieStore> cookie_store = NULL; | 709 scoped_refptr<net::CookieStore> cookie_store = NULL; |
673 if (partition_descriptor.in_memory) { | 710 if (partition_descriptor.in_memory) { |
674 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 711 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
675 } | 712 } |
676 | 713 |
677 // Use an app-specific cookie store. | 714 // Use an app-specific cookie store. |
678 if (!cookie_store.get()) { | 715 if (!cookie_store.get()) { |
679 DCHECK(!cookie_path.empty()); | 716 DCHECK(!cookie_path.empty()); |
680 | 717 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 const base::Closure& completion) { | 841 const base::Closure& completion) { |
805 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 842 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
806 DCHECK(initialized()); | 843 DCHECK(initialized()); |
807 | 844 |
808 DCHECK(transport_security_state()); | 845 DCHECK(transport_security_state()); |
809 // Completes synchronously. | 846 // Completes synchronously. |
810 transport_security_state()->DeleteAllDynamicDataSince(time); | 847 transport_security_state()->DeleteAllDynamicDataSince(time); |
811 DCHECK(http_server_properties_manager_); | 848 DCHECK(http_server_properties_manager_); |
812 http_server_properties_manager_->Clear(completion); | 849 http_server_properties_manager_->Clear(completion); |
813 } | 850 } |
OLD | NEW |