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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "content/public/browser/cookie_store_factory.h" | 50 #include "content/public/browser/cookie_store_factory.h" |
51 #include "content/public/browser/notification_service.h" | 51 #include "content/public/browser/notification_service.h" |
52 #include "content/public/browser/resource_context.h" | 52 #include "content/public/browser/resource_context.h" |
53 #include "content/public/browser/storage_partition.h" | 53 #include "content/public/browser/storage_partition.h" |
54 #include "extensions/browser/extension_protocols.h" | 54 #include "extensions/browser/extension_protocols.h" |
55 #include "extensions/common/constants.h" | 55 #include "extensions/common/constants.h" |
56 #include "net/base/cache_type.h" | 56 #include "net/base/cache_type.h" |
57 #include "net/base/sdch_manager.h" | 57 #include "net/base/sdch_manager.h" |
58 #include "net/ftp/ftp_network_layer.h" | 58 #include "net/ftp/ftp_network_layer.h" |
59 #include "net/http/http_cache.h" | 59 #include "net/http/http_cache.h" |
60 #include "net/http/http_network_session.h" | |
61 #include "net/http/http_server_properties_manager.h" | 60 #include "net/http/http_server_properties_manager.h" |
62 #include "net/sdch/sdch_owner.h" | 61 #include "net/sdch/sdch_owner.h" |
63 #include "net/ssl/channel_id_service.h" | 62 #include "net/ssl/channel_id_service.h" |
64 #include "net/url_request/url_request_intercepting_job_factory.h" | 63 #include "net/url_request/url_request_intercepting_job_factory.h" |
65 #include "net/url_request/url_request_job_factory_impl.h" | 64 #include "net/url_request/url_request_job_factory_impl.h" |
66 #include "storage/browser/quota/special_storage_policy.h" | 65 #include "storage/browser/quota/special_storage_policy.h" |
67 | 66 |
68 namespace { | 67 namespace { |
69 | 68 |
70 net::BackendType ChooseCacheBackendType() { | 69 net::BackendType ChooseCacheBackendType() { |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 BrowserThread::GetBlockingPool()->GetSequenceToken()), | 530 BrowserThread::GetBlockingPool()->GetSequenceToken()), |
532 lazy_params_->special_storage_policy.get()); | 531 lazy_params_->special_storage_policy.get()); |
533 channel_id_service = new net::ChannelIDService( | 532 channel_id_service = new net::ChannelIDService( |
534 new net::DefaultChannelIDStore(channel_id_db.get()), | 533 new net::DefaultChannelIDStore(channel_id_db.get()), |
535 base::WorkerPool::GetTaskRunner(true)); | 534 base::WorkerPool::GetTaskRunner(true)); |
536 } | 535 } |
537 | 536 |
538 set_channel_id_service(channel_id_service); | 537 set_channel_id_service(channel_id_service); |
539 main_context->set_channel_id_service(channel_id_service); | 538 main_context->set_channel_id_service(channel_id_service); |
540 | 539 |
| 540 scoped_ptr<net::HttpCache> main_cache; |
541 { | 541 { |
542 // TODO(ttuttle): Remove ScopedTracker below once crbug.com/436671 is fixed. | 542 // TODO(ttuttle): Remove ScopedTracker below once crbug.com/436671 is fixed. |
543 tracked_objects::ScopedTracker tracking_profile( | 543 tracked_objects::ScopedTracker tracking_profile( |
544 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 HttpCache construction")); | 544 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 HttpCache construction")); |
545 net::HttpCache::BackendFactory* main_backend( | 545 net::HttpCache::DefaultBackend* main_backend = |
546 new net::HttpCache::DefaultBackend( | 546 new net::HttpCache::DefaultBackend( |
547 net::DISK_CACHE, | 547 net::DISK_CACHE, |
548 ChooseCacheBackendType(), | 548 ChooseCacheBackendType(), |
549 lazy_params_->cache_path, | 549 lazy_params_->cache_path, |
550 lazy_params_->cache_max_size, | 550 lazy_params_->cache_max_size, |
551 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 551 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
552 http_network_session_ = CreateHttpNetworkSession(*profile_params); | 552 main_cache = CreateMainHttpFactory(profile_params, main_backend); |
553 main_http_factory_ = CreateMainHttpFactory(http_network_session_.get(), | |
554 main_backend); | |
555 } | 553 } |
556 | 554 |
| 555 main_http_factory_.reset(main_cache.release()); |
557 main_context->set_http_transaction_factory(main_http_factory_.get()); | 556 main_context->set_http_transaction_factory(main_http_factory_.get()); |
558 | 557 |
559 #if !defined(DISABLE_FTP_SUPPORT) | 558 #if !defined(DISABLE_FTP_SUPPORT) |
560 ftp_factory_.reset( | 559 ftp_factory_.reset( |
561 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 560 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
562 #endif // !defined(DISABLE_FTP_SUPPORT) | 561 #endif // !defined(DISABLE_FTP_SUPPORT) |
563 | 562 |
564 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 563 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
565 new net::URLRequestJobFactoryImpl()); | 564 new net::URLRequestJobFactoryImpl()); |
566 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 565 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // Copy most state from the main context. | 657 // Copy most state from the main context. |
659 AppRequestContext* context = new AppRequestContext(); | 658 AppRequestContext* context = new AppRequestContext(); |
660 context->CopyFrom(main_context); | 659 context->CopyFrom(main_context); |
661 | 660 |
662 base::FilePath cookie_path = partition_descriptor.path.Append( | 661 base::FilePath cookie_path = partition_descriptor.path.Append( |
663 chrome::kCookieFilename); | 662 chrome::kCookieFilename); |
664 base::FilePath cache_path = | 663 base::FilePath cache_path = |
665 partition_descriptor.path.Append(chrome::kCacheDirname); | 664 partition_descriptor.path.Append(chrome::kCacheDirname); |
666 | 665 |
667 // Use a separate HTTP disk cache for isolated apps. | 666 // Use a separate HTTP disk cache for isolated apps. |
668 net::HttpCache::BackendFactory* app_backend; | 667 net::HttpCache::BackendFactory* app_backend = NULL; |
669 if (partition_descriptor.in_memory) { | 668 if (partition_descriptor.in_memory) { |
670 app_backend = net::HttpCache::DefaultBackend::InMemory(0); | 669 app_backend = net::HttpCache::DefaultBackend::InMemory(0); |
671 } else { | 670 } else { |
672 app_backend = new net::HttpCache::DefaultBackend( | 671 app_backend = new net::HttpCache::DefaultBackend( |
673 net::DISK_CACHE, | 672 net::DISK_CACHE, |
674 ChooseCacheBackendType(), | 673 ChooseCacheBackendType(), |
675 cache_path, | 674 cache_path, |
676 app_cache_max_size_, | 675 app_cache_max_size_, |
677 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 676 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
678 } | 677 } |
| 678 net::HttpNetworkSession* main_network_session = |
| 679 main_http_factory_->GetSession(); |
679 scoped_ptr<net::HttpCache> app_http_cache = | 680 scoped_ptr<net::HttpCache> app_http_cache = |
680 CreateHttpFactory(http_network_session_.get(), app_backend); | 681 CreateHttpFactory(main_network_session, app_backend); |
681 | 682 |
682 scoped_refptr<net::CookieStore> cookie_store = NULL; | 683 scoped_refptr<net::CookieStore> cookie_store = NULL; |
683 if (partition_descriptor.in_memory) { | 684 if (partition_descriptor.in_memory) { |
684 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 685 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); |
685 } | 686 } |
686 | 687 |
687 // Use an app-specific cookie store. | 688 // Use an app-specific cookie store. |
688 if (!cookie_store.get()) { | 689 if (!cookie_store.get()) { |
689 DCHECK(!cookie_path.empty()); | 690 DCHECK(!cookie_path.empty()); |
690 | 691 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 } | 751 } |
751 | 752 |
752 // Use a separate HTTP disk cache for isolated apps. | 753 // Use a separate HTTP disk cache for isolated apps. |
753 net::HttpCache::BackendFactory* media_backend = | 754 net::HttpCache::BackendFactory* media_backend = |
754 new net::HttpCache::DefaultBackend( | 755 new net::HttpCache::DefaultBackend( |
755 net::MEDIA_CACHE, | 756 net::MEDIA_CACHE, |
756 ChooseCacheBackendType(), | 757 ChooseCacheBackendType(), |
757 cache_path, | 758 cache_path, |
758 cache_max_size, | 759 cache_max_size, |
759 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 760 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
| 761 net::HttpNetworkSession* main_network_session = |
| 762 main_http_factory_->GetSession(); |
760 scoped_ptr<net::HttpCache> media_http_cache = | 763 scoped_ptr<net::HttpCache> media_http_cache = |
761 CreateHttpFactory(http_network_session_.get(), media_backend); | 764 CreateHttpFactory(main_network_session, media_backend); |
762 | 765 |
763 // Transfer ownership of the cache to MediaRequestContext. | 766 // Transfer ownership of the cache to MediaRequestContext. |
764 context->SetHttpTransactionFactory(media_http_cache.Pass()); | 767 context->SetHttpTransactionFactory(media_http_cache.Pass()); |
765 | 768 |
766 // Note that we do not create a new URLRequestJobFactory because | 769 // Note that we do not create a new URLRequestJobFactory because |
767 // the media context should behave exactly like its parent context | 770 // the media context should behave exactly like its parent context |
768 // in all respects except for cache behavior on media subresources. | 771 // in all respects except for cache behavior on media subresources. |
769 // The CopyFrom() step above means that our media context will use | 772 // The CopyFrom() step above means that our media context will use |
770 // the same URLRequestJobFactory instance that our parent context does. | 773 // the same URLRequestJobFactory instance that our parent context does. |
771 | 774 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 const base::Closure& completion) { | 815 const base::Closure& completion) { |
813 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 816 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
814 DCHECK(initialized()); | 817 DCHECK(initialized()); |
815 | 818 |
816 DCHECK(transport_security_state()); | 819 DCHECK(transport_security_state()); |
817 // Completes synchronously. | 820 // Completes synchronously. |
818 transport_security_state()->DeleteAllDynamicDataSince(time); | 821 transport_security_state()->DeleteAllDynamicDataSince(time); |
819 DCHECK(http_server_properties_manager_); | 822 DCHECK(http_server_properties_manager_); |
820 http_server_properties_manager_->Clear(completion); | 823 http_server_properties_manager_->Clear(completion); |
821 } | 824 } |
OLD | NEW |