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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h"
6
7 #include "base/logging.h"
8 #include "base/memory/singleton.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/utility_process_host.h"
11 #include "content/public/browser/utility_process_host_client.h"
12 #include "content/public/common/service_registry.h"
13 #include "net/proxy/mojo_proxy_resolver_factory.h"
14
15 // static
16 UtilityProcessMojoProxyResolverFactory*
17 UtilityProcessMojoProxyResolverFactory::GetInstance() {
18 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
19 return Singleton<
20 UtilityProcessMojoProxyResolverFactory,
21 LeakySingletonTraits<UtilityProcessMojoProxyResolverFactory>>::get();
22 }
23
24 UtilityProcessMojoProxyResolverFactory::
25 UtilityProcessMojoProxyResolverFactory() {
26 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
27 }
28
29 UtilityProcessMojoProxyResolverFactory::
30 ~UtilityProcessMojoProxyResolverFactory() {
31 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
32 }
33
34 void UtilityProcessMojoProxyResolverFactory::CreateProcessAndConnect() {
35 DVLOG(1) << "Attempting to create utility process for proxy resolver";
36 content::UtilityProcessHost* utility_process_host =
37 content::UtilityProcessHost::Create(
38 scoped_refptr<content::UtilityProcessHostClient>(),
39 base::MessageLoopProxy::current().get());
40 bool process_started = utility_process_host->StartMojoMode();
41 if (process_started) {
42 content::ServiceRegistry* service_registry =
43 utility_process_host->GetServiceRegistry();
44 service_registry->ConnectToRemoteService(&resolver_factory_);
45 resolver_factory_.set_error_handler(this);
46 } else {
47 LOG(ERROR) << "Unable to connect to utility process";
48 }
49 }
50
51 void UtilityProcessMojoProxyResolverFactory::Create(
52 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
53 net::interfaces::HostResolverPtr host_resolver) {
54 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
55 if (!resolver_factory_)
56 CreateProcessAndConnect();
57
58 if (!resolver_factory_) {
59 // If there's still no factory, then utility process creation failed so
60 // close |req|'s message pipe, which should cause a connection error.
61 req = nullptr;
62 return;
63 }
64 resolver_factory_->CreateResolver(req.Pass(), host_resolver.Pass());
65 }
66
67 void UtilityProcessMojoProxyResolverFactory::OnConnectionError() {
68 DVLOG(1) << "Disconnection from utility process detected";
69 resolver_factory_.reset();
70 }
OLDNEW
« 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