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 <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 616 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
617 protocol_handler_interceptor, | 617 protocol_handler_interceptor, |
618 content::ProtocolHandlerMap* protocol_handlers, | 618 content::ProtocolHandlerMap* protocol_handlers, |
619 content::URLRequestInterceptorScopedVector request_interceptors) const { | 619 content::URLRequestInterceptorScopedVector request_interceptors) const { |
620 // Copy most state from the main context. | 620 // Copy most state from the main context. |
621 AppRequestContext* context = new AppRequestContext(); | 621 AppRequestContext* context = new AppRequestContext(); |
622 context->CopyFrom(main_context); | 622 context->CopyFrom(main_context); |
623 | 623 |
624 base::FilePath cookie_path = partition_descriptor.path.Append( | 624 base::FilePath cookie_path = partition_descriptor.path.Append( |
625 chrome::kCookieFilename); | 625 chrome::kCookieFilename); |
| 626 base::FilePath channel_id_path = |
| 627 partition_descriptor.path.Append(chrome::kChannelIDFilename); |
626 base::FilePath cache_path = | 628 base::FilePath cache_path = |
627 partition_descriptor.path.Append(chrome::kCacheDirname); | 629 partition_descriptor.path.Append(chrome::kCacheDirname); |
628 | 630 |
629 // Use a separate HTTP disk cache for isolated apps. | 631 // Use a separate HTTP disk cache for isolated apps. |
630 std::unique_ptr<net::HttpCache::BackendFactory> app_backend; | 632 std::unique_ptr<net::HttpCache::BackendFactory> app_backend; |
631 if (partition_descriptor.in_memory) { | 633 if (partition_descriptor.in_memory) { |
632 app_backend = net::HttpCache::DefaultBackend::InMemory(0); | 634 app_backend = net::HttpCache::DefaultBackend::InMemory(0); |
633 } else { | 635 } else { |
634 app_backend.reset(new net::HttpCache::DefaultBackend( | 636 app_backend.reset(new net::HttpCache::DefaultBackend( |
635 net::DISK_CACHE, | 637 net::DISK_CACHE, |
636 ChooseCacheBackendType(), | 638 ChooseCacheBackendType(), |
637 cache_path, | 639 cache_path, |
638 app_cache_max_size_, | 640 app_cache_max_size_, |
639 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 641 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
640 } | 642 } |
641 std::unique_ptr<net::HttpCache> app_http_cache = | |
642 CreateHttpFactory(http_network_session_.get(), std::move(app_backend)); | |
643 | 643 |
644 std::unique_ptr<net::CookieStore> cookie_store; | 644 std::unique_ptr<net::CookieStore> cookie_store; |
| 645 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; |
645 if (partition_descriptor.in_memory) { | 646 if (partition_descriptor.in_memory) { |
646 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 647 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
647 } else { | 648 } else { |
648 // Use an app-specific cookie store. | 649 // Use an app-specific cookie store. |
649 DCHECK(!cookie_path.empty()); | 650 DCHECK(!cookie_path.empty()); |
650 | 651 |
651 // TODO(creis): We should have a cookie delegate for notifying the cookie | 652 // TODO(creis): We should have a cookie delegate for notifying the cookie |
652 // extensions API, but we need to update it to understand isolated apps | 653 // extensions API, but we need to update it to understand isolated apps |
653 // first. | 654 // first. |
654 content::CookieStoreConfig cookie_config( | 655 content::CookieStoreConfig cookie_config( |
655 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, | 656 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
656 nullptr, nullptr); | 657 nullptr, nullptr); |
657 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); | 658 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); |
658 cookie_store = content::CreateCookieStore(cookie_config); | 659 cookie_store = content::CreateCookieStore(cookie_config); |
| 660 channel_id_db = new net::SQLiteChannelIDStore( |
| 661 channel_id_path, |
| 662 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 663 base::SequencedWorkerPool::GetSequenceToken())); |
659 } | 664 } |
| 665 std::unique_ptr<net::ChannelIDService> channel_id_service( |
| 666 new net::ChannelIDService( |
| 667 new net::DefaultChannelIDStore(channel_id_db.get()), |
| 668 base::WorkerPool::GetTaskRunner(true))); |
| 669 |
| 670 // Build a new HttpNetworkSession that uses the new ChannelIDService. |
| 671 net::HttpNetworkSession::Params network_params = |
| 672 http_network_session_->params(); |
| 673 network_params.channel_id_service = channel_id_service.get(); |
| 674 std::unique_ptr<net::HttpNetworkSession> http_network_session( |
| 675 new net::HttpNetworkSession(network_params)); |
| 676 std::unique_ptr<net::HttpCache> app_http_cache = |
| 677 CreateHttpFactory(http_network_session.get(), std::move(app_backend)); |
| 678 |
| 679 // Transfer ownership of the ChannelIDStore and the HttpNetworkSession to the |
| 680 // AppRequestContext. |
| 681 context->SetChannelIDService(std::move(channel_id_service)); |
| 682 context->SetHttpNetworkSession(std::move(http_network_session)); |
660 | 683 |
661 // Transfer ownership of the cookies and cache to AppRequestContext. | 684 // Transfer ownership of the cookies and cache to AppRequestContext. |
662 context->SetCookieStore(std::move(cookie_store)); | 685 context->SetCookieStore(std::move(cookie_store)); |
663 context->SetHttpTransactionFactory(std::move(app_http_cache)); | 686 context->SetHttpTransactionFactory(std::move(app_http_cache)); |
664 | 687 |
665 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( | 688 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( |
666 new net::URLRequestJobFactoryImpl()); | 689 new net::URLRequestJobFactoryImpl()); |
667 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 690 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
668 // The data reduction proxy interceptor should be as close to the network | 691 // The data reduction proxy interceptor should be as close to the network |
669 // as possible. | 692 // as possible. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 const base::Closure& completion) { | 788 const base::Closure& completion) { |
766 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 789 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
767 DCHECK(initialized()); | 790 DCHECK(initialized()); |
768 | 791 |
769 DCHECK(transport_security_state()); | 792 DCHECK(transport_security_state()); |
770 // Completes synchronously. | 793 // Completes synchronously. |
771 transport_security_state()->DeleteAllDynamicDataSince(time); | 794 transport_security_state()->DeleteAllDynamicDataSince(time); |
772 DCHECK(http_server_properties_manager_); | 795 DCHECK(http_server_properties_manager_); |
773 http_server_properties_manager_->Clear(completion); | 796 http_server_properties_manager_->Clear(completion); |
774 } | 797 } |
OLD | NEW |