| 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/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "content/browser/gpu/gpu_process_host.h" | 18 #include "content/browser/gpu/gpu_process_host.h" |
| 18 #include "content/browser/service_manager/merge_dictionary.h" | 19 #include "content/browser/service_manager/merge_dictionary.h" |
| 19 #include "content/common/service_manager/service_manager_connection_impl.h" | 20 #include "content/common/service_manager/service_manager_connection_impl.h" |
| 20 #include "content/grit/content_resources.h" | 21 #include "content/grit/content_resources.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/content_browser_client.h" | 23 #include "content/public/browser/content_browser_client.h" |
| 23 #include "content/public/browser/utility_process_host.h" | 24 #include "content/public/browser/utility_process_host.h" |
| 24 #include "content/public/browser/utility_process_host_client.h" | 25 #include "content/public/browser/utility_process_host_client.h" |
| 25 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 26 #include "content/public/common/service_manager_connection.h" | 27 #include "content/public/common/service_manager_connection.h" |
| 27 #include "content/public/common/service_names.mojom.h" | 28 #include "content/public/common/service_names.mojom.h" |
| 28 #include "mojo/edk/embedder/embedder.h" | 29 #include "mojo/edk/embedder/embedder.h" |
| 29 #include "services/catalog/catalog.h" | 30 #include "services/catalog/catalog.h" |
| 30 #include "services/catalog/manifest_provider.h" | 31 #include "services/catalog/manifest_provider.h" |
| 31 #include "services/catalog/public/interfaces/constants.mojom.h" | 32 #include "services/catalog/public/interfaces/constants.mojom.h" |
| 32 #include "services/catalog/store.h" | 33 #include "services/catalog/store.h" |
| 33 #include "services/device/device_service.h" | 34 #include "services/device/device_service.h" |
| 34 #include "services/device/public/interfaces/constants.mojom.h" | 35 #include "services/device/public/interfaces/constants.mojom.h" |
| 35 #include "services/service_manager/connect_params.h" | 36 #include "services/service_manager/connect_params.h" |
| 36 #include "services/service_manager/public/cpp/connector.h" | 37 #include "services/service_manager/public/cpp/connector.h" |
| 37 #include "services/service_manager/public/cpp/service.h" | 38 #include "services/service_manager/public/cpp/service.h" |
| 38 #include "services/service_manager/public/interfaces/service.mojom.h" | 39 #include "services/service_manager/public/interfaces/service.mojom.h" |
| 39 #include "services/service_manager/runner/common/client_util.h" | 40 #include "services/service_manager/runner/common/client_util.h" |
| 40 #include "services/service_manager/service_manager.h" | 41 #include "services/service_manager/service_manager.h" |
| 42 #include "services/shape_detection/public/interfaces/constants.mojom.h" |
| 41 | 43 |
| 42 namespace content { | 44 namespace content { |
| 43 | 45 |
| 44 namespace { | 46 namespace { |
| 45 | 47 |
| 46 base::LazyInstance<std::unique_ptr<service_manager::Connector>>::Leaky | 48 base::LazyInstance<std::unique_ptr<service_manager::Connector>>::Leaky |
| 47 g_io_thread_connector = LAZY_INSTANCE_INITIALIZER; | 49 g_io_thread_connector = LAZY_INSTANCE_INITIALIZER; |
| 48 | 50 |
| 49 void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); } | 51 void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); } |
| 50 | 52 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( | 306 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( |
| 305 service.first, | 307 service.first, |
| 306 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, | 308 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, |
| 307 true /* use_sandbox */)); | 309 true /* use_sandbox */)); |
| 308 } | 310 } |
| 309 | 311 |
| 310 ContentBrowserClient::OutOfProcessServiceMap unsandboxed_services; | 312 ContentBrowserClient::OutOfProcessServiceMap unsandboxed_services; |
| 311 GetContentClient() | 313 GetContentClient() |
| 312 ->browser() | 314 ->browser() |
| 313 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services); | 315 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services); |
| 316 unsandboxed_services.insert( |
| 317 std::make_pair(shape_detection::mojom::kServiceName, |
| 318 base::ASCIIToUTF16("Shape Detection Service"))); |
| 314 for (const auto& service : unsandboxed_services) { | 319 for (const auto& service : unsandboxed_services) { |
| 315 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( | 320 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( |
| 316 service.first, | 321 service.first, |
| 317 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, | 322 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, |
| 318 false /* use_sandbox */)); | 323 false /* use_sandbox */)); |
| 319 } | 324 } |
| 320 | 325 |
| 321 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) | 326 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) |
| 322 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( | 327 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( |
| 323 "media", base::Bind(&StartServiceInGpuProcess, "media")); | 328 "media", base::Bind(&StartServiceInGpuProcess, "media")); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 346 base::Bind(&DestroyConnectorOnIOThread)); | 351 base::Bind(&DestroyConnectorOnIOThread)); |
| 347 } | 352 } |
| 348 | 353 |
| 349 // static | 354 // static |
| 350 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 355 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
| 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 352 return g_io_thread_connector.Get().get(); | 357 return g_io_thread_connector.Get().get(); |
| 353 } | 358 } |
| 354 | 359 |
| 355 } // namespace content | 360 } // namespace content |
| OLD | NEW |