OLD | NEW |
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_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ |
6 #define CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ | 6 #define CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "net/proxy/mojo_proxy_resolver_factory.h" | 12 #include "net/proxy/mojo_proxy_resolver_factory.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 class UtilityProcessHost; | 15 class UtilityProcessHost; |
16 } | 16 } |
17 | 17 namespace base { |
18 template <typename Type> | 18 template <typename Type> |
19 struct DefaultSingletonTraits; | 19 struct DefaultSingletonTraits; |
| 20 } // namespace base |
20 | 21 |
21 // A factory used to create connections to Mojo proxy resolver services run in a | 22 // A factory used to create connections to Mojo proxy resolver services run in a |
22 // utility process. All Mojo proxy resolver services will be run in the same | 23 // utility process. All Mojo proxy resolver services will be run in the same |
23 // utility process. Utility process crashes are detected and the utility | 24 // utility process. Utility process crashes are detected and the utility |
24 // process is automatically restarted. | 25 // process is automatically restarted. |
25 class UtilityProcessMojoProxyResolverFactory | 26 class UtilityProcessMojoProxyResolverFactory |
26 : public net::MojoProxyResolverFactory { | 27 : public net::MojoProxyResolverFactory { |
27 public: | 28 public: |
28 static UtilityProcessMojoProxyResolverFactory* GetInstance(); | 29 static UtilityProcessMojoProxyResolverFactory* GetInstance(); |
29 | 30 |
30 // Overridden from net::MojoProxyResolverFactory: | 31 // Overridden from net::MojoProxyResolverFactory: |
31 scoped_ptr<base::ScopedClosureRunner> CreateResolver( | 32 scoped_ptr<base::ScopedClosureRunner> CreateResolver( |
32 const mojo::String& pac_script, | 33 const mojo::String& pac_script, |
33 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req, | 34 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req, |
34 net::interfaces::ProxyResolverFactoryRequestClientPtr client) override; | 35 net::interfaces::ProxyResolverFactoryRequestClientPtr client) override; |
35 | 36 |
36 private: | 37 private: |
37 friend struct DefaultSingletonTraits<UtilityProcessMojoProxyResolverFactory>; | 38 friend struct base::DefaultSingletonTraits< |
| 39 UtilityProcessMojoProxyResolverFactory>; |
38 UtilityProcessMojoProxyResolverFactory(); | 40 UtilityProcessMojoProxyResolverFactory(); |
39 ~UtilityProcessMojoProxyResolverFactory() override; | 41 ~UtilityProcessMojoProxyResolverFactory() override; |
40 | 42 |
41 // Error handler callback for |resolver_factory_|. | 43 // Error handler callback for |resolver_factory_|. |
42 void OnConnectionError(); | 44 void OnConnectionError(); |
43 | 45 |
44 // Invoked each time a proxy resolver is destroyed. | 46 // Invoked each time a proxy resolver is destroyed. |
45 void OnResolverDestroyed(); | 47 void OnResolverDestroyed(); |
46 | 48 |
47 // Invoked once an idle timeout has elapsed after all proxy resolvers are | 49 // Invoked once an idle timeout has elapsed after all proxy resolvers are |
(...skipping 10 matching lines...) Expand all Loading... |
58 size_t num_proxy_resolvers_ = 0; | 60 size_t num_proxy_resolvers_ = 0; |
59 | 61 |
60 base::OneShotTimer<UtilityProcessMojoProxyResolverFactory> idle_timer_; | 62 base::OneShotTimer<UtilityProcessMojoProxyResolverFactory> idle_timer_; |
61 | 63 |
62 base::ThreadChecker thread_checker_; | 64 base::ThreadChecker thread_checker_; |
63 | 65 |
64 DISALLOW_COPY_AND_ASSIGN(UtilityProcessMojoProxyResolverFactory); | 66 DISALLOW_COPY_AND_ASSIGN(UtilityProcessMojoProxyResolverFactory); |
65 }; | 67 }; |
66 | 68 |
67 #endif // CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ | 69 #endif // CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_ |
OLD | NEW |