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

Side by Side Diff: chrome/browser/net/chrome_mojo_proxy_resolver_factory.h

Issue 2930743002: Use a MojoProxyResolverFactory on Android. (Closed)
Patch Set: Oops Created 3 years, 6 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 | « chrome/browser/BUILD.gn ('k') | chrome/browser/net/chrome_mojo_proxy_resolver_factory.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 CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ 5 #ifndef CHROME_BROWSER_NET_CHROME_MOJO_PROXY_RESOLVER_FACTORY_H_
6 #define CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ 6 #define CHROME_BROWSER_NET_CHROME_MOJO_PROXY_RESOLVER_FACTORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "net/proxy/mojo_proxy_resolver_factory.h" 14 #include "net/proxy/mojo_proxy_resolver_factory.h"
15 15
16 #if !defined(OS_ANDROID)
16 namespace content { 17 namespace content {
17 class UtilityProcessHost; 18 class UtilityProcessHost;
18 } 19 }
20 #endif
21
19 namespace base { 22 namespace base {
20 template <typename Type> 23 template <typename Type>
21 struct DefaultSingletonTraits; 24 struct DefaultSingletonTraits;
22 } // namespace base 25 } // namespace base
23 26
24 // A factory used to create connections to Mojo proxy resolver services run in a 27 // A factory used to create connections to Mojo proxy resolver services. On
25 // utility process. All Mojo proxy resolver services will be run in the same 28 // Android, the proxy resolvers will run in the browser process, and on other
26 // utility process. Utility process crashes are detected and the utility 29 // platforms, they'll all be run in the same utility process. Utility process
27 // process is automatically restarted. 30 // crashes are detected and the utility process is automatically restarted.
28 class UtilityProcessMojoProxyResolverFactory 31 class ChromeMojoProxyResolverFactory : public net::MojoProxyResolverFactory {
29 : public net::MojoProxyResolverFactory {
30 public: 32 public:
31 static UtilityProcessMojoProxyResolverFactory* GetInstance(); 33 static ChromeMojoProxyResolverFactory* GetInstance();
32 34
33 // Overridden from net::MojoProxyResolverFactory: 35 // Overridden from net::MojoProxyResolverFactory:
34 std::unique_ptr<base::ScopedClosureRunner> CreateResolver( 36 std::unique_ptr<base::ScopedClosureRunner> CreateResolver(
35 const std::string& pac_script, 37 const std::string& pac_script,
36 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req, 38 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
37 net::interfaces::ProxyResolverFactoryRequestClientPtr client) override; 39 net::interfaces::ProxyResolverFactoryRequestClientPtr client) override;
38 40
39 private: 41 private:
40 friend struct base::DefaultSingletonTraits< 42 friend struct base::DefaultSingletonTraits<ChromeMojoProxyResolverFactory>;
41 UtilityProcessMojoProxyResolverFactory>; 43 ChromeMojoProxyResolverFactory();
42 UtilityProcessMojoProxyResolverFactory(); 44 ~ChromeMojoProxyResolverFactory() override;
43 ~UtilityProcessMojoProxyResolverFactory() override;
44 45
45 // Error handler callback for |resolver_factory_|. 46 // Creates the proxy resolver factory. On desktop, creates a new utility
46 void OnConnectionError(); 47 // process before creating it out of process. On Android, creates it on the
48 // current thread.
49 void CreateFactory();
50
51 // Destroys |resolver_factory_|.
52 void DestroyFactory();
47 53
48 // Invoked each time a proxy resolver is destroyed. 54 // Invoked each time a proxy resolver is destroyed.
49 void OnResolverDestroyed(); 55 void OnResolverDestroyed();
50 56
51 // Invoked once an idle timeout has elapsed after all proxy resolvers are 57 // Invoked once an idle timeout has elapsed after all proxy resolvers are
52 // destroyed. 58 // destroyed.
53 void OnIdleTimeout(); 59 void OnIdleTimeout();
54 60
55 // Creates a new utility process and connects to its Mojo proxy resolver
56 // factory.
57 void CreateProcessAndConnect();
58
59 net::interfaces::ProxyResolverFactoryPtr resolver_factory_; 61 net::interfaces::ProxyResolverFactoryPtr resolver_factory_;
60 62
63 #if !defined(OS_ANDROID)
61 base::WeakPtr<content::UtilityProcessHost> weak_utility_process_host_; 64 base::WeakPtr<content::UtilityProcessHost> weak_utility_process_host_;
65 #endif
66
62 size_t num_proxy_resolvers_ = 0; 67 size_t num_proxy_resolvers_ = 0;
63 68
64 base::OneShotTimer idle_timer_; 69 base::OneShotTimer idle_timer_;
65 70
66 base::ThreadChecker thread_checker_; 71 base::ThreadChecker thread_checker_;
67 72
68 DISALLOW_COPY_AND_ASSIGN(UtilityProcessMojoProxyResolverFactory); 73 DISALLOW_COPY_AND_ASSIGN(ChromeMojoProxyResolverFactory);
69 }; 74 };
70 75
71 #endif // CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ 76 #endif // CHROME_BROWSER_NET_CHROME_MOJO_PROXY_RESOLVER_FACTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698