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

Unified Diff: chrome/browser/profiles/off_the_record_profile_io_data.cc

Issue 1239393003: Refactor main URLRequestContext creation to use URLRequestContextBuilder Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/off_the_record_profile_io_data.cc
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc
index e77e99a50b0b48a16cfab41cd89ae1da17b685fb..9c70a9949852cd8dab9dd37a714e2bff100ac303 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.cc
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc
@@ -35,6 +35,8 @@
#include "net/sdch/sdch_owner.h"
#include "net/ssl/channel_id_service.h"
#include "net/ssl/default_channel_id_store.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_job_factory_impl.h"
#include "storage/browser/database/database_tracker.h"
@@ -199,87 +201,92 @@ void OffTheRecordProfileIOData::InitializeInternal(
scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate,
ProfileParams* profile_params,
content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
- net::URLRequestContext* main_context = main_request_context();
+ content::URLRequestInterceptorScopedVector request_interceptors,
+ net::URLRequestContextBuilder* context_builder) const {
IOThread* const io_thread = profile_params->io_thread;
IOThread::Globals* const io_thread_globals = io_thread->globals();
- ApplyProfileParamsToContext(main_context);
-
- main_context->set_transport_security_state(transport_security_state());
+ ApplyProfileParamsToContext(context_builder);
- main_context->set_net_log(io_thread->net_log());
+ context_builder->set_net_log_unowned(io_thread->net_log());
- main_context->set_network_delegate(chrome_network_delegate.get());
-
- network_delegate_ = chrome_network_delegate.Pass();
-
- main_context->set_host_resolver(
+ context_builder->set_host_resolver_unowned(
io_thread_globals->host_resolver.get());
- main_context->set_http_auth_handler_factory(
+ context_builder->set_http_auth_handler_factory_unowned(
io_thread_globals->http_auth_handler_factory.get());
- main_context->set_fraudulent_certificate_reporter(
- fraudulent_certificate_reporter());
- main_context->set_proxy_service(proxy_service());
+ context_builder->set_proxy_service_unowned(proxy_service());
- main_context->set_cert_transparency_verifier(
+ context_builder->set_cert_transparency_verifier_unowned(
io_thread_globals->cert_transparency_verifier.get());
// For incognito, we use the default non-persistent HttpServerPropertiesImpl.
set_http_server_properties(
scoped_ptr<net::HttpServerProperties>(
new net::HttpServerPropertiesImpl()));
- main_context->set_http_server_properties(http_server_properties());
+ // The context receives a WeakPtr to the server properties.
+ context_builder->set_http_server_properties(http_server_properties());
// For incognito, we use a non-persistent channel ID store.
net::ChannelIDService* channel_id_service =
new net::ChannelIDService(
new net::DefaultChannelIDStore(NULL),
base::WorkerPool::GetTaskRunner(true));
- set_channel_id_service(channel_id_service);
- main_context->set_channel_id_service(channel_id_service);
using content::CookieStoreConfig;
- main_context->set_cookie_store(
+ scoped_refptr<net::CookieStore> cookie_store =
CreateCookieStore(CookieStoreConfig(
- base::FilePath(),
- CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
- NULL,
- profile_params->cookie_monster_delegate.get())));
+ base::FilePath(), CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, NULL,
+ profile_params->cookie_monster_delegate.get()));
+ context_builder->SetCookieAndChannelIdStores(
+ cookie_store.get(), make_scoped_ptr(channel_id_service));
net::HttpCache::BackendFactory* main_backend =
net::HttpCache::DefaultBackend::InMemory(0);
- main_http_factory_ = CreateMainHttpFactory(profile_params, main_backend);
- main_context->set_http_transaction_factory(main_http_factory_.get());
+ context_builder->set_http_transaction_factory_factory(
+ new ProfileIOData::HttpTransactionFactoryDelegate(this, profile_params,
+ main_backend));
+
#if !defined(DISABLE_FTP_SUPPORT)
ftp_factory_.reset(
- new net::FtpNetworkLayer(main_context->host_resolver()));
+ new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
#endif // !defined(DISABLE_FTP_SUPPORT)
scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
new net::URLRequestJobFactoryImpl());
+ scoped_ptr<net::NetworkDelegate> network_delegate =
+ chrome_network_delegate.Pass();
+
InstallProtocolHandlers(main_job_factory.get(), protocol_handlers);
- main_job_factory_ = SetUpJobFactoryDefaults(
+ context_builder->set_job_factory(SetUpJobFactoryDefaults(
main_job_factory.Pass(),
request_interceptors.Pass(),
profile_params->protocol_handler_interceptor.Pass(),
- main_context->network_delegate(),
- ftp_factory_.get());
- main_context->set_job_factory(main_job_factory_.get());
+ network_delegate.get(),
+ ftp_factory_.get()));
+ context_builder->set_network_delegate(network_delegate.release());
// Setup SDCH for this profile.
- sdch_manager_.reset(new net::SdchManager);
- sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context));
- main_context->set_sdch_manager(sdch_manager_.get());
+ context_builder->set_sdch_manager(new net::SdchManager);
#if defined(ENABLE_EXTENSIONS)
+ // This call initializes the extensions URLRequestContext *independently* of
+ // the, as-yet unbuilt, main URLRequestContext. If that ever changes, then
+ // this should not be called in this function.
InitializeExtensionsRequestContext(profile_params);
#endif
}
+void OffTheRecordProfileIOData::InitPostContextSetup(
+ ChromeNetworkDelegate* chrome_network_delegate) const {
+ net::URLRequestContext* main_context = main_request_context();
+
+ sdch_policy_.reset(
+ new net::SdchOwner(main_context->sdch_manager(), main_context));
+}
+
void OffTheRecordProfileIOData::
InitializeExtensionsRequestContext(ProfileParams* profile_params) const {
net::URLRequestContext* extensions_context = extensions_request_context();
@@ -348,7 +355,7 @@ net::URLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext(
net::HttpCache::BackendFactory* app_backend =
net::HttpCache::DefaultBackend::InMemory(0);
net::HttpNetworkSession* main_network_session =
- main_http_factory_->GetSession();
+ context->storage()->http_transaction_factory()->GetSession();
scoped_ptr<net::HttpCache> app_http_cache =
CreateHttpFactory(main_network_session, app_backend);
« no previous file with comments | « chrome/browser/profiles/off_the_record_profile_io_data.h ('k') | chrome/browser/profiles/profile_impl_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698