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

Side by Side Diff: chrome/service/net/service_url_request_context.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address erikwright's second round of comments. Created 8 years, 2 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 | Annotate | Revision Log
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/service/net/service_url_request_context.h" 5 #include "chrome/service/net/service_url_request_context.h"
6 6
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <sys/utsname.h> 8 #include <sys/utsname.h>
9 #endif 9 #endif
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/sys_info.h" 14 #include "base/sys_info.h"
15 #include "chrome/common/chrome_version_info.h" 15 #include "chrome/common/chrome_version_info.h"
16 #include "chrome/service/service_process.h" 16 #include "chrome/service/service_process.h"
17 #include "net/base/cert_verifier.h" 17 #include "net/base/cert_verifier.h"
18 #include "net/base/host_resolver.h" 18 #include "net/base/host_resolver.h"
19 #include "net/base/ssl_config_service_defaults.h" 19 #include "net/base/ssl_config_service_defaults.h"
20 #include "net/cookies/cookie_monster.h" 20 #include "net/cookies/cookie_monster.h"
21 #include "net/ftp/ftp_network_layer.h" 21 #include "net/ftp/ftp_network_layer.h"
22 #include "net/http/http_auth_handler_factory.h" 22 #include "net/http/http_auth_handler_factory.h"
23 #include "net/http/http_cache.h" 23 #include "net/http/http_cache.h"
24 #include "net/http/http_network_session.h" 24 #include "net/http/http_network_session.h"
25 #include "net/http/http_server_properties_impl.h" 25 #include "net/http/http_server_properties_impl.h"
26 #include "net/proxy/proxy_config_service.h" 26 #include "net/proxy/proxy_config_service.h"
27 #include "net/proxy/proxy_service.h" 27 #include "net/proxy/proxy_service.h"
28 #include "net/url_request/const_http_user_agent_settings.h"
28 #include "net/url_request/url_request_throttler_manager.h" 29 #include "net/url_request/url_request_throttler_manager.h"
29 30
30 namespace { 31 namespace {
31 // Copied from webkit/glue/user_agent.cc. We don't want to pull in a dependency 32 // Copied from webkit/glue/user_agent.cc. We don't want to pull in a dependency
32 // on webkit/glue which also pulls in the renderer. Also our user-agent is 33 // on webkit/glue which also pulls in the renderer. Also our user-agent is
33 // totally different from the user-agent used by the browser, just the 34 // totally different from the user-agent used by the browser, just the
34 // OS-specific parts are common. 35 // OS-specific parts are common.
35 std::string BuildOSCpuInfo() { 36 std::string BuildOSCpuInfo() {
36 std::string os_cpu; 37 std::string os_cpu;
37 38
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 extra_version_info.c_str(), 102 extra_version_info.c_str(),
102 BuildOSCpuInfo().c_str()); 103 BuildOSCpuInfo().c_str());
103 return user_agent; 104 return user_agent;
104 } 105 }
105 106
106 } // namespace 107 } // namespace
107 108
108 ServiceURLRequestContext::ServiceURLRequestContext( 109 ServiceURLRequestContext::ServiceURLRequestContext(
109 const std::string& user_agent, 110 const std::string& user_agent,
110 net::ProxyConfigService* net_proxy_config_service) 111 net::ProxyConfigService* net_proxy_config_service)
111 : user_agent_(user_agent), 112 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
112 ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
113 storage_.set_host_resolver( 113 storage_.set_host_resolver(
114 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 114 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
115 net::HostResolver::kDefaultRetryAttempts, 115 net::HostResolver::kDefaultRetryAttempts,
116 NULL)); 116 NULL));
117 storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( 117 storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver(
118 net_proxy_config_service, 0u, NULL)); 118 net_proxy_config_service, 0u, NULL));
119 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); 119 storage_.set_cert_verifier(net::CertVerifier::CreateDefault());
120 storage_.set_ftp_transaction_factory( 120 storage_.set_ftp_transaction_factory(
121 new net::FtpNetworkLayer(host_resolver())); 121 new net::FtpNetworkLayer(host_resolver()));
122 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); 122 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults);
(...skipping 11 matching lines...) Expand all
134 session_params.http_auth_handler_factory = http_auth_handler_factory(); 134 session_params.http_auth_handler_factory = http_auth_handler_factory();
135 session_params.http_server_properties = http_server_properties(); 135 session_params.http_server_properties = http_server_properties();
136 scoped_refptr<net::HttpNetworkSession> network_session( 136 scoped_refptr<net::HttpNetworkSession> network_session(
137 new net::HttpNetworkSession(session_params)); 137 new net::HttpNetworkSession(session_params));
138 storage_.set_http_transaction_factory( 138 storage_.set_http_transaction_factory(
139 new net::HttpCache( 139 new net::HttpCache(
140 network_session, 140 network_session,
141 net::HttpCache::DefaultBackend::InMemory(0))); 141 net::HttpCache::DefaultBackend::InMemory(0)));
142 // In-memory cookie store. 142 // In-memory cookie store.
143 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); 143 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
144 set_accept_language("en-us,fr"); 144 storage_.set_http_user_agent_settings(new net::ConstHttpUserAgentSettings(
145 set_accept_charset("iso-8859-1,*,utf-8"); 145 "en-us,fr", "iso-8859-1,*,utf-8", user_agent));
mmenke 2012/09/26 16:28:20 nit: 4-space indent
146 }
147
148 const std::string& ServiceURLRequestContext::GetUserAgent(
149 const GURL& url) const {
150 // If the user agent is set explicitly return that, otherwise call the
151 // base class method to return default value.
152 return user_agent_.empty() ?
153 net::URLRequestContext::GetUserAgent(url) : user_agent_;
154 } 146 }
155 147
156 ServiceURLRequestContext::~ServiceURLRequestContext() { 148 ServiceURLRequestContext::~ServiceURLRequestContext() {
157 } 149 }
158 150
159 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() 151 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter()
160 : network_task_runner_( 152 : network_task_runner_(
161 g_service_process->io_thread()->message_loop_proxy()) { 153 g_service_process->io_thread()->message_loop_proxy()) {
162 // Build the default user agent. 154 // Build the default user agent.
163 user_agent_ = MakeUserAgentForServiceProcess(); 155 user_agent_ = MakeUserAgentForServiceProcess();
(...skipping 15 matching lines...) Expand all
179 proxy_config_service_.release())); 171 proxy_config_service_.release()));
180 return url_request_context_.get(); 172 return url_request_context_.get();
181 } 173 }
182 174
183 scoped_refptr<base::SingleThreadTaskRunner> 175 scoped_refptr<base::SingleThreadTaskRunner>
184 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { 176 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const {
185 return network_task_runner_; 177 return network_task_runner_;
186 } 178 }
187 179
188 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} 180 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698