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

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

Issue 2934153002: Add virtual ProfileIOData methods related to URLRequestContext creation. (Closed)
Patch Set: . Created 3 years, 6 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 ProfileParams* profile_params, 462 ProfileParams* profile_params,
463 content::ProtocolHandlerMap* protocol_handlers, 463 content::ProtocolHandlerMap* protocol_handlers,
464 content::URLRequestInterceptorScopedVector request_interceptors) const { 464 content::URLRequestInterceptorScopedVector request_interceptors) const {
465 net::URLRequestContext* main_context = main_request_context(); 465 net::URLRequestContext* main_context = main_request_context();
466 net::URLRequestContextStorage* main_context_storage = 466 net::URLRequestContextStorage* main_context_storage =
467 main_request_context_storage(); 467 main_request_context_storage();
468 468
469 IOThread* const io_thread = profile_params->io_thread; 469 IOThread* const io_thread = profile_params->io_thread;
470 IOThread::Globals* const io_thread_globals = io_thread->globals(); 470 IOThread::Globals* const io_thread_globals = io_thread->globals();
471 471
472 if (lazy_params_->http_server_properties_manager) {
473 lazy_params_->http_server_properties_manager->InitializeOnNetworkSequence();
474 main_context_storage->set_http_server_properties(
475 std::move(lazy_params_->http_server_properties_manager));
476 }
477
478 main_context->set_network_quality_estimator(
479 io_thread_globals->network_quality_estimator.get());
480
481 // Create a single task runner to use with the CookieStore and ChannelIDStore.
482 scoped_refptr<base::SequencedTaskRunner> cookie_background_task_runner =
483 base::CreateSequencedTaskRunnerWithTraits(
484 {base::MayBlock(), base::TaskPriority::BACKGROUND,
485 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
486
487 // Set up server bound cert service.
488 DCHECK(!lazy_params_->channel_id_path.empty());
489 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db =
490 new QuotaPolicyChannelIDStore(lazy_params_->channel_id_path,
491 cookie_background_task_runner,
492 lazy_params_->special_storage_policy.get());
493 main_context_storage->set_channel_id_service(
494 base::MakeUnique<net::ChannelIDService>(
495 new net::DefaultChannelIDStore(channel_id_db.get())));
496
497 // Set up cookie store.
498 DCHECK(!lazy_params_->cookie_path.empty());
499
500 content::CookieStoreConfig cookie_config(
501 lazy_params_->cookie_path, lazy_params_->session_cookie_mode,
502 lazy_params_->special_storage_policy.get(),
503 profile_params->cookie_monster_delegate.get());
504 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
505 cookie_config.channel_id_service = main_context->channel_id_service();
506 cookie_config.background_task_runner = cookie_background_task_runner;
507 main_context_storage->set_cookie_store(
508 content::CreateCookieStore(cookie_config));
509
510 main_context->cookie_store()->SetChannelIDServiceID(
511 main_context->channel_id_service()->GetUniqueID());
512
513 std::unique_ptr<net::HttpCache::BackendFactory> main_backend(
514 new net::HttpCache::DefaultBackend(
515 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path,
516 lazy_params_->cache_max_size,
517 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)));
518 main_context_storage->set_http_network_session(
519 CreateHttpNetworkSession(*profile_params));
520 main_context_storage->set_http_transaction_factory(CreateMainHttpFactory(
521 main_context_storage->http_network_session(), std::move(main_backend)));
522
523 std::unique_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
524 new net::URLRequestJobFactoryImpl());
525 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers);
526
527 // Install the Offline Page Interceptor. 472 // Install the Offline Page Interceptor.
528 #if defined(OS_ANDROID) 473 #if defined(OS_ANDROID)
529 request_interceptors.push_back( 474 request_interceptors.push_back(
530 base::MakeUnique<offline_pages::OfflinePageRequestInterceptor>( 475 base::MakeUnique<offline_pages::OfflinePageRequestInterceptor>(
531 previews_io_data())); 476 previews_io_data()));
532 #endif 477 #endif
533 478
534 // The data reduction proxy interceptor should be as close to the network 479 // The data reduction proxy interceptor should be as close to the network
535 // as possible. 480 // as possible.
536 request_interceptors.insert( 481 request_interceptors.insert(
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 content::URLRequestInterceptorScopedVector request_interceptors) const { 693 content::URLRequestInterceptorScopedVector request_interceptors) const {
749 // We create per-app contexts on demand, unlike the others above. 694 // We create per-app contexts on demand, unlike the others above.
750 net::URLRequestContext* app_request_context = InitializeAppRequestContext( 695 net::URLRequestContext* app_request_context = InitializeAppRequestContext(
751 main_context, partition_descriptor, 696 main_context, partition_descriptor,
752 std::move(protocol_handler_interceptor), protocol_handlers, 697 std::move(protocol_handler_interceptor), protocol_handlers,
753 std::move(request_interceptors)); 698 std::move(request_interceptors));
754 DCHECK(app_request_context); 699 DCHECK(app_request_context);
755 return app_request_context; 700 return app_request_context;
756 } 701 }
757 702
703 std::unique_ptr<net::HttpServerProperties>
704 ProfileImplIOData::GetHttpServerProperties() const {
705 if (!lazy_params_->http_server_properties_manager)
706 return base::MakeUnique<net::HttpServerPropertiesImpl>();
707 lazy_params_->http_server_properties_manager->InitializeOnNetworkSequence();
708 return std::move(lazy_params_->http_server_properties_manager);
709 }
710
711 void ProfileImplIOData::GetCookieAndChannelIDStores(
712 std::unique_ptr<net::CookieStore>* cookie_store,
713 std::unique_ptr<net::ChannelIDService>* channel_id_service) const {
714 // Create a single task runner to use with the CookieStore and ChannelIDStore.
715 scoped_refptr<base::SequencedTaskRunner> cookie_background_task_runner =
716 base::CreateSequencedTaskRunnerWithTraits(
717 {base::MayBlock(), base::TaskPriority::BACKGROUND,
718 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
719
720 // Set up server bound cert service.
721 DCHECK(!lazy_params_->channel_id_path.empty());
722 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db =
723 new QuotaPolicyChannelIDStore(lazy_params_->channel_id_path,
724 cookie_background_task_runner,
725 lazy_params_->special_storage_policy.get());
726 *channel_id_service = base::MakeUnique<net::ChannelIDService>(
727 new net::DefaultChannelIDStore(channel_id_db.get()));
728
729 // Set up cookie store.
730 DCHECK(!lazy_params_->cookie_path.empty());
731
732 content::CookieStoreConfig cookie_config(
733 lazy_params_->cookie_path, lazy_params_->session_cookie_mode,
734 lazy_params_->special_storage_policy.get(),
735 profile_params()->cookie_monster_delegate.get());
736 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate();
737 cookie_config.channel_id_service = channel_id_service->get();
738 cookie_config.background_task_runner = cookie_background_task_runner;
739 *cookie_store = content::CreateCookieStore(cookie_config);
740 }
741
742 bool ProfileImplIOData::UseNetworkQualityEstimator() const {
743 return true;
744 }
745
746 std::unique_ptr<net::HttpCache::BackendFactory> ProfileImplIOData::GetCacheBacke ndFactory() const {
747 return base::MakeUnique<net::HttpCache::DefaultBackend>(
748 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path,
749 lazy_params_->cache_max_size,
750 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE));
751 }
752
758 net::URLRequestContext* 753 net::URLRequestContext*
759 ProfileImplIOData::AcquireIsolatedMediaRequestContext( 754 ProfileImplIOData::AcquireIsolatedMediaRequestContext(
760 net::URLRequestContext* app_context, 755 net::URLRequestContext* app_context,
761 const StoragePartitionDescriptor& partition_descriptor) const { 756 const StoragePartitionDescriptor& partition_descriptor) const {
762 // We create per-app media contexts on demand, unlike the others above. 757 // We create per-app media contexts on demand, unlike the others above.
763 net::URLRequestContext* media_request_context = InitializeMediaRequestContext( 758 net::URLRequestContext* media_request_context = InitializeMediaRequestContext(
764 app_context, partition_descriptor, "isolated_media"); 759 app_context, partition_descriptor, "isolated_media");
765 DCHECK(media_request_context); 760 DCHECK(media_request_context);
766 return media_request_context; 761 return media_request_context;
767 } 762 }
(...skipping 17 matching lines...) Expand all
785 const base::Closure& completion) { 780 const base::Closure& completion) {
786 DCHECK_CURRENTLY_ON(BrowserThread::IO); 781 DCHECK_CURRENTLY_ON(BrowserThread::IO);
787 DCHECK(initialized()); 782 DCHECK(initialized());
788 783
789 // Completes synchronously. 784 // Completes synchronously.
790 main_request_context()->transport_security_state()->DeleteAllDynamicDataSince( 785 main_request_context()->transport_security_state()->DeleteAllDynamicDataSince(
791 time); 786 time);
792 DCHECK(http_server_properties_manager_); 787 DCHECK(http_server_properties_manager_);
793 http_server_properties_manager_->Clear(completion); 788 http_server_properties_manager_->Clear(completion);
794 } 789 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698