| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h" | 5 #include "chrome/browser/net/utility_process_mojo_proxy_resolver_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/utility_process_host.h" | 10 #include "content/public/browser/utility_process_host.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 utility_process_host->GetServiceRegistry(); | 43 utility_process_host->GetServiceRegistry(); |
| 44 service_registry->ConnectToRemoteService(&resolver_factory_); | 44 service_registry->ConnectToRemoteService(&resolver_factory_); |
| 45 resolver_factory_.set_error_handler(this); | 45 resolver_factory_.set_error_handler(this); |
| 46 } else { | 46 } else { |
| 47 LOG(ERROR) << "Unable to connect to utility process"; | 47 LOG(ERROR) << "Unable to connect to utility process"; |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void UtilityProcessMojoProxyResolverFactory::Create( | 51 void UtilityProcessMojoProxyResolverFactory::Create( |
| 52 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req, | 52 mojo::InterfaceRequest<net::interfaces::ProxyResolver> req, |
| 53 net::interfaces::HostResolverPtr host_resolver) { | 53 net::interfaces::HostResolverPtr host_resolver, |
| 54 net::interfaces::ProxyResolverErrorObserverPtr error_observer) { |
| 54 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 55 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 55 if (!resolver_factory_) | 56 if (!resolver_factory_) |
| 56 CreateProcessAndConnect(); | 57 CreateProcessAndConnect(); |
| 57 | 58 |
| 58 if (!resolver_factory_) { | 59 if (!resolver_factory_) { |
| 59 // If there's still no factory, then utility process creation failed so | 60 // 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 // close |req|'s message pipe, which should cause a connection error. |
| 61 req = nullptr; | 62 req = nullptr; |
| 62 return; | 63 return; |
| 63 } | 64 } |
| 64 resolver_factory_->CreateResolver(req.Pass(), host_resolver.Pass()); | 65 resolver_factory_->CreateResolver(req.Pass(), host_resolver.Pass(), |
| 66 error_observer.Pass()); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void UtilityProcessMojoProxyResolverFactory::OnConnectionError() { | 69 void UtilityProcessMojoProxyResolverFactory::OnConnectionError() { |
| 68 DVLOG(1) << "Disconnection from utility process detected"; | 70 DVLOG(1) << "Disconnection from utility process detected"; |
| 69 resolver_factory_.reset(); | 71 resolver_factory_.reset(); |
| 70 } | 72 } |
| OLD | NEW |