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

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

Issue 10874077: net: Add a new target 'net_with_v8'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang? Created 8 years, 3 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
« net/proxy/proxy_service.cc ('K') | « net/proxy/proxy_service_v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/proxy/proxy_service_v8.h"
6
7 #include "base/logging.h"
8 #include "net/proxy/multi_threaded_proxy_resolver.h"
9 #include "net/proxy/network_delegate_error_observer.h"
10 #include "net/proxy/proxy_resolver.h"
11 #include "net/proxy/proxy_resolver_js_bindings.h"
12 #include "net/proxy/proxy_resolver_v8.h"
13 #include "net/proxy/proxy_service.h"
14 #include "net/proxy/sync_host_resolver_bridge.h"
15
16 namespace net {
17 namespace {
18
19 // This factory creates V8ProxyResolvers with appropriate javascript bindings.
20 class ProxyResolverFactoryForV8 : public ProxyResolverFactory {
21 public:
22 // |async_host_resolver|, |io_loop| and |net_log| must remain
23 // valid for the duration of our lifetime.
24 // |async_host_resolver| will only be operated on |io_loop|.
25 // TODO(willchan): remove io_loop and replace it with origin_loop.
26 ProxyResolverFactoryForV8(HostResolver* async_host_resolver,
27 MessageLoop* io_loop,
28 base::MessageLoopProxy* origin_loop,
29 NetLog* net_log,
30 NetworkDelegate* network_delegate)
31 : ProxyResolverFactory(true /*expects_pac_bytes*/),
32 async_host_resolver_(async_host_resolver),
33 io_loop_(io_loop),
34 origin_loop_(origin_loop),
35 net_log_(net_log),
36 network_delegate_(network_delegate) {
37 }
38
39 virtual ProxyResolver* CreateProxyResolver() OVERRIDE {
40 // Create a synchronous host resolver wrapper that operates
41 // |async_host_resolver_| on |io_loop_|.
42 SyncHostResolverBridge* sync_host_resolver =
43 new SyncHostResolverBridge(async_host_resolver_, io_loop_);
44
45 NetworkDelegateErrorObserver* error_observer =
46 new NetworkDelegateErrorObserver(
47 network_delegate_, origin_loop_.get());
48
49 // ProxyResolverJSBindings takes ownership of |error_observer| and
50 // |sync_host_resolver|.
51 ProxyResolverJSBindings* js_bindings =
eroman 2012/08/28 01:37:42 I assume this file is a straight up move, and cons
tfarina 2012/08/30 02:45:52 Yup, just cut and paste.
52 ProxyResolverJSBindings::CreateDefault(
53 sync_host_resolver, net_log_, error_observer);
54
55 // ProxyResolverV8 takes ownership of |js_bindings|.
56 return new ProxyResolverV8(js_bindings);
57 }
58
59 private:
60 HostResolver* const async_host_resolver_;
61 MessageLoop* io_loop_;
62 scoped_refptr<base::MessageLoopProxy> origin_loop_;
63 NetLog* net_log_;
64 NetworkDelegate* network_delegate_;
65 };
66
67 } // namespace
68
69 // static
70 ProxyService* CreateProxyServiceUsingV8ProxyResolver(
71 ProxyConfigService* proxy_config_service,
72 size_t num_pac_threads,
73 ProxyScriptFetcher* proxy_script_fetcher,
74 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
75 HostResolver* host_resolver,
76 NetLog* net_log,
77 NetworkDelegate* network_delegate) {
78 DCHECK(proxy_config_service);
79 DCHECK(proxy_script_fetcher);
80 DCHECK(dhcp_proxy_script_fetcher);
81 DCHECK(host_resolver);
82
83 if (num_pac_threads == 0)
84 num_pac_threads = ProxyService::kDefaultNumPacThreads;
85
86 ProxyResolverFactory* sync_resolver_factory =
87 new ProxyResolverFactoryForV8(
88 host_resolver,
89 MessageLoop::current(),
90 base::MessageLoopProxy::current(),
91 net_log,
92 network_delegate);
93
94 ProxyResolver* proxy_resolver =
95 new MultiThreadedProxyResolver(sync_resolver_factory, num_pac_threads);
96
97 ProxyService* proxy_service =
98 new ProxyService(proxy_config_service, proxy_resolver, net_log);
99
100 // Configure fetchers to use for PAC script downloads and auto-detect.
101 proxy_service->SetProxyScriptFetchers(proxy_script_fetcher,
102 dhcp_proxy_script_fetcher);
103
104 return proxy_service;
105 }
106
107 } // namespace net
OLDNEW
« net/proxy/proxy_service.cc ('K') | « net/proxy/proxy_service_v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698