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