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" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/proxy/proxy_config_service_fixed.h" | 14 #include "net/proxy/proxy_config_service_fixed.h" |
15 #include "net/proxy/proxy_script_fetcher.h" | 15 #include "net/proxy/proxy_script_fetcher.h" |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 #include "net/proxy/proxy_config_service_win.h" | 17 #include "net/proxy/proxy_config_service_win.h" |
18 #include "net/proxy/proxy_resolver_winhttp.h" | 18 #include "net/proxy/proxy_resolver_winhttp.h" |
19 #elif defined(OS_MACOSX) | 19 #elif defined(OS_MACOSX) |
20 #include "net/proxy/proxy_resolver_mac.h" | 20 #include "net/proxy/proxy_resolver_mac.h" |
21 #elif defined(OS_LINUX) | 21 #elif defined(OS_LINUX) |
22 #include "net/proxy/proxy_config_service_linux.h" | 22 #include "net/proxy/proxy_config_service_linux.h" |
23 #endif | 23 #endif |
24 #include "net/proxy/proxy_resolver.h" | 24 #include "net/proxy/proxy_resolver.h" |
25 #include "net/proxy/proxy_resolver_v8.h" | 25 #include "net/proxy/proxy_resolver_v8.h" |
| 26 #include "net/url_request/url_request_context.h" |
26 | 27 |
27 using base::TimeDelta; | 28 using base::TimeDelta; |
28 using base::TimeTicks; | 29 using base::TimeTicks; |
29 | 30 |
30 namespace net { | 31 namespace net { |
31 | 32 |
32 // Config getter that fails every time. | 33 // Config getter that fails every time. |
33 class ProxyConfigServiceNull : public ProxyConfigService { | 34 class ProxyConfigServiceNull : public ProxyConfigService { |
34 public: | 35 public: |
35 // ProxyConfigService implementation: | 36 // ProxyConfigService implementation: |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ProxyService* ProxyService::Create( | 211 ProxyService* ProxyService::Create( |
211 const ProxyConfig* pc, | 212 const ProxyConfig* pc, |
212 bool use_v8_resolver, | 213 bool use_v8_resolver, |
213 URLRequestContext* url_request_context, | 214 URLRequestContext* url_request_context, |
214 MessageLoop* io_loop) { | 215 MessageLoop* io_loop) { |
215 // Choose the system configuration service appropriate for each platform. | 216 // Choose the system configuration service appropriate for each platform. |
216 ProxyConfigService* proxy_config_service = pc ? | 217 ProxyConfigService* proxy_config_service = pc ? |
217 new ProxyConfigServiceFixed(*pc) : | 218 new ProxyConfigServiceFixed(*pc) : |
218 CreateSystemProxyConfigService(io_loop); | 219 CreateSystemProxyConfigService(io_loop); |
219 | 220 |
220 ProxyResolver* proxy_resolver = use_v8_resolver ? | 221 ProxyResolver* proxy_resolver; |
221 new ProxyResolverV8() : CreateNonV8ProxyResolver(); | 222 |
| 223 if (use_v8_resolver) { |
| 224 // Send javascript errors and alerts to LOG(INFO). |
| 225 HostResolver* host_resolver = url_request_context->host_resolver(); |
| 226 ProxyResolverV8::JSBindings* js_bindings = |
| 227 ProxyResolverV8::CreateDefaultBindings(host_resolver, io_loop); |
| 228 |
| 229 proxy_resolver = new ProxyResolverV8(js_bindings); |
| 230 } else { |
| 231 proxy_resolver = CreateNonV8ProxyResolver(); |
| 232 } |
222 | 233 |
223 ProxyService* proxy_service = new ProxyService( | 234 ProxyService* proxy_service = new ProxyService( |
224 proxy_config_service, proxy_resolver); | 235 proxy_config_service, proxy_resolver); |
225 | 236 |
226 if (!proxy_resolver->does_fetch()) { | 237 if (!proxy_resolver->does_fetch()) { |
227 // Configure PAC script downloads to be issued using |url_request_context|. | 238 // Configure PAC script downloads to be issued using |url_request_context|. |
228 DCHECK(url_request_context); | 239 DCHECK(url_request_context); |
229 proxy_service->SetProxyScriptFetcher( | 240 proxy_service->SetProxyScriptFetcher( |
230 ProxyScriptFetcher::Create(url_request_context)); | 241 ProxyScriptFetcher::Create(url_request_context)); |
231 } | 242 } |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 OnCompletion(result_); | 761 OnCompletion(result_); |
751 } | 762 } |
752 } | 763 } |
753 | 764 |
754 void SyncProxyServiceHelper::OnCompletion(int rv) { | 765 void SyncProxyServiceHelper::OnCompletion(int rv) { |
755 result_ = rv; | 766 result_ = rv; |
756 event_.Signal(); | 767 event_.Signal(); |
757 } | 768 } |
758 | 769 |
759 } // namespace net | 770 } // namespace net |
OLD | NEW |