| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 delete dnsrr_resolver(); | 150 delete dnsrr_resolver(); |
| 151 delete host_resolver(); | 151 delete host_resolver(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() | 154 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() |
| 155 : io_message_loop_proxy_( | 155 : io_message_loop_proxy_( |
| 156 g_service_process->io_thread()->message_loop_proxy()) { | 156 g_service_process->io_thread()->message_loop_proxy()) { |
| 157 // Build the default user agent. | 157 // Build the default user agent. |
| 158 user_agent_ = MakeUserAgentForServiceProcess(); | 158 user_agent_ = MakeUserAgentForServiceProcess(); |
| 159 | 159 |
| 160 #if !defined(OS_MACOSX) | 160 #if defined(OS_LINUX) |
| 161 // Create the proxy service now, at initialization time, on the main thread. | 161 // Create the proxy service now, at initialization time, on the main thread, |
| 162 // The Mac needs it created later, on the I/O thread. | 162 // only for Linux, which requires that. |
| 163 CreateProxyService(); | 163 CreateProxyService(); |
| 164 #endif | 164 #endif |
| 165 } | 165 } |
| 166 | 166 |
| 167 net::URLRequestContext* | 167 net::URLRequestContext* |
| 168 ServiceURLRequestContextGetter::GetURLRequestContext() { | 168 ServiceURLRequestContextGetter::GetURLRequestContext() { |
| 169 #if defined(OS_MACOSX) | 169 #if !defined(OS_LINUX) |
| 170 if (!proxy_service_) | 170 if (!proxy_service_) |
| 171 CreateProxyService(); | 171 CreateProxyService(); |
| 172 #endif | 172 #endif |
| 173 if (!url_request_context_) | 173 if (!url_request_context_) |
| 174 url_request_context_ = new ServiceURLRequestContext(user_agent_, | 174 url_request_context_ = new ServiceURLRequestContext(user_agent_, |
| 175 proxy_service_); | 175 proxy_service_); |
| 176 return url_request_context_; | 176 return url_request_context_; |
| 177 } | 177 } |
| 178 | 178 |
| 179 scoped_refptr<base::MessageLoopProxy> | 179 scoped_refptr<base::MessageLoopProxy> |
| 180 ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { | 180 ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { |
| 181 return io_message_loop_proxy_; | 181 return io_message_loop_proxy_; |
| 182 } | 182 } |
| 183 | 183 |
| 184 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} | 184 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} |
| 185 | 185 |
| 186 void ServiceURLRequestContextGetter::CreateProxyService() { | 186 void ServiceURLRequestContextGetter::CreateProxyService() { |
| 187 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a | 187 // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a |
| 188 // MessageLoopProxy* instead of MessageLoop*. | 188 // MessageLoopProxy* instead of MessageLoop*. |
| 189 DCHECK(g_service_process); | 189 DCHECK(g_service_process); |
| 190 net::ProxyConfigService * proxy_config_service = | 190 net::ProxyConfigService * proxy_config_service = |
| 191 net::ProxyService::CreateSystemProxyConfigService( | 191 net::ProxyService::CreateSystemProxyConfigService( |
| 192 g_service_process->io_thread()->message_loop(), | 192 g_service_process->io_thread()->message_loop(), |
| 193 g_service_process->file_thread()->message_loop()); | 193 g_service_process->file_thread()->message_loop()); |
| 194 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( | 194 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( |
| 195 proxy_config_service, 0u, NULL); | 195 proxy_config_service, 0u, NULL); |
| 196 } | 196 } |
| OLD | NEW |