OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/browser_state/chrome_browser_state_io_data.h" | 5 #include "ios/chrome/browser/browser_state/chrome_browser_state_io_data.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/debug/alias.h" | 17 #include "base/debug/alias.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ChromeBrowserStateIOData::AppRequestContext::AppRequestContext() {} | 134 ChromeBrowserStateIOData::AppRequestContext::AppRequestContext() {} |
134 | 135 |
135 void ChromeBrowserStateIOData::AppRequestContext::SetCookieStore( | 136 void ChromeBrowserStateIOData::AppRequestContext::SetCookieStore( |
136 net::CookieStore* cookie_store) { | 137 net::CookieStore* cookie_store) { |
137 cookie_store_ = cookie_store; | 138 cookie_store_ = cookie_store; |
138 set_cookie_store(cookie_store); | 139 set_cookie_store(cookie_store); |
139 } | 140 } |
140 | 141 |
141 void ChromeBrowserStateIOData::AppRequestContext::SetHttpTransactionFactory( | 142 void ChromeBrowserStateIOData::AppRequestContext::SetHttpTransactionFactory( |
142 scoped_ptr<net::HttpTransactionFactory> http_factory) { | 143 scoped_ptr<net::HttpTransactionFactory> http_factory) { |
143 http_factory_ = http_factory.Pass(); | 144 http_factory_ = std::move(http_factory); |
144 set_http_transaction_factory(http_factory_.get()); | 145 set_http_transaction_factory(http_factory_.get()); |
145 } | 146 } |
146 | 147 |
147 void ChromeBrowserStateIOData::AppRequestContext::SetJobFactory( | 148 void ChromeBrowserStateIOData::AppRequestContext::SetJobFactory( |
148 scoped_ptr<net::URLRequestJobFactory> job_factory) { | 149 scoped_ptr<net::URLRequestJobFactory> job_factory) { |
149 job_factory_ = job_factory.Pass(); | 150 job_factory_ = std::move(job_factory); |
150 set_job_factory(job_factory_.get()); | 151 set_job_factory(job_factory_.get()); |
151 } | 152 } |
152 | 153 |
153 ChromeBrowserStateIOData::AppRequestContext::~AppRequestContext() { | 154 ChromeBrowserStateIOData::AppRequestContext::~AppRequestContext() { |
154 AssertNoURLRequests(); | 155 AssertNoURLRequests(); |
155 } | 156 } |
156 | 157 |
157 ChromeBrowserStateIOData::ProfileParams::ProfileParams() | 158 ChromeBrowserStateIOData::ProfileParams::ProfileParams() |
158 : io_thread(nullptr), browser_state(nullptr) {} | 159 : io_thread(nullptr), browser_state(nullptr) {} |
159 | 160 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 302 } |
302 | 303 |
303 bool ChromeBrowserStateIOData::IsDataReductionProxyEnabled() const { | 304 bool ChromeBrowserStateIOData::IsDataReductionProxyEnabled() const { |
304 return data_reduction_proxy_io_data() && | 305 return data_reduction_proxy_io_data() && |
305 data_reduction_proxy_io_data()->IsEnabled(); | 306 data_reduction_proxy_io_data()->IsEnabled(); |
306 } | 307 } |
307 | 308 |
308 void ChromeBrowserStateIOData::set_data_reduction_proxy_io_data( | 309 void ChromeBrowserStateIOData::set_data_reduction_proxy_io_data( |
309 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | 310 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
310 data_reduction_proxy_io_data) const { | 311 data_reduction_proxy_io_data) const { |
311 data_reduction_proxy_io_data_ = data_reduction_proxy_io_data.Pass(); | 312 data_reduction_proxy_io_data_ = std::move(data_reduction_proxy_io_data); |
312 } | 313 } |
313 | 314 |
314 base::WeakPtr<net::HttpServerProperties> | 315 base::WeakPtr<net::HttpServerProperties> |
315 ChromeBrowserStateIOData::http_server_properties() const { | 316 ChromeBrowserStateIOData::http_server_properties() const { |
316 return http_server_properties_->GetWeakPtr(); | 317 return http_server_properties_->GetWeakPtr(); |
317 } | 318 } |
318 | 319 |
319 void ChromeBrowserStateIOData::set_http_server_properties( | 320 void ChromeBrowserStateIOData::set_http_server_properties( |
320 scoped_ptr<net::HttpServerProperties> http_server_properties) const { | 321 scoped_ptr<net::HttpServerProperties> http_server_properties) const { |
321 http_server_properties_ = http_server_properties.Pass(); | 322 http_server_properties_ = std::move(http_server_properties); |
322 } | 323 } |
323 | 324 |
324 void ChromeBrowserStateIOData::Init( | 325 void ChromeBrowserStateIOData::Init( |
325 ProtocolHandlerMap* protocol_handlers) const { | 326 ProtocolHandlerMap* protocol_handlers) const { |
326 // The basic logic is implemented here. The specific initialization | 327 // The basic logic is implemented here. The specific initialization |
327 // is done in InitializeInternal(), implemented by subtypes. Static helper | 328 // is done in InitializeInternal(), implemented by subtypes. Static helper |
328 // functions have been provided to assist in common operations. | 329 // functions have been provided to assist in common operations. |
329 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); | 330 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); |
330 DCHECK(!initialized_); | 331 DCHECK(!initialized_); |
331 | 332 |
(...skipping 13 matching lines...) Expand all Loading... |
345 new IOSChromeNetworkDelegate()); | 346 new IOSChromeNetworkDelegate()); |
346 | 347 |
347 network_delegate->set_cookie_settings(profile_params_->cookie_settings.get()); | 348 network_delegate->set_cookie_settings(profile_params_->cookie_settings.get()); |
348 network_delegate->set_enable_do_not_track(&enable_do_not_track_); | 349 network_delegate->set_enable_do_not_track(&enable_do_not_track_); |
349 | 350 |
350 // NOTE: Proxy service uses the default io thread network delegate, not the | 351 // NOTE: Proxy service uses the default io thread network delegate, not the |
351 // delegate just created. | 352 // delegate just created. |
352 proxy_service_ = ios::ProxyServiceFactory::CreateProxyService( | 353 proxy_service_ = ios::ProxyServiceFactory::CreateProxyService( |
353 io_thread->net_log(), nullptr, | 354 io_thread->net_log(), nullptr, |
354 io_thread_globals->system_network_delegate.get(), | 355 io_thread_globals->system_network_delegate.get(), |
355 profile_params_->proxy_config_service.Pass(), | 356 std::move(profile_params_->proxy_config_service), |
356 true /* quick_check_enabled */); | 357 true /* quick_check_enabled */); |
357 transport_security_state_.reset(new net::TransportSecurityState()); | 358 transport_security_state_.reset(new net::TransportSecurityState()); |
358 base::SequencedWorkerPool* pool = web::WebThread::GetBlockingPool(); | 359 base::SequencedWorkerPool* pool = web::WebThread::GetBlockingPool(); |
359 transport_security_persister_.reset(new net::TransportSecurityPersister( | 360 transport_security_persister_.reset(new net::TransportSecurityPersister( |
360 transport_security_state_.get(), profile_params_->path, | 361 transport_security_state_.get(), profile_params_->path, |
361 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 362 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
362 pool->GetSequenceToken(), base::SequencedWorkerPool::BLOCK_SHUTDOWN), | 363 pool->GetSequenceToken(), base::SequencedWorkerPool::BLOCK_SHUTDOWN), |
363 IsOffTheRecord())); | 364 IsOffTheRecord())); |
364 | 365 |
365 certificate_report_sender_.reset(new net::CertificateReportSender( | 366 certificate_report_sender_.reset(new net::CertificateReportSender( |
366 main_request_context_.get(), | 367 main_request_context_.get(), |
367 net::CertificateReportSender::DO_NOT_SEND_COOKIES)); | 368 net::CertificateReportSender::DO_NOT_SEND_COOKIES)); |
368 transport_security_state_->SetReportSender(certificate_report_sender_.get()); | 369 transport_security_state_->SetReportSender(certificate_report_sender_.get()); |
369 | 370 |
370 // Take ownership over these parameters. | 371 // Take ownership over these parameters. |
371 cookie_settings_ = profile_params_->cookie_settings; | 372 cookie_settings_ = profile_params_->cookie_settings; |
372 host_content_settings_map_ = profile_params_->host_content_settings_map; | 373 host_content_settings_map_ = profile_params_->host_content_settings_map; |
373 | 374 |
374 main_request_context_->set_cert_verifier( | 375 main_request_context_->set_cert_verifier( |
375 io_thread_globals->cert_verifier.get()); | 376 io_thread_globals->cert_verifier.get()); |
376 | 377 |
377 InitializeInternal(network_delegate.Pass(), profile_params_.get(), | 378 InitializeInternal(std::move(network_delegate), profile_params_.get(), |
378 protocol_handlers); | 379 protocol_handlers); |
379 | 380 |
380 profile_params_.reset(); | 381 profile_params_.reset(); |
381 initialized_ = true; | 382 initialized_ = true; |
382 } | 383 } |
383 | 384 |
384 void ChromeBrowserStateIOData::ApplyProfileParamsToContext( | 385 void ChromeBrowserStateIOData::ApplyProfileParamsToContext( |
385 net::URLRequestContext* context) const { | 386 net::URLRequestContext* context) const { |
386 context->set_http_user_agent_settings(chrome_http_user_agent_settings_.get()); | 387 context->set_http_user_agent_settings(chrome_http_user_agent_settings_.get()); |
387 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); | 388 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); |
(...skipping 15 matching lines...) Expand all Loading... |
403 | 404 |
404 set_protocol = job_factory->SetProtocolHandler( | 405 set_protocol = job_factory->SetProtocolHandler( |
405 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler())); | 406 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler())); |
406 DCHECK(set_protocol); | 407 DCHECK(set_protocol); |
407 | 408 |
408 job_factory->SetProtocolHandler( | 409 job_factory->SetProtocolHandler( |
409 url::kAboutScheme, | 410 url::kAboutScheme, |
410 make_scoped_ptr(new about_handler::AboutProtocolHandler())); | 411 make_scoped_ptr(new about_handler::AboutProtocolHandler())); |
411 | 412 |
412 // Set up interceptors in the reverse order. | 413 // Set up interceptors in the reverse order. |
413 scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass(); | 414 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
| 415 std::move(job_factory); |
414 for (URLRequestInterceptorScopedVector::reverse_iterator i = | 416 for (URLRequestInterceptorScopedVector::reverse_iterator i = |
415 request_interceptors.rbegin(); | 417 request_interceptors.rbegin(); |
416 i != request_interceptors.rend(); ++i) { | 418 i != request_interceptors.rend(); ++i) { |
417 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 419 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
418 top_job_factory.Pass(), make_scoped_ptr(*i))); | 420 std::move(top_job_factory), make_scoped_ptr(*i))); |
419 } | 421 } |
420 request_interceptors.weak_clear(); | 422 request_interceptors.weak_clear(); |
421 return top_job_factory.Pass(); | 423 return top_job_factory; |
422 } | 424 } |
423 | 425 |
424 void ChromeBrowserStateIOData::ShutdownOnUIThread( | 426 void ChromeBrowserStateIOData::ShutdownOnUIThread( |
425 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters) { | 427 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters) { |
426 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); | 428 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); |
427 | 429 |
428 google_services_user_account_id_.Destroy(); | 430 google_services_user_account_id_.Destroy(); |
429 enable_referrers_.Destroy(); | 431 enable_referrers_.Destroy(); |
430 enable_do_not_track_.Destroy(); | 432 enable_do_not_track_.Destroy(); |
431 enable_metrics_.Destroy(); | 433 enable_metrics_.Destroy(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 params.proxy_delegate = data_reduction_proxy_io_data_->proxy_delegate(); | 474 params.proxy_delegate = data_reduction_proxy_io_data_->proxy_delegate(); |
473 | 475 |
474 return scoped_ptr<net::HttpNetworkSession>( | 476 return scoped_ptr<net::HttpNetworkSession>( |
475 new net::HttpNetworkSession(params)); | 477 new net::HttpNetworkSession(params)); |
476 } | 478 } |
477 | 479 |
478 scoped_ptr<net::HttpCache> ChromeBrowserStateIOData::CreateMainHttpFactory( | 480 scoped_ptr<net::HttpCache> ChromeBrowserStateIOData::CreateMainHttpFactory( |
479 net::HttpNetworkSession* session, | 481 net::HttpNetworkSession* session, |
480 scoped_ptr<net::HttpCache::BackendFactory> main_backend) const { | 482 scoped_ptr<net::HttpCache::BackendFactory> main_backend) const { |
481 return scoped_ptr<net::HttpCache>( | 483 return scoped_ptr<net::HttpCache>( |
482 new net::HttpCache(session, main_backend.Pass(), true)); | 484 new net::HttpCache(session, std::move(main_backend), true)); |
483 } | 485 } |
484 | 486 |
485 scoped_ptr<net::HttpCache> ChromeBrowserStateIOData::CreateHttpFactory( | 487 scoped_ptr<net::HttpCache> ChromeBrowserStateIOData::CreateHttpFactory( |
486 net::HttpNetworkSession* shared_session, | 488 net::HttpNetworkSession* shared_session, |
487 scoped_ptr<net::HttpCache::BackendFactory> backend) const { | 489 scoped_ptr<net::HttpCache::BackendFactory> backend) const { |
488 return scoped_ptr<net::HttpCache>( | 490 return scoped_ptr<net::HttpCache>( |
489 new net::HttpCache(shared_session, backend.Pass(), true)); | 491 new net::HttpCache(shared_session, std::move(backend), true)); |
490 } | 492 } |
OLD | NEW |