diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-08 02:33:53 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-08 02:33:53 +0000 |
commit | 305ed87d5bb35fbdde0240c3d0f801be47909453 (patch) | |
tree | 61810b2987d2c51a0ce169fcfa25144c489552a1 /chrome/service | |
parent | 176fe9ad192f383d92336af2e7721d6cf7b59a50 (diff) | |
download | chromium_src-305ed87d5bb35fbdde0240c3d0f801be47909453.zip chromium_src-305ed87d5bb35fbdde0240c3d0f801be47909453.tar.gz chromium_src-305ed87d5bb35fbdde0240c3d0f801be47909453.tar.bz2 |
Switch to using URLRequestContextBuilder to create some contexts.
Also add missing functionality to URLRequestContextBuilder to fit
their needs. This is intended to simplify code to initialize the
network stack, and make it easier to refactor network stack
initialization.
BUG=388836
Review URL: https://codereview.chromium.org/354693004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r-- | chrome/service/cloud_print/cloud_print_auth.cc | 2 | ||||
-rw-r--r-- | chrome/service/cloud_print/cloud_print_proxy_backend.cc | 2 | ||||
-rw-r--r-- | chrome/service/cloud_print/cloud_print_url_fetcher.cc | 2 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context_getter.cc (renamed from chrome/service/net/service_url_request_context.cc) | 74 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context_getter.h (renamed from chrome/service/net/service_url_request_context.h) | 25 | ||||
-rw-r--r-- | chrome/service/service_process.cc | 2 |
6 files changed, 22 insertions, 85 deletions
diff --git a/chrome/service/cloud_print/cloud_print_auth.cc b/chrome/service/cloud_print/cloud_print_auth.cc index 482b9c3..b52ba0c 100644 --- a/chrome/service/cloud_print/cloud_print_auth.cc +++ b/chrome/service/cloud_print/cloud_print_auth.cc @@ -10,7 +10,7 @@ #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/common/cloud_print/cloud_print_helpers.h" #include "chrome/service/cloud_print/cloud_print_token_store.h" -#include "chrome/service/net/service_url_request_context.h" +#include "chrome/service/net/service_url_request_context_getter.h" #include "chrome/service/service_process.h" #include "google_apis/gaia/gaia_urls.h" diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc index 52205cd..228aba7 100644 --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc @@ -19,7 +19,7 @@ #include "chrome/service/cloud_print/cloud_print_service_helpers.h" #include "chrome/service/cloud_print/cloud_print_token_store.h" #include "chrome/service/cloud_print/connector_settings.h" -#include "chrome/service/net/service_url_request_context.h" +#include "chrome/service/net/service_url_request_context_getter.h" #include "chrome/service/service_process.h" #include "components/cloud_devices/common/cloud_devices_switches.h" #include "google_apis/gaia/gaia_oauth_client.h" diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher.cc b/chrome/service/cloud_print/cloud_print_url_fetcher.cc index 757b158..b1f0b51 100644 --- a/chrome/service/cloud_print/cloud_print_url_fetcher.cc +++ b/chrome/service/cloud_print/cloud_print_url_fetcher.cc @@ -11,7 +11,7 @@ #include "chrome/common/cloud_print/cloud_print_helpers.h" #include "chrome/service/cloud_print/cloud_print_service_helpers.h" #include "chrome/service/cloud_print/cloud_print_token_store.h" -#include "chrome/service/net/service_url_request_context.h" +#include "chrome/service/net/service_url_request_context_getter.h" #include "chrome/service/service_process.h" #include "net/base/load_flags.h" #include "net/http/http_status_code.h" diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context_getter.cc index edc2104..8f0de43 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context_getter.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/service/net/service_url_request_context.h" +#include "chrome/service/net/service_url_request_context_getter.h" #if defined(OS_POSIX) && !defined(OS_MACOSX) #include <sys/utsname.h> @@ -14,19 +14,9 @@ #include "base/sys_info.h" #include "chrome/common/chrome_version_info.h" #include "chrome/service/service_process.h" -#include "net/cert/cert_verifier.h" -#include "net/cookies/cookie_monster.h" -#include "net/dns/host_resolver.h" -#include "net/http/http_auth_handler_factory.h" -#include "net/http/http_cache.h" -#include "net/http/http_network_session.h" -#include "net/http/http_server_properties_impl.h" #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/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" +#include "net/url_request/url_request_context_builder.h" namespace { // Copied from webkit/glue/user_agent.cc. We don't want to pull in a dependency @@ -86,6 +76,7 @@ std::string BuildOSCpuInfo() { return os_cpu; } +// Returns the default user agent. std::string MakeUserAgentForServiceProcess() { std::string user_agent; chrome::VersionInfo version_info; @@ -106,51 +97,10 @@ std::string MakeUserAgentForServiceProcess() { } // namespace -ServiceURLRequestContext::ServiceURLRequestContext( - const std::string& user_agent, - net::ProxyConfigService* net_proxy_config_service) - : storage_(this) { - storage_.set_host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); - storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( - net_proxy_config_service, 0u, NULL)); - storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); - storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); - storage_.set_http_auth_handler_factory( - net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); - storage_.set_http_server_properties( - scoped_ptr<net::HttpServerProperties>( - new net::HttpServerPropertiesImpl())); - storage_.set_transport_security_state(new net::TransportSecurityState); - storage_.set_throttler_manager(new net::URLRequestThrottlerManager); - - net::HttpNetworkSession::Params session_params; - session_params.host_resolver = host_resolver(); - session_params.cert_verifier = cert_verifier(); - session_params.transport_security_state = transport_security_state(); - session_params.proxy_service = proxy_service(); - session_params.ssl_config_service = ssl_config_service(); - session_params.http_auth_handler_factory = http_auth_handler_factory(); - session_params.http_server_properties = http_server_properties(); - scoped_refptr<net::HttpNetworkSession> network_session( - new net::HttpNetworkSession(session_params)); - storage_.set_http_transaction_factory(new net::HttpCache( - 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)); -} - -ServiceURLRequestContext::~ServiceURLRequestContext() { -} - ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() - : network_task_runner_( + : user_agent_(MakeUserAgentForServiceProcess()), + network_task_runner_( g_service_process->io_thread()->message_loop_proxy()) { - // Build the default user agent. - user_agent_ = MakeUserAgentForServiceProcess(); - // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a // MessageLoopProxy* instead of MessageLoop*. DCHECK(g_service_process); @@ -161,10 +111,14 @@ ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() net::URLRequestContext* ServiceURLRequestContextGetter::GetURLRequestContext() { - if (!url_request_context_.get()) - url_request_context_.reset( - new ServiceURLRequestContext(user_agent_, - proxy_config_service_.release())); + if (!url_request_context_.get()) { + net::URLRequestContextBuilder builder; + builder.set_user_agent(user_agent_); + builder.set_accept_language("en-us,fr"); + builder.set_proxy_config_service(proxy_config_service_.release()); + builder.set_throttling_enabled(true); + url_request_context_.reset(builder.Build()); + } return url_request_context_.get(); } diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context_getter.h index c409ede..35fcea7 100644 --- a/chrome/service/net/service_url_request_context.h +++ b/chrome/service/net/service_url_request_context_getter.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ -#define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ +#ifndef CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_GETTER_H_ +#define CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_GETTER_H_ #include <string> @@ -28,23 +28,6 @@ namespace net { class ProxyConfigService; } -// Subclass of net::URLRequestContext which can be used to store extra -// information for requests. This subclass is meant to be used in the service -// process where the profile is not available. -// -class ServiceURLRequestContext : public net::URLRequestContext { - public: - // This context takes ownership of |net_proxy_config_service|. - explicit ServiceURLRequestContext( - const std::string& user_agent, - net::ProxyConfigService* net_proxy_config_service); - - virtual ~ServiceURLRequestContext(); - - private: - net::URLRequestContextStorage storage_; -}; - class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { public: virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; @@ -69,4 +52,4 @@ class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { scoped_ptr<net::URLRequestContext> url_request_context_; }; -#endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_ +#endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_GETTER_H_ diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 5b02bc2..d6cb9d4 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -24,7 +24,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/service_process_util.h" #include "chrome/service/cloud_print/cloud_print_proxy.h" -#include "chrome/service/net/service_url_request_context.h" +#include "chrome/service/net/service_url_request_context_getter.h" #include "chrome/service/service_ipc_server.h" #include "chrome/service/service_process_prefs.h" #include "grit/chromium_strings.h" |