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

Unified Diff: chrome/browser/net/utility_process_mojo_proxy_resolver_factory.cc

Issue 940813003: Use a utility process for the Mojo v8 proxy resolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-pac-in-process-enable
Patch Set: Remove unneeded forward decl. Created 5 years, 9 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
« no previous file with comments | « chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/utility_process_mojo_proxy_resolver_factory.cc
diff --git a/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.cc b/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..501d44a9ca7384fd3d482b1caf5544cd4371c481
--- /dev/null
+++ b/chrome/browser/net/utility_process_mojo_proxy_resolver_factory.cc
@@ -0,0 +1,70 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h"
+
+#include "base/logging.h"
+#include "base/memory/singleton.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/utility_process_host.h"
+#include "content/public/browser/utility_process_host_client.h"
+#include "content/public/common/service_registry.h"
+#include "net/proxy/mojo_proxy_resolver_factory.h"
+
+// static
+UtilityProcessMojoProxyResolverFactory*
+UtilityProcessMojoProxyResolverFactory::GetInstance() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ return Singleton<
+ UtilityProcessMojoProxyResolverFactory,
+ LeakySingletonTraits<UtilityProcessMojoProxyResolverFactory>>::get();
+}
+
+UtilityProcessMojoProxyResolverFactory::
+ UtilityProcessMojoProxyResolverFactory() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+UtilityProcessMojoProxyResolverFactory::
+ ~UtilityProcessMojoProxyResolverFactory() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+void UtilityProcessMojoProxyResolverFactory::CreateProcessAndConnect() {
+ DVLOG(1) << "Attempting to create utility process for proxy resolver";
+ content::UtilityProcessHost* utility_process_host =
+ content::UtilityProcessHost::Create(
+ scoped_refptr<content::UtilityProcessHostClient>(),
+ base::MessageLoopProxy::current().get());
+ bool process_started = utility_process_host->StartMojoMode();
+ if (process_started) {
+ content::ServiceRegistry* service_registry =
+ utility_process_host->GetServiceRegistry();
+ service_registry->ConnectToRemoteService(&resolver_factory_);
+ resolver_factory_.set_error_handler(this);
+ } else {
+ LOG(ERROR) << "Unable to connect to utility process";
+ }
+}
+
+void UtilityProcessMojoProxyResolverFactory::Create(
+ mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
+ net::interfaces::HostResolverPtr host_resolver) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ if (!resolver_factory_)
+ CreateProcessAndConnect();
+
+ if (!resolver_factory_) {
+ // If there's still no factory, then utility process creation failed so
+ // close |req|'s message pipe, which should cause a connection error.
+ req = nullptr;
+ return;
+ }
+ resolver_factory_->CreateResolver(req.Pass(), host_resolver.Pass());
+}
+
+void UtilityProcessMojoProxyResolverFactory::OnConnectionError() {
+ DVLOG(1) << "Disconnection from utility process detected";
+ resolver_factory_.reset();
+}
« no previous file with comments | « chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698