Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / net / utility_process_mojo_proxy_resolver_factory.h
blobf6e9e21d5aa2efaf1ad8963e4fda321a67ea7014
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.
5 #ifndef CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_
6 #define CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_checker.h"
11 #include "base/timer/timer.h"
12 #include "net/proxy/mojo_proxy_resolver_factory.h"
14 namespace content {
15 class UtilityProcessHost;
18 template <typename Type>
19 struct DefaultSingletonTraits;
21 // 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. Utility process crashes are detected and the utility
24 // process is automatically restarted.
25 class UtilityProcessMojoProxyResolverFactory
26 : public net::MojoProxyResolverFactory,
27 public mojo::ErrorHandler {
28 public:
29 static UtilityProcessMojoProxyResolverFactory* GetInstance();
31 // Overridden from net::MojoProxyResolverFactory:
32 scoped_ptr<base::ScopedClosureRunner> CreateResolver(
33 const mojo::String& pac_script,
34 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
35 net::interfaces::HostResolverPtr host_resolver,
36 net::interfaces::ProxyResolverErrorObserverPtr error_observer,
37 net::interfaces::ProxyResolverFactoryRequestClientPtr client) override;
39 private:
40 friend struct DefaultSingletonTraits<UtilityProcessMojoProxyResolverFactory>;
41 UtilityProcessMojoProxyResolverFactory();
42 ~UtilityProcessMojoProxyResolverFactory() override;
44 // Overridden from mojo::ErrorHandler:
45 void OnConnectionError() override;
47 // Invoked each time a proxy resolver is destroyed.
48 void OnResolverDestroyed();
50 // Invoked once an idle timeout has elapsed after all proxy resolvers are
51 // destroyed.
52 void OnIdleTimeout();
54 // Creates a new utility process and connects to its Mojo proxy resolver
55 // factory.
56 void CreateProcessAndConnect();
58 net::interfaces::ProxyResolverFactoryPtr resolver_factory_;
60 base::WeakPtr<content::UtilityProcessHost> weak_utility_process_host_;
61 size_t num_proxy_resolvers_ = 0;
63 base::OneShotTimer<UtilityProcessMojoProxyResolverFactory> idle_timer_;
65 base::ThreadChecker thread_checker_;
67 DISALLOW_COPY_AND_ASSIGN(UtilityProcessMojoProxyResolverFactory);
70 #endif // CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_