| 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/service_manager/service_manager_context.h" | 5 #include "content/browser/service_manager/service_manager_context.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "content/browser/child_process_launcher.h" | 19 #include "content/browser/child_process_launcher.h" |
| 20 #include "content/browser/gpu/gpu_process_host.h" | 20 #include "content/browser/gpu/gpu_process_host.h" |
| 21 #include "content/browser/service_manager/merge_dictionary.h" | 21 #include "content/browser/service_manager/merge_dictionary.h" |
| 22 #include "content/browser/wake_lock/wake_lock_context_host.h" | 22 #include "content/browser/wake_lock/wake_lock_context_host.h" |
| 23 #include "content/common/service_manager/service_manager_connection_impl.h" | 23 #include "content/common/service_manager/service_manager_connection_impl.h" |
| 24 #include "content/grit/content_resources.h" | 24 #include "content/grit/content_resources.h" |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/content_browser_client.h" | 26 #include "content/public/browser/content_browser_client.h" |
| 27 #include "content/public/browser/gpu_service_registry.h" |
| 27 #include "content/public/browser/utility_process_host.h" | 28 #include "content/public/browser/utility_process_host.h" |
| 28 #include "content/public/browser/utility_process_host_client.h" | 29 #include "content/public/browser/utility_process_host_client.h" |
| 29 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
| 30 #include "content/public/common/service_manager_connection.h" | 31 #include "content/public/common/service_manager_connection.h" |
| 31 #include "content/public/common/service_names.mojom.h" | 32 #include "content/public/common/service_names.mojom.h" |
| 32 #include "mojo/edk/embedder/embedder.h" | 33 #include "mojo/edk/embedder/embedder.h" |
| 33 #include "services/catalog/catalog.h" | 34 #include "services/catalog/catalog.h" |
| 34 #include "services/catalog/manifest_provider.h" | 35 #include "services/catalog/manifest_provider.h" |
| 35 #include "services/catalog/public/cpp/manifest_parsing_util.h" | 36 #include "services/catalog/public/cpp/manifest_parsing_util.h" |
| 36 #include "services/catalog/public/interfaces/constants.mojom.h" | 37 #include "services/catalog/public/interfaces/constants.mojom.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 bool use_sandbox, | 62 bool use_sandbox, |
| 62 service_manager::mojom::ServiceRequest request) { | 63 service_manager::mojom::ServiceRequest request) { |
| 63 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 64 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 64 UtilityProcessHost* process_host = | 65 UtilityProcessHost* process_host = |
| 65 UtilityProcessHost::Create(nullptr, nullptr); | 66 UtilityProcessHost::Create(nullptr, nullptr); |
| 66 process_host->SetName(process_name); | 67 process_host->SetName(process_name); |
| 67 if (!use_sandbox) | 68 if (!use_sandbox) |
| 68 process_host->DisableSandbox(); | 69 process_host->DisableSandbox(); |
| 69 process_host->Start(); | 70 process_host->Start(); |
| 70 service_manager::mojom::ServiceFactoryPtr service_factory; | 71 service_manager::mojom::ServiceFactoryPtr service_factory; |
| 71 process_host->GetRemoteInterfaces()->GetInterface( | 72 BindInterface(process_host, mojo::MakeRequest(&service_factory)); |
| 72 mojo::MakeRequest(&service_factory)); | |
| 73 service_factory->CreateService(std::move(request), service_name); | 73 service_factory->CreateService(std::move(request), service_name); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be | 76 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be |
| 77 // called on IO thread. | 77 // called on IO thread. |
| 78 void StartServiceInGpuProcess(const std::string& service_name, | 78 void StartServiceInGpuProcess(const std::string& service_name, |
| 79 service_manager::mojom::ServiceRequest request) { | 79 service_manager::mojom::ServiceRequest request) { |
| 80 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 80 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 81 GpuProcessHost* process_host = | 81 GpuProcessHost* process_host = |
| 82 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED); | 82 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED); |
| 83 if (!process_host) { | 83 if (!process_host) { |
| 84 DLOG(ERROR) << "GPU process host not available."; | 84 DLOG(ERROR) << "GPU process host not available."; |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 service_manager::mojom::ServiceFactoryPtr service_factory; | 88 service_manager::mojom::ServiceFactoryPtr service_factory; |
| 89 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual | 89 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual |
| 90 // process is dead. In that case, |request| will be dropped and application | 90 // process is dead. In that case, |request| will be dropped and application |
| 91 // load requests through ServiceFactory will also fail. Make sure we handle | 91 // load requests through ServiceFactory will also fail. Make sure we handle |
| 92 // these cases correctly. | 92 // these cases correctly. |
| 93 process_host->GetRemoteInterfaces()->GetInterface( | 93 BindInterfaceInGpuProcess(mojo::MakeRequest(&service_factory)); |
| 94 mojo::MakeRequest(&service_factory)); | |
| 95 service_factory->CreateService(std::move(request), service_name); | 94 service_factory->CreateService(std::move(request), service_name); |
| 96 } | 95 } |
| 97 | 96 |
| 98 // A ManifestProvider which resolves application names to builtin manifest | 97 // A ManifestProvider which resolves application names to builtin manifest |
| 99 // resources for the catalog service to consume. | 98 // resources for the catalog service to consume. |
| 100 class BuiltinManifestProvider : public catalog::ManifestProvider { | 99 class BuiltinManifestProvider : public catalog::ManifestProvider { |
| 101 public: | 100 public: |
| 102 BuiltinManifestProvider() {} | 101 BuiltinManifestProvider() {} |
| 103 ~BuiltinManifestProvider() override {} | 102 ~BuiltinManifestProvider() override {} |
| 104 | 103 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 base::Bind(&DestroyConnectorOnIOThread)); | 365 base::Bind(&DestroyConnectorOnIOThread)); |
| 367 } | 366 } |
| 368 | 367 |
| 369 // static | 368 // static |
| 370 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 369 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
| 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 372 return g_io_thread_connector.Get().get(); | 371 return g_io_thread_connector.Get().get(); |
| 373 } | 372 } |
| 374 | 373 |
| 375 } // namespace content | 374 } // namespace content |
| OLD | NEW |