| Index: chrome/browser/profiles/profile_io_data.cc
|
| diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
|
| index 0963814dfe9779f2d6761433ad2ca2389c51b892..04e1fadc0f28fdf1e350830dcf14ffc5fd773b6b 100644
|
| --- a/chrome/browser/profiles/profile_io_data.cc
|
| +++ b/chrome/browser/profiles/profile_io_data.cc
|
| @@ -78,6 +78,8 @@
|
| #include "net/url_request/ftp_protocol_handler.h"
|
| #include "net/url_request/url_request.h"
|
| #include "net/url_request/url_request_context.h"
|
| +#include "net/url_request/url_request_context_builder.h"
|
| +#include "net/url_request/url_request_context_storage.h"
|
| #include "net/url_request/url_request_file_job.h"
|
| #include "net/url_request/url_request_intercepting_job_factory.h"
|
| #include "net/url_request/url_request_interceptor.h"
|
| @@ -884,6 +886,20 @@ void ProfileIOData::set_data_reduction_proxy_io_data(
|
| data_reduction_proxy_io_data_ = data_reduction_proxy_io_data.Pass();
|
| }
|
|
|
| +net::FraudulentCertificateReporter*
|
| +ProfileIOData::fraudulent_certificate_reporter() const {
|
| + return main_request_context_.get()
|
| + ? main_request_context_->storage()
|
| + ->fraudulent_certificate_reporter()
|
| + : nullptr;
|
| +}
|
| +
|
| +net::TransportSecurityState* ProfileIOData::transport_security_state() const {
|
| + return main_request_context_.get()
|
| + ? main_request_context_->storage()->transport_security_state()
|
| + : nullptr;
|
| +}
|
| +
|
| base::WeakPtr<net::HttpServerProperties>
|
| ProfileIOData::http_server_properties() const {
|
| return http_server_properties_->GetWeakPtr();
|
| @@ -985,6 +1001,31 @@ std::string ProfileIOData::GetSSLSessionCacheShard() {
|
| return base::StringPrintf("profile/%u", ssl_session_cache_instance++);
|
| }
|
|
|
| +namespace {
|
| +
|
| +class ChromeFraudulentCertificateReporterFactory
|
| + : public net::FraudulentCertificateReporterFactory {
|
| + public:
|
| + net::FraudulentCertificateReporter* Create(
|
| + net::URLRequestContext* context) const override {
|
| + return new ChromeFraudulentCertificateReporter(context);
|
| + }
|
| +};
|
| +
|
| +}
|
| +
|
| +net::CertVerifier* ProfileIOData::CertVerifierDelegateMainContext::Get(
|
| + net::URLRequestContext* context) {
|
| + return owner_->GetCertVerifierForMainContext(context);
|
| +}
|
| +
|
| +net::HttpTransactionFactory*
|
| +ProfileIOData::HttpTransactionFactoryDelegate::Create(
|
| + net::URLRequestContext* context) {
|
| + return owner_->CreateMainHttpFactory(
|
| + profile_params_, main_backend_, context).release();
|
| +}
|
| +
|
| void ProfileIOData::Init(
|
| content::ProtocolHandlerMap* protocol_handlers,
|
| content::URLRequestInterceptorScopedVector request_interceptors) const {
|
| @@ -1006,7 +1047,7 @@ void ProfileIOData::Init(
|
| *base::CommandLine::ForCurrentProcess();
|
|
|
| // Create the common request contexts.
|
| - main_request_context_.reset(new net::URLRequestContext());
|
| + net::URLRequestContextBuilder context_builder;
|
| extensions_request_context_.reset(new net::URLRequestContext());
|
|
|
| scoped_ptr<ChromeNetworkDelegate> network_delegate(
|
| @@ -1035,8 +1076,9 @@ void ProfileIOData::Init(
|
| network_delegate->set_enable_do_not_track(&enable_do_not_track_);
|
| network_delegate->set_force_google_safe_search(&force_google_safesearch_);
|
| network_delegate->set_force_youtube_safety_mode(&force_youtube_safety_mode_);
|
| - fraudulent_certificate_reporter_.reset(
|
| - new ChromeFraudulentCertificateReporter(main_request_context_.get()));
|
| +
|
| + context_builder.set_fraudulent_certificate_reporter_factory(
|
| + new ChromeFraudulentCertificateReporterFactory);
|
|
|
| // NOTE: Proxy service uses the default io thread network delegate, not the
|
| // delegate just created.
|
| @@ -1048,16 +1090,8 @@ void ProfileIOData::Init(
|
| profile_params_->proxy_config_service.release(),
|
| command_line,
|
| quick_check_enabled_.GetValue()));
|
| - transport_security_state_.reset(new net::TransportSecurityState());
|
| - base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
|
| - transport_security_persister_.reset(
|
| - new net::TransportSecurityPersister(
|
| - transport_security_state_.get(),
|
| - profile_params_->path,
|
| - pool->GetSequencedTaskRunnerWithShutdownBehavior(
|
| - pool->GetSequenceToken(),
|
| - base::SequencedWorkerPool::BLOCK_SHUTDOWN),
|
| - IsOffTheRecord()));
|
| + context_builder.set_transport_security_state(
|
| + new net::TransportSecurityState());
|
|
|
| // Take ownership over these parameters.
|
| cookie_settings_ = profile_params_->cookie_settings;
|
| @@ -1066,9 +1100,6 @@ void ProfileIOData::Init(
|
| extension_info_map_ = profile_params_->extension_info_map;
|
| #endif
|
|
|
| - resource_context_->host_resolver_ = io_thread_globals->host_resolver.get();
|
| - resource_context_->request_context_ = main_request_context_.get();
|
| -
|
| if (profile_params_->resource_prefetch_predictor_observer_) {
|
| resource_prefetch_predictor_observer_.reset(
|
| profile_params_->resource_prefetch_predictor_observer_.release());
|
| @@ -1078,6 +1109,49 @@ void ProfileIOData::Init(
|
| supervised_user_url_filter_ = profile_params_->supervised_user_url_filter;
|
| #endif
|
|
|
| + context_builder.set_cert_verifier_delegate(
|
| + new CertVerifierDelegateMainContext(this));
|
| +
|
| + // Install the New Tab Page Interceptor.
|
| + if (profile_params_->new_tab_page_interceptor.get()) {
|
| + request_interceptors.push_back(
|
| + profile_params_->new_tab_page_interceptor.release());
|
| + }
|
| +
|
| + // We save a copy of the network delegate pointer as it may be wrapped before
|
| + // it is stored in the URLResourceContext, and we may need it during the
|
| + // post setup init.
|
| + ChromeNetworkDelegate* network_delegate_raw_ptr = network_delegate.get();
|
| + InitializeInternal(
|
| + network_delegate.Pass(), profile_params_.get(),
|
| + protocol_handlers, request_interceptors.Pass(),
|
| + &context_builder);
|
| +
|
| + // Now that the builder is initialized, proceed with building the main
|
| + // context.
|
| + main_request_context_.reset(context_builder.BuildMainContext());
|
| +
|
| + base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
|
| + transport_security_persister_.reset(new net::TransportSecurityPersister(
|
| + main_request_context_->storage()->transport_security_state(),
|
| + profile_params_->path,
|
| + pool->GetSequencedTaskRunnerWithShutdownBehavior(
|
| + pool->GetSequenceToken(), base::SequencedWorkerPool::BLOCK_SHUTDOWN),
|
| + IsOffTheRecord()));
|
| +
|
| + InitPostContextSetup(network_delegate_raw_ptr);
|
| +
|
| + profile_params_.reset();
|
| + initialized_ = true;
|
| +}
|
| +
|
| +net::CertVerifier* ProfileIOData::GetCertVerifierForMainContext(
|
| + net::URLRequestContext* context) const {
|
| + IOThread* const io_thread = profile_params_->io_thread;
|
| + IOThread::Globals* const io_thread_globals = io_thread->globals();
|
| +
|
| + resource_context_->host_resolver_ = io_thread_globals->host_resolver.get();
|
| + resource_context_->request_context_ = context;
|
| #if defined(OS_CHROMEOS)
|
| username_hash_ = profile_params_->username_hash;
|
| use_system_key_slot_ = profile_params_->use_system_key_slot;
|
| @@ -1096,25 +1170,12 @@ void ProfileIOData::Init(
|
| } else {
|
| cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get()));
|
| }
|
| - main_request_context_->set_cert_verifier(cert_verifier_.get());
|
| + return cert_verifier_.get();
|
| #else
|
| - main_request_context_->set_cert_verifier(
|
| - io_thread_globals->cert_verifier.get());
|
| + return io_thread_globals->cert_verifier.get();
|
| #endif
|
| -
|
| - // Install the New Tab Page Interceptor.
|
| - if (profile_params_->new_tab_page_interceptor.get()) {
|
| - request_interceptors.push_back(
|
| - profile_params_->new_tab_page_interceptor.release());
|
| - }
|
| -
|
| - InitializeInternal(
|
| - network_delegate.Pass(), profile_params_.get(),
|
| - protocol_handlers, request_interceptors.Pass());
|
| -
|
| - profile_params_.reset();
|
| - initialized_ = true;
|
| }
|
| +//#endif
|
|
|
| void ProfileIOData::ApplyProfileParamsToContext(
|
| net::URLRequestContext* context) const {
|
| @@ -1123,6 +1184,14 @@ void ProfileIOData::ApplyProfileParamsToContext(
|
| context->set_ssl_config_service(profile_params_->ssl_config_service.get());
|
| }
|
|
|
| +void ProfileIOData::ApplyProfileParamsToContext(
|
| + net::URLRequestContextBuilder* context_builder) const {
|
| + context_builder->set_http_user_agent_settings_unowned(
|
| + chrome_http_user_agent_settings_.get());
|
| + context_builder->set_ssl_config_service(
|
| + profile_params_->ssl_config_service.get());
|
| +}
|
| +
|
| scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults(
|
| scoped_ptr<net::URLRequestJobFactoryImpl> job_factory,
|
| content::URLRequestInterceptorScopedVector request_interceptors,
|
| @@ -1248,20 +1317,15 @@ void ProfileIOData::ShutdownOnUIThread(
|
| delete this;
|
| }
|
|
|
| -void ProfileIOData::set_channel_id_service(
|
| - net::ChannelIDService* channel_id_service) const {
|
| - channel_id_service_.reset(channel_id_service);
|
| -}
|
| -
|
| void ProfileIOData::DestroyResourceContext() {
|
| resource_context_.reset();
|
| }
|
|
|
| scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory(
|
| const ProfileParams* profile_params,
|
| - net::HttpCache::BackendFactory* main_backend) const {
|
| + net::HttpCache::BackendFactory* main_backend,
|
| + net::URLRequestContext* context) const {
|
| net::HttpNetworkSession::Params params;
|
| - net::URLRequestContext* context = main_request_context();
|
|
|
| IOThread* const io_thread = profile_params->io_thread;
|
|
|
|
|