| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/proxy/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 resolver_(resolver), | 205 resolver_(resolver), |
| 206 next_config_id_(1), | 206 next_config_id_(1), |
| 207 config_is_bad_(false), | 207 config_is_bad_(false), |
| 208 should_use_proxy_resolver_(false), | 208 should_use_proxy_resolver_(false), |
| 209 ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_( | 209 ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_( |
| 210 this, &ProxyService::OnInitProxyResolverComplete)) { | 210 this, &ProxyService::OnInitProxyResolverComplete)) { |
| 211 } | 211 } |
| 212 | 212 |
| 213 // static | 213 // static |
| 214 ProxyService* ProxyService::Create( | 214 ProxyService* ProxyService::Create( |
| 215 const ProxyConfig* pc, | 215 ProxyConfigService* proxy_config_service, |
| 216 bool use_v8_resolver, | 216 bool use_v8_resolver, |
| 217 URLRequestContext* url_request_context, | 217 URLRequestContext* url_request_context, |
| 218 MessageLoop* io_loop, MessageLoop* file_loop) { | 218 MessageLoop* io_loop) { |
| 219 // Choose the system configuration service appropriate for each platform. | |
| 220 ProxyConfigService* proxy_config_service = pc ? | |
| 221 new ProxyConfigServiceFixed(*pc) : | |
| 222 CreateSystemProxyConfigService(io_loop, file_loop); | |
| 223 | |
| 224 ProxyResolver* proxy_resolver; | 219 ProxyResolver* proxy_resolver; |
| 225 | 220 |
| 226 if (use_v8_resolver) { | 221 if (use_v8_resolver) { |
| 227 // Send javascript errors and alerts to LOG(INFO). | 222 // Send javascript errors and alerts to LOG(INFO). |
| 228 HostResolver* host_resolver = url_request_context->host_resolver(); | 223 HostResolver* host_resolver = url_request_context->host_resolver(); |
| 229 ProxyResolverJSBindings* js_bindings = | 224 ProxyResolverJSBindings* js_bindings = |
| 230 ProxyResolverJSBindings::CreateDefault(host_resolver, io_loop); | 225 ProxyResolverJSBindings::CreateDefault(host_resolver, io_loop); |
| 231 | 226 |
| 232 proxy_resolver = new ProxyResolverV8(js_bindings); | 227 proxy_resolver = new ProxyResolverV8(js_bindings); |
| 233 } else { | 228 } else { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 246 DCHECK(url_request_context); | 241 DCHECK(url_request_context); |
| 247 proxy_service->SetProxyScriptFetcher( | 242 proxy_service->SetProxyScriptFetcher( |
| 248 ProxyScriptFetcher::Create(url_request_context)); | 243 ProxyScriptFetcher::Create(url_request_context)); |
| 249 } | 244 } |
| 250 | 245 |
| 251 return proxy_service; | 246 return proxy_service; |
| 252 } | 247 } |
| 253 | 248 |
| 254 // static | 249 // static |
| 255 ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) { | 250 ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) { |
| 256 return Create(&pc, false, NULL, NULL, NULL); | 251 return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL); |
| 257 } | 252 } |
| 258 | 253 |
| 259 // static | 254 // static |
| 260 ProxyService* ProxyService::CreateNull() { | 255 ProxyService* ProxyService::CreateNull() { |
| 261 // Use a configuration fetcher and proxy resolver which always fail. | 256 // Use a configuration fetcher and proxy resolver which always fail. |
| 262 return new ProxyService(new ProxyConfigServiceNull, new ProxyResolverNull); | 257 return new ProxyService(new ProxyConfigServiceNull, new ProxyResolverNull); |
| 263 } | 258 } |
| 264 | 259 |
| 265 int ProxyService::ResolveProxy(const GURL& raw_url, | 260 int ProxyService::ResolveProxy(const GURL& raw_url, |
| 266 ProxyInfo* result, | 261 ProxyInfo* result, |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 OnCompletion(result_); | 789 OnCompletion(result_); |
| 795 } | 790 } |
| 796 } | 791 } |
| 797 | 792 |
| 798 void SyncProxyServiceHelper::OnCompletion(int rv) { | 793 void SyncProxyServiceHelper::OnCompletion(int rv) { |
| 799 result_ = rv; | 794 result_ = rv; |
| 800 event_.Signal(); | 795 event_.Signal(); |
| 801 } | 796 } |
| 802 | 797 |
| 803 } // namespace net | 798 } // namespace net |
| OLD | NEW |