OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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/mojo_proxy_resolver_factory_impl.h" | |
6 | |
7 #include "net/dns/host_resolver_mojo.h" | |
8 #include "net/proxy/mojo_proxy_resolver_impl.h" | |
9 #include "net/proxy/proxy_resolver_v8_tracing.h" | |
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" | |
11 | |
12 namespace net { | |
13 namespace { | |
14 | |
15 scoped_ptr<ProxyResolver> CreateDefaultProxyResolver( | |
16 HostResolver* host_resolver) { | |
17 return make_scoped_ptr( | |
Anand Mistry (off Chromium)
2015/02/19 05:23:08
ProxyResolverV8::EnsureIsolateCreated();
Sam McNally
2015/02/20 03:25:04
Done.
| |
18 new ProxyResolverV8Tracing(host_resolver, nullptr, nullptr)); | |
19 } | |
20 | |
21 // A class to manage the lifetime of a MojoProxyResolverHolder and a | |
eroman
2015/02/20 01:43:37
Is this comment correct? MojoProxyResolverHolder -
Sam McNally
2015/02/20 03:25:04
Done.
| |
22 // HostResolverMojo. An instance will remain while the message pipes for both | |
23 // mojo connections remain open. | |
24 class MojoProxyResolverHolder : public mojo::ErrorHandler { | |
25 public: | |
26 MojoProxyResolverHolder( | |
27 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory, | |
28 mojo::InterfaceRequest<interfaces::ProxyResolver> request, | |
29 interfaces::HostResolverPtr host_resolver); | |
30 | |
31 private: | |
32 // mojo::ErrorHandler override. | |
33 void OnConnectionError() override; | |
34 | |
35 HostResolverMojo host_resolver_; | |
36 MojoProxyResolverImpl proxy_resolver_; | |
37 mojo::Binding<interfaces::ProxyResolver> binding_; | |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(MojoProxyResolverHolder); | |
40 }; | |
41 | |
42 MojoProxyResolverHolder::MojoProxyResolverHolder( | |
43 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory, | |
44 mojo::InterfaceRequest<interfaces::ProxyResolver> request, | |
45 interfaces::HostResolverPtr host_resolver) | |
46 : host_resolver_(host_resolver.Pass(), | |
47 base::Bind(&MojoProxyResolverHolder::OnConnectionError, | |
48 base::Unretained(this))), | |
49 proxy_resolver_(proxy_resolver_factory.Run(&host_resolver_)), | |
50 binding_(&proxy_resolver_, request.Pass()) { | |
51 binding_.set_error_handler(this); | |
eroman
2015/02/20 01:43:37
what is the difference between the error handler o
Sam McNally
2015/02/20 03:25:04
They serve the same function, but operate on oppos
| |
52 } | |
53 | |
54 void MojoProxyResolverHolder::OnConnectionError() { | |
55 delete this; | |
56 } | |
57 | |
58 } // namespace | |
59 | |
60 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl( | |
61 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory, | |
62 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request) | |
63 : proxy_resolver_impl_factory_(proxy_resolver_factory), | |
64 binding_(this, request.Pass()) { | |
65 } | |
66 | |
67 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl( | |
68 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request) | |
69 : MojoProxyResolverFactoryImpl(base::Bind(&CreateDefaultProxyResolver), | |
70 request.Pass()) { | |
71 } | |
72 | |
73 MojoProxyResolverFactoryImpl::~MojoProxyResolverFactoryImpl() = default; | |
74 | |
75 void MojoProxyResolverFactoryImpl::CreateResolver( | |
76 mojo::InterfaceRequest<interfaces::ProxyResolver> request, | |
77 interfaces::HostResolverPtr host_resolver) { | |
78 new MojoProxyResolverHolder(proxy_resolver_impl_factory_, request.Pass(), | |
eroman
2015/02/20 01:43:37
This still doesn't smell right to me.
At the very
Sam McNally
2015/02/20 03:25:04
Done.
| |
79 host_resolver.Pass()); | |
80 } | |
81 | |
82 } // namespace net | |
OLD | NEW |