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

Side by Side Diff: net/proxy/proxy_resolver_mojo.h

Issue 1076083002: Shut down proxy resolver utility processes when no longer needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy-service-with-factory-restart
Patch Set: Created 5 years, 7 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
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory.h ('k') | net/proxy/proxy_resolver_mojo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef NET_PROXY_PROXY_RESOLVER_MOJO_H_ 5 #ifndef NET_PROXY_PROXY_RESOLVER_MOJO_H_
6 #define NET_PROXY_PROXY_RESOLVER_MOJO_H_ 6 #define NET_PROXY_PROXY_RESOLVER_MOJO_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback_helpers.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
13 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
14 #include "net/base/load_states.h" 15 #include "net/base/load_states.h"
15 #include "net/interfaces/host_resolver_service.mojom.h" 16 #include "net/interfaces/host_resolver_service.mojom.h"
16 #include "net/interfaces/proxy_resolver_service.mojom.h" 17 #include "net/interfaces/proxy_resolver_service.mojom.h"
17 #include "net/proxy/proxy_resolver.h" 18 #include "net/proxy/proxy_resolver.h"
18 #include "net/proxy/proxy_resolver_factory.h" 19 #include "net/proxy/proxy_resolver_factory.h"
19 #include "net/proxy/proxy_resolver_script_data.h" 20 #include "net/proxy/proxy_resolver_script_data.h"
20 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" 21 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
21 22
22 class GURL; 23 class GURL;
23 24
24 namespace net { 25 namespace net {
25 26
26 class BoundNetLog; 27 class BoundNetLog;
27 class HostResolver; 28 class HostResolver;
28 class ProxyInfo; 29 class ProxyInfo;
29 class MojoProxyResolverFactory; 30 class MojoProxyResolverFactory;
30 31
31 // Implementation of ProxyResolver that connects to a Mojo service to evaluate 32 // Implementation of ProxyResolver that connects to a Mojo service to evaluate
32 // PAC scripts. This implementation only knows about Mojo services, and 33 // PAC scripts. This implementation only knows about Mojo services, and
33 // therefore that service may live in or out of process. 34 // therefore that service may live in or out of process.
35 //
36 // This implementation reports disconnections from the Mojo service (i.e. if the
37 // service is out-of-process and that process crashes) using the error code
38 // ERR_PAC_SCRIPT_TERMINATED.
34 class ProxyResolverMojo : public ProxyResolver, public mojo::ErrorHandler { 39 class ProxyResolverMojo : public ProxyResolver, public mojo::ErrorHandler {
35 public: 40 public:
36 // Constructs a ProxyResolverMojo that connects to a mojo proxy resolver 41 // Constructs a ProxyResolverMojo that connects to a mojo proxy resolver
37 // implementation using |resolver_ptr|. The implementation uses 42 // implementation using |resolver_ptr|. The implementation uses
38 // |host_resolver| as the DNS resolver, using |host_resolver_binding| to 43 // |host_resolver| as the DNS resolver, using |host_resolver_binding| to
39 // communicate with it. 44 // communicate with it. When deleted, the closure contained within
45 // |on_delete_callback_runner| will be run.
40 // TODO(amistry): Add ProxyResolverErrorObserver and NetLog. 46 // TODO(amistry): Add ProxyResolverErrorObserver and NetLog.
41 ProxyResolverMojo(interfaces::ProxyResolverPtr resolver_ptr, 47 ProxyResolverMojo(
42 scoped_ptr<interfaces::HostResolver> host_resolver, 48 interfaces::ProxyResolverPtr resolver_ptr,
43 scoped_ptr<mojo::Binding<interfaces::HostResolver>> 49 scoped_ptr<interfaces::HostResolver> host_resolver,
44 host_resolver_binding); 50 scoped_ptr<mojo::Binding<interfaces::HostResolver>> host_resolver_binding,
51 scoped_ptr<base::ScopedClosureRunner> on_delete_callback_runner);
45 ~ProxyResolverMojo() override; 52 ~ProxyResolverMojo() override;
46 53
47 // ProxyResolver implementation: 54 // ProxyResolver implementation:
48 int GetProxyForURL(const GURL& url, 55 int GetProxyForURL(const GURL& url,
49 ProxyInfo* results, 56 ProxyInfo* results,
50 const net::CompletionCallback& callback, 57 const net::CompletionCallback& callback,
51 RequestHandle* request, 58 RequestHandle* request,
52 const BoundNetLog& net_log) override; 59 const BoundNetLog& net_log) override;
53 void CancelRequest(RequestHandle request) override; 60 void CancelRequest(RequestHandle request) override;
54 LoadState GetLoadState(RequestHandle request) const override; 61 LoadState GetLoadState(RequestHandle request) const override;
(...skipping 14 matching lines...) Expand all
69 76
70 // Mojo host resolver service and binding. 77 // Mojo host resolver service and binding.
71 scoped_ptr<interfaces::HostResolver> mojo_host_resolver_; 78 scoped_ptr<interfaces::HostResolver> mojo_host_resolver_;
72 scoped_ptr<mojo::Binding<interfaces::HostResolver>> 79 scoped_ptr<mojo::Binding<interfaces::HostResolver>>
73 mojo_host_resolver_binding_; 80 mojo_host_resolver_binding_;
74 81
75 std::set<Job*> pending_jobs_; 82 std::set<Job*> pending_jobs_;
76 83
77 base::ThreadChecker thread_checker_; 84 base::ThreadChecker thread_checker_;
78 85
86 scoped_ptr<base::ScopedClosureRunner> on_delete_callback_runner_;
87
79 DISALLOW_COPY_AND_ASSIGN(ProxyResolverMojo); 88 DISALLOW_COPY_AND_ASSIGN(ProxyResolverMojo);
80 }; 89 };
81 90
82 // Implementation of ProxyResolverFactory that connects to a Mojo service to 91 // Implementation of ProxyResolverFactory that connects to a Mojo service to
83 // create implementations of a Mojo proxy resolver to back a ProxyResolverMojo. 92 // create implementations of a Mojo proxy resolver to back a ProxyResolverMojo.
84 class ProxyResolverFactoryMojo : public ProxyResolverFactory { 93 class ProxyResolverFactoryMojo : public ProxyResolverFactory {
85 public: 94 public:
86 ProxyResolverFactoryMojo(interfaces::ProxyResolverFactory* mojo_proxy_factory, 95 ProxyResolverFactoryMojo(MojoProxyResolverFactory* mojo_proxy_factory,
87 HostResolver* host_resolver); 96 HostResolver* host_resolver);
97 ~ProxyResolverFactoryMojo() override;
88 98
89 // ProxyResolverFactory override. 99 // ProxyResolverFactory override.
90 int CreateProxyResolver( 100 int CreateProxyResolver(
91 const scoped_refptr<ProxyResolverScriptData>& pac_script, 101 const scoped_refptr<ProxyResolverScriptData>& pac_script,
92 scoped_ptr<ProxyResolver>* resolver, 102 scoped_ptr<ProxyResolver>* resolver,
93 const CompletionCallback& callback, 103 const CompletionCallback& callback,
94 scoped_ptr<Request>* request) override; 104 scoped_ptr<Request>* request) override;
95 105
96 private: 106 private:
97 class Job; 107 class Job;
98 108
99 interfaces::ProxyResolverFactory* const mojo_proxy_factory_; 109 MojoProxyResolverFactory* const mojo_proxy_factory_;
100 HostResolver* const host_resolver_; 110 HostResolver* const host_resolver_;
101 111
102 DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactoryMojo); 112 DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactoryMojo);
103 }; 113 };
104 114
105 } // namespace net 115 } // namespace net
106 116
107 #endif // NET_PROXY_PROXY_RESOLVER_MOJO_H_ 117 #endif // NET_PROXY_PROXY_RESOLVER_MOJO_H_
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory.h ('k') | net/proxy/proxy_resolver_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698