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

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: Address review comments. 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 namespace chrome_browser_net {
16
17 // static
18 UtilityProcessMojoProxyResolverFactory*
19 UtilityProcessMojoProxyResolverFactory::GetInstance() {
20 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
21 return Singleton<
22 UtilityProcessMojoProxyResolverFactory,
23 LeakySingletonTraits<UtilityProcessMojoProxyResolverFactory>>::get();
24 }
25
26 UtilityProcessMojoProxyResolverFactory::
27 UtilityProcessMojoProxyResolverFactory() {
28 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
29 }
30
31 UtilityProcessMojoProxyResolverFactory::
32 ~UtilityProcessMojoProxyResolverFactory() {
33 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
34 }
35
36 void UtilityProcessMojoProxyResolverFactory::CreateProcessAndConnect() {
37 DVLOG(1) << "Attempting to create utility process for proxy resolver";
38 content::UtilityProcessHost* utility_process_host =
39 content::UtilityProcessHost::Create(
eroman 2015/03/06 05:48:21 What is the lifetime of this process? It seems lik
Anand Mistry (off Chromium) 2015/03/10 07:24:23 Yes, for now. For other Mojo services, I'm plannin
eroman 2015/03/11 18:48:35 One way we could solve this is to make ProxyServic
40 scoped_refptr<content::UtilityProcessHostClient>(),
41 base::MessageLoopProxy::current().get());
42 bool process_started = utility_process_host->StartMojoMode();
43 if (process_started) {
44 content::ServiceRegistry* service_registry =
45 utility_process_host->GetServiceRegistry();
46 service_registry->ConnectToRemoteService(&resolver_factory_);
47 resolver_factory_.set_error_handler(this);
48 } else {
49 LOG(ERROR) << "Unable to connect to utility process";
50 }
51 }
52
53 void UtilityProcessMojoProxyResolverFactory::Create(
54 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req,
55 net::interfaces::HostResolverPtr host_resolver) {
56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
57 if (!resolver_factory_)
58 CreateProcessAndConnect();
59
60 if (!resolver_factory_) {
61 // If there's still no factory, then utility process creation failed so
62 // close |req|'s message pipe, which should cause a connection error.
63 req = nullptr;
64 return;
65 }
66 resolver_factory_->CreateResolver(req.Pass(), host_resolver.Pass());
67 }
68
69 void UtilityProcessMojoProxyResolverFactory::OnConnectionError() {
70 DVLOG(1) << "Disconnection from utility process detected";
71 resolver_factory_.reset();
72 }
73
74 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698