diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 00:41:29 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 00:41:29 +0000 |
commit | 2944afa8913462c5a6a873a8acb9d54a1741e627 (patch) | |
tree | 4ff0c5e953ca4cadc1dd4106b9c056a44f9e251e | |
parent | 7e885e72f21fdeb77895f67ca086286e85347807 (diff) | |
download | chromium_src-2944afa8913462c5a6a873a8acb9d54a1741e627.zip chromium_src-2944afa8913462c5a6a873a8acb9d54a1741e627.tar.gz chromium_src-2944afa8913462c5a6a873a8acb9d54a1741e627.tar.bz2 |
Add URLRequestJobFactories to URLRequestContexts without one.
Currently a URLRequestJobFactory is optional, as the global
URLRequestJobManager passes jobs on to the URLRequestFilter and
global http/https/ws/wss factories. In order to be able to
eliminate the global URLRequestJobManager object, first have to
give all contexts their own URLRequestJobFactory.
BUG=81979
TBR=ajwong@chromium.org (Who actually signed off on this, but Rietveld ignored his email).
Review URL: https://codereview.chromium.org/311393002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276867 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/io_thread.cc | 3 | ||||
-rw-r--r-- | chrome/browser/io_thread.h | 1 | ||||
-rw-r--r-- | chrome/browser/net/connection_tester.cc | 4 | ||||
-rw-r--r-- | chrome/browser/net/connection_tester_unittest.cc | 52 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_test_util_common.cc | 2 | ||||
-rw-r--r-- | remoting/base/url_request_context.cc | 2 | ||||
-rw-r--r-- | sync/internal_api/http_bridge.cc | 7 | ||||
-rw-r--r-- | sync/internal_api/public/http_bridge.h | 2 |
9 files changed, 27 insertions, 48 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 621ab62..b567990 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -259,6 +259,7 @@ ConstructSystemRequestContext(IOThread::Globals* globals, context->set_proxy_service(globals->system_proxy_service.get()); context->set_http_transaction_factory( globals->system_http_transaction_factory.get()); + context->set_job_factory(globals->system_url_request_job_factory.get()); context->set_cookie_store(globals->system_cookie_store.get()); context->set_server_bound_cert_service( globals->system_server_bound_cert_service.get()); @@ -1045,6 +1046,8 @@ void IOThread::InitSystemRequestContextOnIOThread() { globals_->system_http_transaction_factory.reset( new net::HttpNetworkLayer( new net::HttpNetworkSession(system_params))); + globals_->system_url_request_job_factory.reset( + new net::URLRequestJobFactoryImpl()); globals_->system_request_context.reset( ConstructSystemRequestContext(globals_, net_log_)); diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index 24212fe..0c9219e 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h @@ -143,6 +143,7 @@ class IOThread : public content::BrowserThreadDelegate { scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context; scoped_ptr<net::ProxyService> system_proxy_service; scoped_ptr<net::HttpTransactionFactory> system_http_transaction_factory; + scoped_ptr<net::URLRequestJobFactory> system_url_request_job_factory; scoped_ptr<net::URLRequestContext> system_request_context; SystemRequestContextLeakChecker system_request_context_leak_checker; // |system_cookie_store| and |system_server_bound_cert_service| are shared diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc index 533f8ac..37c5aea 100644 --- a/chrome/browser/net/connection_tester.cc +++ b/chrome/browser/net/connection_tester.cc @@ -36,6 +36,7 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_storage.h" +#include "net/url_request/url_request_job_factory_impl.h" #if !defined(OS_ANDROID) && !defined(OS_IOS) #include "chrome/browser/net/firefox_proxy_settings.h" @@ -134,6 +135,9 @@ class ExperimentURLRequestContext : public net::URLRequestContext { // In-memory cookie store. storage_.set_cookie_store( content::CreateCookieStore(content::CookieStoreConfig())); + // Creating a new job factory avoids added ProtocolHandlers and + // layered URLRequestInterceptingJobFactories. + storage_.set_job_factory(new net::URLRequestJobFactoryImpl()); return net::OK; } diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc index 6239c2b..eaf84bc 100644 --- a/chrome/browser/net/connection_tester_unittest.cc +++ b/chrome/browser/net/connection_tester_unittest.cc @@ -21,6 +21,7 @@ #include "net/ssl/ssl_config_service_defaults.h" #include "net/test/spawned_test_server/spawned_test_server.h" #include "net/url_request/url_request_context.h" +#include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -93,9 +94,7 @@ class ConnectionTesterTest : public PlatformTest { test_server_(net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, // Nothing is read in this directory. - base::FilePath(FILE_PATH_LITERAL("chrome"))), - proxy_script_fetcher_context_(new net::URLRequestContext) { - InitializeRequestContext(); + base::FilePath(FILE_PATH_LITERAL("chrome"))) { } protected: @@ -107,56 +106,15 @@ class ConnectionTesterTest : public PlatformTest { base::MessageLoopForIO message_loop_; content::TestBrowserThread io_thread_; net::SpawnedTestServer test_server_; + net::TestURLRequestContext proxy_script_fetcher_context_; ConnectionTesterDelegate test_delegate_; - net::MockHostResolver host_resolver_; - scoped_ptr<net::CertVerifier> cert_verifier_; - scoped_ptr<net::TransportSecurityState> transport_security_state_; - scoped_ptr<net::ProxyService> proxy_service_; - scoped_refptr<net::SSLConfigService> ssl_config_service_; - scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; - net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; - net::HttpServerPropertiesImpl http_server_properties_impl_; - scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_; - - private: - void InitializeRequestContext() { - proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); - cert_verifier_.reset(new net::MockCertVerifier); - transport_security_state_.reset(new net::TransportSecurityState); - proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get()); - proxy_script_fetcher_context_->set_transport_security_state( - transport_security_state_.get()); - proxy_script_fetcher_context_->set_http_auth_handler_factory( - &http_auth_handler_factory_); - proxy_service_.reset(net::ProxyService::CreateDirect()); - proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); - ssl_config_service_ = new net::SSLConfigServiceDefaults; - net::HttpNetworkSession::Params session_params; - session_params.host_resolver = &host_resolver_; - session_params.cert_verifier = cert_verifier_.get(); - session_params.transport_security_state = transport_security_state_.get(); - session_params.http_auth_handler_factory = &http_auth_handler_factory_; - session_params.ssl_config_service = ssl_config_service_.get(); - session_params.proxy_service = proxy_service_.get(); - session_params.http_server_properties = - http_server_properties_impl_.GetWeakPtr(); - scoped_refptr<net::HttpNetworkSession> network_session( - new net::HttpNetworkSession(session_params)); - http_transaction_factory_.reset( - new net::HttpNetworkLayer(network_session.get())); - proxy_script_fetcher_context_->set_http_transaction_factory( - http_transaction_factory_.get()); - // In-memory cookie store. - proxy_script_fetcher_context_->set_cookie_store( - content::CreateCookieStore(content::CookieStoreConfig())); - } }; TEST_F(ConnectionTesterTest, RunAllTests) { ASSERT_TRUE(test_server_.Start()); ConnectionTester tester(&test_delegate_, - proxy_script_fetcher_context_.get(), + &proxy_script_fetcher_context_, NULL); // Start the test suite on URL "echoall". @@ -183,7 +141,7 @@ TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { scoped_ptr<ConnectionTester> tester( new ConnectionTester(&test_delegate_, - proxy_script_fetcher_context_.get(), + &proxy_script_fetcher_context_, NULL)); // Start the test suite on URL "echoall". diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index 005ae15..edc2104 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -25,6 +25,7 @@ #include "net/proxy/proxy_service.h" #include "net/ssl/ssl_config_service_defaults.h" #include "net/url_request/static_http_user_agent_settings.h" +#include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_throttler_manager.h" namespace { @@ -136,6 +137,7 @@ ServiceURLRequestContext::ServiceURLRequestContext( network_session.get(), net::HttpCache::DefaultBackend::InMemory(0))); // In-memory cookie store. storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); + storage_.set_job_factory(new net::URLRequestJobFactoryImpl()); storage_.set_http_user_agent_settings(new net::StaticHttpUserAgentSettings( "en-us,fr", user_agent)); } diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc index e12aff4..b943c31 100644 --- a/net/spdy/spdy_test_util_common.cc +++ b/net/spdy/spdy_test_util_common.cc @@ -24,6 +24,7 @@ #include "net/spdy/spdy_session.h" #include "net/spdy/spdy_session_pool.h" #include "net/spdy/spdy_stream.h" +#include "net/url_request/url_request_job_factory_impl.h" namespace net { @@ -475,6 +476,7 @@ SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol, host_resolver())); storage_.set_http_server_properties( scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); + storage_.set_job_factory(new URLRequestJobFactoryImpl()); net::HttpNetworkSession::Params params; params.client_socket_factory = &socket_factory_; params.host_resolver = host_resolver(); diff --git a/remoting/base/url_request_context.cc b/remoting/base/url_request_context.cc index 60f620d..39985ab 100644 --- a/remoting/base/url_request_context.cc +++ b/remoting/base/url_request_context.cc @@ -15,6 +15,7 @@ #include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_service.h" #include "net/ssl/ssl_config_service_defaults.h" +#include "net/url_request/url_request_job_factory_impl.h" #include "remoting/base/vlog_net_log.h" #if defined(OS_WIN) @@ -95,6 +96,7 @@ URLRequestContext::URLRequestContext( scoped_ptr<net::HttpServerProperties>( new net::HttpServerPropertiesImpl())); storage_.set_transport_security_state(new net::TransportSecurityState); + storage_.set_job_factory(new net::URLRequestJobFactoryImpl()); net::HttpNetworkSession::Params session_params; session_params.host_resolver = host_resolver(); diff --git a/sync/internal_api/http_bridge.cc b/sync/internal_api/http_bridge.cc index ffcaf9a..c4e096c 100644 --- a/sync/internal_api/http_bridge.cc +++ b/sync/internal_api/http_bridge.cc @@ -16,6 +16,7 @@ #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_request_context.h" +#include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_status.h" #include "sync/internal_api/public/base/cancelation_signal.h" @@ -122,7 +123,8 @@ HttpBridge::RequestContext::RequestContext( network_task_runner, const std::string& user_agent) : baseline_context_(baseline_context), - network_task_runner_(network_task_runner) { + network_task_runner_(network_task_runner), + job_factory_(new net::URLRequestJobFactoryImpl()) { DCHECK(!user_agent.empty()); // Create empty, in-memory cookie store. @@ -133,6 +135,9 @@ HttpBridge::RequestContext::RequestContext( set_proxy_service(baseline_context->proxy_service()); set_ssl_config_service(baseline_context->ssl_config_service()); + // Use its own job factory, which only supports http and https. + set_job_factory(job_factory_.get()); + // We want to share the HTTP session data with the network layer factory, // which includes auth_cache for proxies. // Session is not refcounted so we need to be careful to not lose the parent diff --git a/sync/internal_api/public/http_bridge.h b/sync/internal_api/public/http_bridge.h index 145e36f..3988c7c 100644 --- a/sync/internal_api/public/http_bridge.h +++ b/sync/internal_api/public/http_bridge.h @@ -33,6 +33,7 @@ namespace net { class HttpResponseHeaders; class HttpUserAgentSettings; class URLFetcher; +class URLRequestJobFactory; } namespace syncer { @@ -72,6 +73,7 @@ class SYNC_EXPORT_PRIVATE HttpBridge net::URLRequestContext* const baseline_context_; const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_; + scoped_ptr<net::URLRequestJobFactory> job_factory_; DISALLOW_COPY_AND_ASSIGN(RequestContext); }; |