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

Unified Diff: chrome/browser/net/utility_process_mojo_proxy_resolver_factory.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, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h
diff --git a/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h b/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h
index 0186253071b9316186fb533496187905426bd74f..79520cdc9a8eb84a10c288e157ea38fdd2c533cd 100644
--- a/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h
+++ b/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h
@@ -6,8 +6,14 @@
#define CHROME_BROWSER_NET_UTILITY_PROCESS_MOJO_PROXY_RESOLVER_FACTORY_H_
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
#include "net/proxy/mojo_proxy_resolver_factory.h"
+namespace content {
+class UtilityProcessHost;
+}
+
template <typename Type>
struct DefaultSingletonTraits;
@@ -22,8 +28,9 @@ class UtilityProcessMojoProxyResolverFactory
static UtilityProcessMojoProxyResolverFactory* GetInstance();
// Overridden from net::MojoProxyResolverFactory:
- void Create(mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
- net::interfaces::HostResolverPtr host_resolver) override;
+ scoped_ptr<base::ScopedClosureRunner> Create(
+ mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
+ net::interfaces::HostResolverPtr host_resolver) override;
private:
friend struct DefaultSingletonTraits<UtilityProcessMojoProxyResolverFactory>;
@@ -33,12 +40,24 @@ class UtilityProcessMojoProxyResolverFactory
// Overridden from mojo::ErrorHandler:
void OnConnectionError() override;
+ // Invoked each time a proxy resolver is destroyed.
+ void OnResolverDestroyed();
+
+ // Invoked once an idle timeout has elapsed after all proxy resolvers are
+ // destroyed.
+ void OnIdleTimeout();
+
// Creates a new utility process and connects to its Mojo proxy resolver
// factory.
void CreateProcessAndConnect();
net::interfaces::ProxyResolverFactoryPtr resolver_factory_;
+ base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
+ size_t num_proxy_resolvers_ = 0;
+
+ base::OneShotTimer<UtilityProcessMojoProxyResolverFactory> idle_timer_;
+
DISALLOW_COPY_AND_ASSIGN(UtilityProcessMojoProxyResolverFactory);
};

Powered by Google App Engine
This is Rietveld 408576698