Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 2428143002: Clean up FtpTransactionFacory ownership. (Closed)
Patch Set: Response to comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "content/public/browser/browser_thread.h" 56 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/cookie_store_factory.h" 57 #include "content/public/browser/cookie_store_factory.h"
58 #include "content/public/browser/notification_service.h" 58 #include "content/public/browser/notification_service.h"
59 #include "content/public/browser/resource_context.h" 59 #include "content/public/browser/resource_context.h"
60 #include "content/public/browser/storage_partition.h" 60 #include "content/public/browser/storage_partition.h"
61 #include "extensions/browser/extension_protocols.h" 61 #include "extensions/browser/extension_protocols.h"
62 #include "extensions/common/constants.h" 62 #include "extensions/common/constants.h"
63 #include "net/base/cache_type.h" 63 #include "net/base/cache_type.h"
64 #include "net/base/sdch_manager.h" 64 #include "net/base/sdch_manager.h"
65 #include "net/cookies/cookie_store.h" 65 #include "net/cookies/cookie_store.h"
66 #include "net/ftp/ftp_network_layer.h"
67 #include "net/http/http_cache.h" 66 #include "net/http/http_cache.h"
68 #include "net/http/http_network_session.h" 67 #include "net/http/http_network_session.h"
69 #include "net/http/http_server_properties_manager.h" 68 #include "net/http/http_server_properties_manager.h"
70 #include "net/sdch/sdch_owner.h" 69 #include "net/sdch/sdch_owner.h"
71 #include "net/ssl/channel_id_service.h" 70 #include "net/ssl/channel_id_service.h"
72 #include "net/url_request/url_request_context_storage.h" 71 #include "net/url_request/url_request_context_storage.h"
73 #include "net/url_request/url_request_intercepting_job_factory.h" 72 #include "net/url_request/url_request_intercepting_job_factory.h"
74 #include "net/url_request/url_request_job_factory_impl.h" 73 #include "net/url_request/url_request_job_factory_impl.h"
75 #include "storage/browser/quota/special_storage_policy.h" 74 #include "storage/browser/quota/special_storage_policy.h"
76 75
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 std::unique_ptr<net::HttpCache::BackendFactory> main_backend( 525 std::unique_ptr<net::HttpCache::BackendFactory> main_backend(
527 new net::HttpCache::DefaultBackend( 526 new net::HttpCache::DefaultBackend(
528 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path, 527 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path,
529 lazy_params_->cache_max_size, 528 lazy_params_->cache_max_size,
530 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); 529 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)));
531 main_context_storage->set_http_network_session( 530 main_context_storage->set_http_network_session(
532 CreateHttpNetworkSession(*profile_params)); 531 CreateHttpNetworkSession(*profile_params));
533 main_context_storage->set_http_transaction_factory(CreateMainHttpFactory( 532 main_context_storage->set_http_transaction_factory(CreateMainHttpFactory(
534 main_context_storage->http_network_session(), std::move(main_backend))); 533 main_context_storage->http_network_session(), std::move(main_backend)));
535 534
536 #if !defined(DISABLE_FTP_SUPPORT)
537 ftp_factory_.reset(
538 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
539 #endif // !defined(DISABLE_FTP_SUPPORT)
540
541 std::unique_ptr<net::URLRequestJobFactoryImpl> main_job_factory( 535 std::unique_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
542 new net::URLRequestJobFactoryImpl()); 536 new net::URLRequestJobFactoryImpl());
543 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); 537 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers);
544 538
545 // Install the Offline Page Interceptor. 539 // Install the Offline Page Interceptor.
546 #if defined(OS_ANDROID) 540 #if defined(OS_ANDROID)
547 request_interceptors.push_back(std::unique_ptr<net::URLRequestInterceptor>( 541 request_interceptors.push_back(std::unique_ptr<net::URLRequestInterceptor>(
548 new offline_pages::OfflinePageRequestInterceptor( 542 new offline_pages::OfflinePageRequestInterceptor(
549 previews_io_data_.get()))); 543 previews_io_data_.get())));
550 #endif 544 #endif
551 545
552 // The data reduction proxy interceptor should be as close to the network 546 // The data reduction proxy interceptor should be as close to the network
553 // as possible. 547 // as possible.
554 request_interceptors.insert( 548 request_interceptors.insert(
555 request_interceptors.begin(), 549 request_interceptors.begin(),
556 data_reduction_proxy_io_data()->CreateInterceptor().release()); 550 data_reduction_proxy_io_data()->CreateInterceptor().release());
557 main_context_storage->set_job_factory(SetUpJobFactoryDefaults( 551 main_context_storage->set_job_factory(SetUpJobFactoryDefaults(
558 std::move(main_job_factory), std::move(request_interceptors), 552 std::move(main_job_factory), std::move(request_interceptors),
559 std::move(profile_params->protocol_handler_interceptor), 553 std::move(profile_params->protocol_handler_interceptor),
560 main_context->network_delegate(), ftp_factory_.get())); 554 main_context->network_delegate(),
555 io_thread_globals->host_resolver.get()));
561 main_context->set_network_quality_estimator( 556 main_context->set_network_quality_estimator(
562 io_thread_globals->network_quality_estimator.get()); 557 io_thread_globals->network_quality_estimator.get());
563 558
564 #if defined(ENABLE_EXTENSIONS) 559 #if defined(ENABLE_EXTENSIONS)
565 InitializeExtensionsRequestContext(profile_params); 560 InitializeExtensionsRequestContext(profile_params);
566 #endif 561 #endif
567 562
568 // Setup SDCH for this profile. 563 // Setup SDCH for this profile.
569 std::unique_ptr<net::SdchManager> sdch_manager(new net::SdchManager()); 564 std::unique_ptr<net::SdchManager> sdch_manager(new net::SdchManager());
570 sdch_policy_.reset(new net::SdchOwner(sdch_manager.get(), main_context)); 565 sdch_policy_.reset(new net::SdchOwner(sdch_manager.get(), main_context));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. 606 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate.
612 // Without a network_delegate, this protocol handler will never 607 // Without a network_delegate, this protocol handler will never
613 // handle file: requests, but as a side effect it makes 608 // handle file: requests, but as a side effect it makes
614 // job_factory::IsHandledProtocol return true, which prevents attempts to 609 // job_factory::IsHandledProtocol return true, which prevents attempts to
615 // handle the protocol externally. We pass NULL in to 610 // handle the protocol externally. We pass NULL in to
616 // SetUpJobFactory() to get this effect. 611 // SetUpJobFactory() to get this effect.
617 extensions_job_factory_ = SetUpJobFactoryDefaults( 612 extensions_job_factory_ = SetUpJobFactoryDefaults(
618 std::move(extensions_job_factory), 613 std::move(extensions_job_factory),
619 content::URLRequestInterceptorScopedVector(), 614 content::URLRequestInterceptorScopedVector(),
620 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(), NULL, 615 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(), NULL,
621 ftp_factory_.get()); 616 io_thread_globals->host_resolver.get());
622 extensions_context->set_job_factory(extensions_job_factory_.get()); 617 extensions_context->set_job_factory(extensions_job_factory_.get());
623 } 618 }
624 619
625 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext( 620 net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext(
626 net::URLRequestContext* main_context, 621 net::URLRequestContext* main_context,
627 const StoragePartitionDescriptor& partition_descriptor, 622 const StoragePartitionDescriptor& partition_descriptor,
628 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 623 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
629 protocol_handler_interceptor, 624 protocol_handler_interceptor,
630 content::ProtocolHandlerMap* protocol_handlers, 625 content::ProtocolHandlerMap* protocol_handlers,
631 content::URLRequestInterceptorScopedVector request_interceptors) const { 626 content::URLRequestInterceptorScopedVector request_interceptors) const {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 context->SetHttpTransactionFactory(std::move(app_http_cache)); 696 context->SetHttpTransactionFactory(std::move(app_http_cache));
702 697
703 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( 698 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory(
704 new net::URLRequestJobFactoryImpl()); 699 new net::URLRequestJobFactoryImpl());
705 InstallProtocolHandlers(job_factory.get(), protocol_handlers); 700 InstallProtocolHandlers(job_factory.get(), protocol_handlers);
706 // The data reduction proxy interceptor should be as close to the network 701 // The data reduction proxy interceptor should be as close to the network
707 // as possible. 702 // as possible.
708 request_interceptors.insert( 703 request_interceptors.insert(
709 request_interceptors.begin(), 704 request_interceptors.begin(),
710 data_reduction_proxy_io_data()->CreateInterceptor().release()); 705 data_reduction_proxy_io_data()->CreateInterceptor().release());
706
711 std::unique_ptr<net::URLRequestJobFactory> top_job_factory( 707 std::unique_ptr<net::URLRequestJobFactory> top_job_factory(
712 SetUpJobFactoryDefaults( 708 SetUpJobFactoryDefaults(
713 std::move(job_factory), std::move(request_interceptors), 709 std::move(job_factory), std::move(request_interceptors),
714 std::move(protocol_handler_interceptor), 710 std::move(protocol_handler_interceptor), context->network_delegate(),
715 main_context->network_delegate(), ftp_factory_.get())); 711 context->host_resolver()));
716 context->SetJobFactory(std::move(top_job_factory)); 712 context->SetJobFactory(std::move(top_job_factory));
717 713
718 return context; 714 return context;
719 } 715 }
720 716
721 net::URLRequestContext* 717 net::URLRequestContext*
722 ProfileImplIOData::InitializeMediaRequestContext( 718 ProfileImplIOData::InitializeMediaRequestContext(
723 net::URLRequestContext* original_context, 719 net::URLRequestContext* original_context,
724 const StoragePartitionDescriptor& partition_descriptor) const { 720 const StoragePartitionDescriptor& partition_descriptor) const {
725 // Copy most state from the original context. 721 // Copy most state from the original context.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 const base::Closure& completion) { 804 const base::Closure& completion) {
809 DCHECK_CURRENTLY_ON(BrowserThread::IO); 805 DCHECK_CURRENTLY_ON(BrowserThread::IO);
810 DCHECK(initialized()); 806 DCHECK(initialized());
811 807
812 DCHECK(transport_security_state()); 808 DCHECK(transport_security_state());
813 // Completes synchronously. 809 // Completes synchronously.
814 transport_security_state()->DeleteAllDynamicDataSince(time); 810 transport_security_state()->DeleteAllDynamicDataSince(time);
815 DCHECK(http_server_properties_manager_); 811 DCHECK(http_server_properties_manager_);
816 http_server_properties_manager_->Clear(completion); 812 http_server_properties_manager_->Clear(completion);
817 } 813 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698