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