OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "chrome/common/chrome_version_info.h" | 14 #include "chrome/common/chrome_version_info.h" |
15 #include "chrome/service/service_process.h" | 15 #include "chrome/service/service_process.h" |
| 16 #include "net/base/cert_verifier.h" |
16 #include "net/base/cookie_monster.h" | 17 #include "net/base/cookie_monster.h" |
17 #include "net/base/cookie_policy.h" | 18 #include "net/base/cookie_policy.h" |
18 #include "net/base/dnsrr_resolver.h" | 19 #include "net/base/dnsrr_resolver.h" |
19 #include "net/base/host_resolver.h" | 20 #include "net/base/host_resolver.h" |
20 #include "net/base/ssl_config_service_defaults.h" | 21 #include "net/base/ssl_config_service_defaults.h" |
21 #include "net/ftp/ftp_network_layer.h" | 22 #include "net/ftp/ftp_network_layer.h" |
22 #include "net/http/http_auth_handler_factory.h" | 23 #include "net/http/http_auth_handler_factory.h" |
23 #include "net/http/http_cache.h" | 24 #include "net/http/http_cache.h" |
24 #include "net/http/http_network_layer.h" | 25 #include "net/http/http_network_layer.h" |
25 #include "net/proxy/proxy_service.h" | 26 #include "net/proxy/proxy_service.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 DCHECK(g_service_process); | 111 DCHECK(g_service_process); |
111 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a | 112 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a |
112 // MessageLoopProxy* instead of MessageLoop*. | 113 // MessageLoopProxy* instead of MessageLoop*. |
113 // Also this needs to be created on the UI thread on Linux. Fix this. | 114 // Also this needs to be created on the UI thread on Linux. Fix this. |
114 net::ProxyConfigService * proxy_config_service = | 115 net::ProxyConfigService * proxy_config_service = |
115 net::ProxyService::CreateSystemProxyConfigService( | 116 net::ProxyService::CreateSystemProxyConfigService( |
116 g_service_process->io_thread()->message_loop(), | 117 g_service_process->io_thread()->message_loop(), |
117 g_service_process->file_thread()->message_loop()); | 118 g_service_process->file_thread()->message_loop()); |
118 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( | 119 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( |
119 proxy_config_service, 0u, NULL); | 120 proxy_config_service, 0u, NULL); |
| 121 cert_verifier_ = new net::CertVerifier; |
120 dnsrr_resolver_ = new net::DnsRRResolver; | 122 dnsrr_resolver_ = new net::DnsRRResolver; |
121 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | 123 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); |
122 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 124 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
123 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault( | 125 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault( |
124 host_resolver_); | 126 host_resolver_); |
125 http_transaction_factory_ = new net::HttpCache( | 127 http_transaction_factory_ = new net::HttpCache( |
126 net::HttpNetworkLayer::CreateFactory(host_resolver_, | 128 net::HttpNetworkLayer::CreateFactory(host_resolver_, |
| 129 cert_verifier_, |
127 dnsrr_resolver_, | 130 dnsrr_resolver_, |
128 NULL /* dns_cert_checker */, | 131 NULL /* dns_cert_checker */, |
129 NULL /* ssl_host_info_factory */, | 132 NULL /* ssl_host_info_factory */, |
130 proxy_service_, | 133 proxy_service_, |
131 ssl_config_service_, | 134 ssl_config_service_, |
132 http_auth_handler_factory_, | 135 http_auth_handler_factory_, |
133 NULL /* network_delegate */, | 136 NULL /* network_delegate */, |
134 NULL /* net_log */), | 137 NULL /* net_log */), |
135 net::HttpCache::DefaultBackend::InMemory(0)); | 138 net::HttpCache::DefaultBackend::InMemory(0)); |
136 // In-memory cookie store. | 139 // In-memory cookie store. |
137 cookie_store_ = new net::CookieMonster(NULL, NULL); | 140 cookie_store_ = new net::CookieMonster(NULL, NULL); |
138 accept_language_ = "en-us,fr"; | 141 accept_language_ = "en-us,fr"; |
139 accept_charset_ = "iso-8859-1,*,utf-8"; | 142 accept_charset_ = "iso-8859-1,*,utf-8"; |
140 } | 143 } |
141 | 144 |
142 const std::string& ServiceURLRequestContext::GetUserAgent( | 145 const std::string& ServiceURLRequestContext::GetUserAgent( |
143 const GURL& url) const { | 146 const GURL& url) const { |
144 // If the user agent is set explicitly return that, otherwise call the | 147 // If the user agent is set explicitly return that, otherwise call the |
145 // base class method to return default value. | 148 // base class method to return default value. |
146 return user_agent_.empty() ? | 149 return user_agent_.empty() ? |
147 URLRequestContext::GetUserAgent(url) : user_agent_; | 150 URLRequestContext::GetUserAgent(url) : user_agent_; |
148 } | 151 } |
149 | 152 |
150 ServiceURLRequestContext::~ServiceURLRequestContext() { | 153 ServiceURLRequestContext::~ServiceURLRequestContext() { |
151 delete ftp_transaction_factory_; | 154 delete ftp_transaction_factory_; |
152 delete http_transaction_factory_; | 155 delete http_transaction_factory_; |
153 delete http_auth_handler_factory_; | 156 delete http_auth_handler_factory_; |
| 157 delete cert_verifier_; |
154 delete dnsrr_resolver_; | 158 delete dnsrr_resolver_; |
155 } | 159 } |
156 | 160 |
157 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() | 161 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() |
158 : io_message_loop_proxy_( | 162 : io_message_loop_proxy_( |
159 g_service_process->io_thread()->message_loop_proxy()) { | 163 g_service_process->io_thread()->message_loop_proxy()) { |
160 // Build the default user agent. | 164 // Build the default user agent. |
161 user_agent_ = MakeUserAgentForServiceProcess(); | 165 user_agent_ = MakeUserAgentForServiceProcess(); |
162 } | 166 } |
163 | 167 |
164 URLRequestContext* | 168 URLRequestContext* |
165 ServiceURLRequestContextGetter::GetURLRequestContext() { | 169 ServiceURLRequestContextGetter::GetURLRequestContext() { |
166 if (!url_request_context_) | 170 if (!url_request_context_) |
167 url_request_context_ = new ServiceURLRequestContext(user_agent_); | 171 url_request_context_ = new ServiceURLRequestContext(user_agent_); |
168 return url_request_context_; | 172 return url_request_context_; |
169 } | 173 } |
170 | 174 |
171 scoped_refptr<base::MessageLoopProxy> | 175 scoped_refptr<base::MessageLoopProxy> |
172 ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { | 176 ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { |
173 return io_message_loop_proxy_; | 177 return io_message_loop_proxy_; |
174 } | 178 } |
175 | 179 |
176 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} | 180 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} |
OLD | NEW |