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

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

Issue 939503004: Add LoadState reporting to the mojo proxy resolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy-resolver-mojo
Patch Set: rebase Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/mojo_proxy_resolver_factory_impl.h" 5 #include "net/proxy/mojo_proxy_resolver_factory_impl.h"
6 6
7 #include "net/dns/host_resolver_mojo.h" 7 #include "net/dns/host_resolver_mojo.h"
8 #include "net/proxy/mojo_proxy_resolver_impl.h" 8 #include "net/proxy/mojo_proxy_resolver_impl.h"
9 #include "net/proxy/proxy_resolver_v8.h" 9 #include "net/proxy/proxy_resolver_v8.h"
10 #include "net/proxy/proxy_resolver_v8_tracing.h" 10 #include "net/proxy/proxy_resolver_v8_tracing.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" 11 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
12 12
13 namespace net { 13 namespace net {
14 namespace { 14 namespace {
15 15
16 scoped_ptr<ProxyResolver> CreateDefaultProxyResolver( 16 scoped_ptr<ProxyResolver> CreateDefaultProxyResolver(
17 HostResolver* host_resolver) { 17 HostResolver* host_resolver,
18 const ProxyResolver::LoadStateChangedCallback& callback) {
18 return make_scoped_ptr( 19 return make_scoped_ptr(
19 new ProxyResolverV8Tracing(host_resolver, nullptr, nullptr)); 20 new ProxyResolverV8Tracing(host_resolver, nullptr, nullptr, callback));
20 } 21 }
21 22
22 // A class to manage the lifetime of a MojoProxyResolverImpl and a 23 // A class to manage the lifetime of a MojoProxyResolverImpl and a
23 // HostResolverMojo. An instance will remain while the message pipes for both 24 // HostResolverMojo. An instance will remain while the message pipes for both
24 // mojo connections remain open. 25 // mojo connections remain open.
25 class MojoProxyResolverHolder : public mojo::ErrorHandler { 26 class MojoProxyResolverHolder : public mojo::ErrorHandler {
26 public: 27 public:
27 MojoProxyResolverHolder( 28 MojoProxyResolverHolder(
28 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory, 29 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory,
29 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 30 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
30 interfaces::HostResolverPtr host_resolver); 31 interfaces::HostResolverPtr host_resolver);
31 32
32 private: 33 private:
33 // mojo::ErrorHandler override. 34 // mojo::ErrorHandler override.
34 void OnConnectionError() override; 35 void OnConnectionError() override;
35 36
37 void LoadStateChanged(ProxyResolver::RequestHandle handle,
38 LoadState load_state);
39
36 HostResolverMojo host_resolver_; 40 HostResolverMojo host_resolver_;
37 MojoProxyResolverImpl proxy_resolver_; 41 MojoProxyResolverImpl proxy_resolver_;
38 mojo::Binding<interfaces::ProxyResolver> binding_; 42 mojo::Binding<interfaces::ProxyResolver> binding_;
39 43
40 DISALLOW_COPY_AND_ASSIGN(MojoProxyResolverHolder); 44 DISALLOW_COPY_AND_ASSIGN(MojoProxyResolverHolder);
41 }; 45 };
42 46
43 MojoProxyResolverHolder::MojoProxyResolverHolder( 47 MojoProxyResolverHolder::MojoProxyResolverHolder(
44 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory, 48 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory,
45 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 49 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
46 interfaces::HostResolverPtr host_resolver) 50 interfaces::HostResolverPtr host_resolver)
47 : host_resolver_(host_resolver.Pass(), 51 : host_resolver_(host_resolver.Pass(),
48 base::Bind(&MojoProxyResolverHolder::OnConnectionError, 52 base::Bind(&MojoProxyResolverHolder::OnConnectionError,
49 base::Unretained(this))), 53 base::Unretained(this))),
50 proxy_resolver_(proxy_resolver_factory.Run(&host_resolver_)), 54 proxy_resolver_(proxy_resolver_factory.Run(
55 &host_resolver_,
56 base::Bind(&MojoProxyResolverHolder::LoadStateChanged,
57 base::Unretained(this)))),
51 binding_(&proxy_resolver_, request.Pass()) { 58 binding_(&proxy_resolver_, request.Pass()) {
52 binding_.set_error_handler(this); 59 binding_.set_error_handler(this);
53 } 60 }
54 61
55 void MojoProxyResolverHolder::OnConnectionError() { 62 void MojoProxyResolverHolder::OnConnectionError() {
56 delete this; 63 delete this;
57 } 64 }
58 65
66 void MojoProxyResolverHolder::LoadStateChanged(
67 ProxyResolver::RequestHandle handle,
68 LoadState load_state) {
69 proxy_resolver_.LoadStateChanged(handle, load_state);
70 }
71
59 } // namespace 72 } // namespace
60 73
61 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl( 74 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl(
62 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory, 75 const MojoProxyResolverFactoryImpl::Factory& proxy_resolver_factory,
63 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request) 76 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request)
64 : proxy_resolver_impl_factory_(proxy_resolver_factory), 77 : proxy_resolver_impl_factory_(proxy_resolver_factory),
65 binding_(this, request.Pass()) { 78 binding_(this, request.Pass()) {
66 } 79 }
67 80
68 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl( 81 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl(
69 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request) 82 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> request)
70 : MojoProxyResolverFactoryImpl(base::Bind(&CreateDefaultProxyResolver), 83 : MojoProxyResolverFactoryImpl(base::Bind(&CreateDefaultProxyResolver),
71 request.Pass()) { 84 request.Pass()) {
72 } 85 }
73 86
74 MojoProxyResolverFactoryImpl::~MojoProxyResolverFactoryImpl() = default; 87 MojoProxyResolverFactoryImpl::~MojoProxyResolverFactoryImpl() = default;
75 88
76 void MojoProxyResolverFactoryImpl::CreateResolver( 89 void MojoProxyResolverFactoryImpl::CreateResolver(
77 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 90 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
78 interfaces::HostResolverPtr host_resolver) { 91 interfaces::HostResolverPtr host_resolver) {
79 // The MojoProxyResolverHolder will delete itself when either |request| or 92 // The MojoProxyResolverHolder will delete itself when either |request| or
80 // |host_resolver| encounters a connection error, that is, when either the 93 // |host_resolver| encounters a connection error, that is, when either the
81 // ProxyResolver client or the HostResolver implementation is deleted. 94 // ProxyResolver client or the HostResolver implementation is deleted.
82 new MojoProxyResolverHolder(proxy_resolver_impl_factory_, request.Pass(), 95 new MojoProxyResolverHolder(proxy_resolver_impl_factory_, request.Pass(),
83 host_resolver.Pass()); 96 host_resolver.Pass());
84 } 97 }
85 98
86 } // namespace net 99 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory_impl.h ('k') | net/proxy/mojo_proxy_resolver_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698