Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: net/proxy/proxy_service.cc

Issue 27365: Add a command line flag --v8-proxy-resolver, to select the new PAC implementa... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc's comments Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_tokenizer.h" 11 #include "base/string_tokenizer.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/proxy/proxy_config_service_fixed.h" 15 #include "net/proxy/proxy_config_service_fixed.h"
16 #include "net/proxy/proxy_script_fetcher.h" 16 #include "net/proxy/proxy_script_fetcher.h"
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include "net/proxy/proxy_config_service_win.h" 18 #include "net/proxy/proxy_config_service_win.h"
19 #include "net/proxy/proxy_resolver_winhttp.h" 19 #include "net/proxy/proxy_resolver_winhttp.h"
20 #elif defined(OS_MACOSX) 20 #elif defined(OS_MACOSX)
21 #include "net/proxy/proxy_resolver_mac.h" 21 #include "net/proxy/proxy_resolver_mac.h"
22 #endif 22 #endif
23 #include "net/proxy/proxy_resolver.h" 23 #include "net/proxy/proxy_resolver.h"
24 #include "net/proxy/proxy_resolver_v8.h"
24 25
25 using base::TimeDelta; 26 using base::TimeDelta;
26 using base::TimeTicks; 27 using base::TimeTicks;
27 28
28 namespace net { 29 namespace net {
29 30
30 // Config getter that fails every time. 31 // Config getter that fails every time.
31 class ProxyConfigServiceNull : public ProxyConfigService { 32 class ProxyConfigServiceNull : public ProxyConfigService {
32 public: 33 public:
33 virtual int GetProxyConfig(ProxyConfig* config) { 34 virtual int GetProxyConfig(ProxyConfig* config) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // TODO(port): implement ProxyConfigServiceLinux as well as make use of 208 // TODO(port): implement ProxyConfigServiceLinux as well as make use of
208 // ProxyResolverV8 once it's implemented. 209 // ProxyResolverV8 once it's implemented.
209 // See: 210 // See:
210 // - http://code.google.com/p/chromium/issues/detail?id=8143 211 // - http://code.google.com/p/chromium/issues/detail?id=8143
211 // - http://code.google.com/p/chromium/issues/detail?id=2764 212 // - http://code.google.com/p/chromium/issues/detail?id=2764
212 return CreateNull(); 213 return CreateNull();
213 #endif 214 #endif
214 } 215 }
215 216
216 // static 217 // static
218 ProxyService* ProxyService::CreateUsingV8Resolver(
219 const ProxyInfo* pi, URLRequestContext* url_request_context) {
220 if (pi) {
221 // The ProxyResolver is set to NULL, since it should never be called
222 // (because the configuration will never require PAC).
223 return new ProxyService(new ProxyConfigServiceFixed(*pi), NULL);
224 }
225
226 // Choose the system configuration service appropriate for each platform.
227 ProxyConfigService* config_service;
228 #if defined(OS_WIN)
229 config_service = new ProxyConfigServiceWin();
230 #elif defined(OS_MACOSX)
231 config_service = new ProxyConfigServiceMac();
232 #else
233 // TODO(port): implement ProxyConfigServiceLinux.
234 // See: http://code.google.com/p/chromium/issues/detail?id=8143
235 return CreateNull();
236 #endif
237
238 // Create a ProxyService that uses V8 to evaluate PAC scripts.
239 ProxyService* proxy_service = new ProxyService(
240 config_service, new ProxyResolverV8());
241
242 // Configure PAC script downloads to be issued using |url_request_context|.
243 proxy_service->SetProxyScriptFetcher(
244 ProxyScriptFetcher::Create(url_request_context));
245
246 return proxy_service;
247 }
248
249 // static
217 ProxyService* ProxyService::CreateNull() { 250 ProxyService* ProxyService::CreateNull() {
218 // The ProxyResolver is set to NULL, since it should never be called 251 // The ProxyResolver is set to NULL, since it should never be called
219 // (because the configuration will never require PAC). 252 // (because the configuration will never require PAC).
220 return new ProxyService(new ProxyConfigServiceNull, NULL); 253 return new ProxyService(new ProxyConfigServiceNull, NULL);
221 } 254 }
222 255
223 int ProxyService::ResolveProxy(const GURL& url, ProxyInfo* result, 256 int ProxyService::ResolveProxy(const GURL& url, ProxyInfo* result,
224 CompletionCallback* callback, 257 CompletionCallback* callback,
225 PacRequest** pac_request) { 258 PacRequest** pac_request) {
226 DCHECK(callback); 259 DCHECK(callback);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 662 }
630 } 663 }
631 664
632 void SyncProxyServiceHelper::OnCompletion(int rv) { 665 void SyncProxyServiceHelper::OnCompletion(int rv) {
633 result_ = rv; 666 result_ = rv;
634 event_.Signal(); 667 event_.Signal();
635 } 668 }
636 669
637 } // namespace net 670 } // namespace net
638 671
OLDNEW
« chrome/browser/debugger/debugger_shell.cc ('K') | « net/proxy/proxy_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698