| 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 "content/browser/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
| 6 | 6 |
| 7 #include <unordered_map> | 7 #include <unordered_map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "content/browser/gpu/gpu_process_host.h" | 18 #include "content/browser/gpu/gpu_process_host.h" |
| 19 #include "content/browser/mojo/constants.h" | 19 #include "content/browser/mojo/constants.h" |
| 20 #include "content/common/gpu_process_launch_causes.h" | 20 #include "content/common/gpu_process_launch_causes.h" |
| 21 #include "content/common/mojo/mojo_shell_connection_impl.h" | 21 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 22 #include "content/common/process_control.mojom.h" | 22 #include "content/common/process_control.mojom.h" |
| 23 #include "content/grit/content_resources.h" | 23 #include "content/grit/content_resources.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
| 26 #include "content/public/browser/utility_process_host.h" | 26 #include "content/public/browser/utility_process_host.h" |
| 27 #include "content/public/browser/utility_process_host_client.h" | 27 #include "content/public/browser/utility_process_host_client.h" |
| 28 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
| 29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 30 #include "content/public/common/service_registry.h" | |
| 31 #include "mojo/edk/embedder/embedder.h" | 30 #include "mojo/edk/embedder/embedder.h" |
| 32 #include "mojo/public/cpp/bindings/interface_request.h" | 31 #include "mojo/public/cpp/bindings/interface_request.h" |
| 33 #include "mojo/public/cpp/bindings/string.h" | 32 #include "mojo/public/cpp/bindings/string.h" |
| 34 #include "services/catalog/catalog.h" | 33 #include "services/catalog/catalog.h" |
| 35 #include "services/catalog/manifest_provider.h" | 34 #include "services/catalog/manifest_provider.h" |
| 36 #include "services/catalog/store.h" | 35 #include "services/catalog/store.h" |
| 37 #include "services/shell/connect_params.h" | 36 #include "services/shell/connect_params.h" |
| 38 #include "services/shell/native_runner.h" | 37 #include "services/shell/native_runner.h" |
| 39 #include "services/shell/public/cpp/identity.h" | 38 #include "services/shell/public/cpp/identity.h" |
| 40 #include "services/shell/public/cpp/shell_client.h" | 39 #include "services/shell/public/cpp/shell_client.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 53 mojo::InterfaceRequest<mojom::ProcessControl> request, | 52 mojo::InterfaceRequest<mojom::ProcessControl> request, |
| 54 const base::string16& process_name, | 53 const base::string16& process_name, |
| 55 bool use_sandbox) { | 54 bool use_sandbox) { |
| 56 UtilityProcessHost* process_host = | 55 UtilityProcessHost* process_host = |
| 57 UtilityProcessHost::Create(nullptr, nullptr); | 56 UtilityProcessHost::Create(nullptr, nullptr); |
| 58 process_host->SetName(process_name); | 57 process_host->SetName(process_name); |
| 59 if (!use_sandbox) | 58 if (!use_sandbox) |
| 60 process_host->DisableSandbox(); | 59 process_host->DisableSandbox(); |
| 61 process_host->Start(); | 60 process_host->Start(); |
| 62 | 61 |
| 63 ServiceRegistry* services = process_host->GetServiceRegistry(); | 62 process_host->GetRemoteInterfaces()->GetInterface(std::move(request)); |
| 64 services->ConnectToRemoteService(std::move(request)); | |
| 65 } | 63 } |
| 66 | 64 |
| 67 void OnApplicationLoaded(const std::string& name, bool success) { | 65 void OnApplicationLoaded(const std::string& name, bool success) { |
| 68 if (!success) | 66 if (!success) |
| 69 LOG(ERROR) << "Failed to launch Mojo application for " << name; | 67 LOG(ERROR) << "Failed to launch Mojo application for " << name; |
| 70 } | 68 } |
| 71 | 69 |
| 72 void LaunchAppInUtilityProcess(const std::string& app_name, | 70 void LaunchAppInUtilityProcess(const std::string& app_name, |
| 73 const base::string16& process_name, | 71 const base::string16& process_name, |
| 74 bool use_sandbox, | 72 bool use_sandbox, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 if (!process_host) { | 94 if (!process_host) { |
| 97 DLOG(ERROR) << "GPU process host not available."; | 95 DLOG(ERROR) << "GPU process host not available."; |
| 98 return; | 96 return; |
| 99 } | 97 } |
| 100 | 98 |
| 101 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual | 99 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual |
| 102 // process is dead. In that case, |request| will be dropped and application | 100 // process is dead. In that case, |request| will be dropped and application |
| 103 // load requests through mojom::ProcessControl will also fail. Make sure we | 101 // load requests through mojom::ProcessControl will also fail. Make sure we |
| 104 // handle | 102 // handle |
| 105 // these cases correctly. | 103 // these cases correctly. |
| 106 process_host->GetServiceRegistry()->ConnectToRemoteService( | 104 process_host->GetRemoteInterfaces()->GetInterface(std::move(request)); |
| 107 std::move(request)); | |
| 108 } | 105 } |
| 109 | 106 |
| 110 void LaunchAppInGpuProcess(const std::string& app_name, | 107 void LaunchAppInGpuProcess(const std::string& app_name, |
| 111 shell::mojom::ShellClientRequest request) { | 108 shell::mojom::ShellClientRequest request) { |
| 112 mojom::ProcessControlPtr process_control; | 109 mojom::ProcessControlPtr process_control; |
| 113 mojom::ProcessControlRequest process_request = | 110 mojom::ProcessControlRequest process_request = |
| 114 mojo::GetProxy(&process_control); | 111 mojo::GetProxy(&process_control); |
| 115 BrowserThread::PostTask( | 112 BrowserThread::PostTask( |
| 116 BrowserThread::IO, FROM_HERE, | 113 BrowserThread::IO, FROM_HERE, |
| 117 base::Bind(&RequestGpuProcessControl, base::Passed(&process_request))); | 114 base::Bind(&RequestGpuProcessControl, base::Passed(&process_request))); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 shell::Identity source_id(requestor_name, user_id); | 319 shell::Identity source_id(requestor_name, user_id); |
| 323 params->set_source(source_id); | 320 params->set_source(source_id); |
| 324 params->set_target(shell::Identity(name, user_id)); | 321 params->set_target(shell::Identity(name, user_id)); |
| 325 params->set_remote_interfaces(std::move(request)); | 322 params->set_remote_interfaces(std::move(request)); |
| 326 params->set_local_interfaces(std::move(exposed_services)); | 323 params->set_local_interfaces(std::move(exposed_services)); |
| 327 params->set_connect_callback(callback); | 324 params->set_connect_callback(callback); |
| 328 shell_->Connect(std::move(params)); | 325 shell_->Connect(std::move(params)); |
| 329 } | 326 } |
| 330 | 327 |
| 331 } // namespace content | 328 } // namespace content |
| OLD | NEW |