OLD | NEW |
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 "base/thread_task_runner_handle.h" |
15 #include "chrome/common/chrome_version_info.h" | 16 #include "chrome/common/chrome_version_info.h" |
16 #include "chrome/service/service_process.h" | 17 #include "chrome/service/service_process.h" |
17 #include "net/base/cert_verifier.h" | 18 #include "net/base/cert_verifier.h" |
18 #include "net/base/host_resolver.h" | 19 #include "net/base/host_resolver.h" |
19 #include "net/base/ssl_config_service_defaults.h" | 20 #include "net/base/ssl_config_service_defaults.h" |
20 #include "net/cookies/cookie_monster.h" | 21 #include "net/cookies/cookie_monster.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_session.h" | 25 #include "net/http/http_network_session.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // If the user agent is set explicitly return that, otherwise call the | 151 // If the user agent is set explicitly return that, otherwise call the |
151 // base class method to return default value. | 152 // base class method to return default value. |
152 return user_agent_.empty() ? | 153 return user_agent_.empty() ? |
153 net::URLRequestContext::GetUserAgent(url) : user_agent_; | 154 net::URLRequestContext::GetUserAgent(url) : user_agent_; |
154 } | 155 } |
155 | 156 |
156 ServiceURLRequestContext::~ServiceURLRequestContext() { | 157 ServiceURLRequestContext::~ServiceURLRequestContext() { |
157 } | 158 } |
158 | 159 |
159 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() | 160 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() |
160 : network_task_runner_( | 161 : glib_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 162 network_task_runner_( |
161 g_service_process->io_thread()->message_loop_proxy()) { | 163 g_service_process->io_thread()->message_loop_proxy()) { |
162 // Build the default user agent. | 164 // Build the default user agent. |
163 user_agent_ = MakeUserAgentForServiceProcess(); | 165 user_agent_ = MakeUserAgentForServiceProcess(); |
164 | |
165 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a | |
166 // MessageLoopProxy* instead of MessageLoop*. | |
167 DCHECK(g_service_process); | |
168 proxy_config_service_.reset( | |
169 net::ProxyService::CreateSystemProxyConfigService( | |
170 g_service_process->io_thread()->message_loop_proxy(), | |
171 g_service_process->file_thread()->message_loop())); | |
172 } | 166 } |
173 | 167 |
174 net::URLRequestContext* | 168 net::URLRequestContext* |
175 ServiceURLRequestContextGetter::GetURLRequestContext() { | 169 ServiceURLRequestContextGetter::GetURLRequestContext() { |
176 if (!url_request_context_.get()) | 170 if (!url_request_context_.get()) { |
| 171 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a |
| 172 // MessageLoopProxy* instead of MessageLoop*. |
| 173 DCHECK(g_service_process); |
177 url_request_context_.reset( | 174 url_request_context_.reset( |
178 new ServiceURLRequestContext(user_agent_, | 175 new ServiceURLRequestContext( |
179 proxy_config_service_.release())); | 176 user_agent_, |
| 177 net::ProxyService::CreateSystemProxyConfigService( |
| 178 glib_task_runner_, |
| 179 g_service_process->file_thread()->message_loop()))); |
| 180 } |
180 return url_request_context_.get(); | 181 return url_request_context_.get(); |
181 } | 182 } |
182 | 183 |
183 scoped_refptr<base::SingleThreadTaskRunner> | 184 scoped_refptr<base::SingleThreadTaskRunner> |
184 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { | 185 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { |
185 return network_task_runner_; | 186 return network_task_runner_; |
186 } | 187 } |
187 | 188 |
188 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} | 189 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} |
OLD | NEW |