| 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/utility/utility_service_factory.h" | 5 #include "content/utility/utility_service_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "content/child/child_process.h" | 9 #include "content/child/child_process.h" |
| 10 #include "content/network/network_service.h" | 10 #include "content/network/network_service.h" |
| 11 #include "content/public/common/content_client.h" | 11 #include "content/public/common/content_client.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/common/service_names.mojom.h" | 13 #include "content/public/common/service_names.mojom.h" |
| 14 #include "content/public/utility/content_utility_client.h" | 14 #include "content/public/utility/content_utility_client.h" |
| 15 #include "content/public/utility/utility_thread.h" | 15 #include "content/public/utility/utility_thread.h" |
| 16 #include "content/utility/utility_thread_impl.h" | 16 #include "content/utility/utility_thread_impl.h" |
| 17 #include "media/mojo/features.h" | 17 #include "ppapi/features/features.h" |
| 18 #include "services/data_decoder/data_decoder_service.h" | 18 #include "services/data_decoder/data_decoder_service.h" |
| 19 #include "services/data_decoder/public/interfaces/constants.mojom.h" | 19 #include "services/data_decoder/public/interfaces/constants.mojom.h" |
| 20 #include "services/shape_detection/public/interfaces/constants.mojom.h" | 20 #include "services/shape_detection/public/interfaces/constants.mojom.h" |
| 21 #include "services/shape_detection/shape_detection_service.h" | 21 #include "services/shape_detection/shape_detection_service.h" |
| 22 #include "services/video_capture/public/interfaces/constants.mojom.h" | 22 #include "services/video_capture/public/interfaces/constants.mojom.h" |
| 23 #include "services/video_capture/service_impl.h" | 23 #include "services/video_capture/service_impl.h" |
| 24 | 24 |
| 25 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 25 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 26 #include "media/mojo/services/media_service_factory.h" // nogncheck | 26 #include "base/memory/ptr_util.h" |
| 27 #include "media/cdm/cdm_adapter_factory.h" // nogncheck |
| 28 #include "media/mojo/features.h" // nogncheck |
| 29 #include "media/mojo/services/media_service.h" // nogncheck |
| 30 #include "media/mojo/services/mojo_cdm_allocator.h" // nogncheck |
| 31 #include "media/mojo/services/mojo_media_client.h" // nogncheck |
| 27 #endif | 32 #endif |
| 28 | 33 |
| 29 namespace { | 34 namespace { |
| 30 | 35 |
| 31 std::unique_ptr<service_manager::Service> CreateVideoCaptureService() { | 36 std::unique_ptr<service_manager::Service> CreateVideoCaptureService() { |
| 32 return base::MakeUnique<video_capture::ServiceImpl>(); | 37 return base::MakeUnique<video_capture::ServiceImpl>(); |
| 33 } | 38 } |
| 34 | 39 |
| 35 } // anonymous namespace | 40 } // anonymous namespace |
| 36 | 41 |
| 37 namespace content { | 42 namespace content { |
| 38 | 43 |
| 39 namespace { | 44 namespace { |
| 40 | 45 |
| 46 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 47 |
| 48 static_assert(BUILDFLAG(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS), ""); |
| 49 static_assert(BUILDFLAG(ENABLE_MOJO_CDM), ""); |
| 50 |
| 51 std::unique_ptr<media::CdmAllocator> CreateCdmAllocator() { |
| 52 return base::MakeUnique<media::MojoCdmAllocator>(); |
| 53 } |
| 54 |
| 55 class CdmMojoMediaClient final : public media::MojoMediaClient { |
| 56 public: |
| 57 CdmMojoMediaClient() {} |
| 58 ~CdmMojoMediaClient() override {} |
| 59 |
| 60 std::unique_ptr<media::CdmFactory> CreateCdmFactory( |
| 61 service_manager::mojom::InterfaceProvider* host_interfaces) override { |
| 62 return base::MakeUnique<media::CdmAdapterFactory>( |
| 63 base::Bind(&CreateCdmAllocator)); |
| 64 } |
| 65 }; |
| 66 |
| 67 std::unique_ptr<service_manager::Service> CreateMediaService() { |
| 68 return std::unique_ptr<service_manager::Service>( |
| 69 new ::media::MediaService(base::MakeUnique<CdmMojoMediaClient>())); |
| 70 } |
| 71 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 72 |
| 41 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { | 73 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { |
| 42 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 74 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 43 return data_decoder::DataDecoderService::Create(); | 75 return data_decoder::DataDecoderService::Create(); |
| 44 } | 76 } |
| 45 | 77 |
| 46 } // namespace | 78 } // namespace |
| 47 | 79 |
| 48 UtilityServiceFactory::UtilityServiceFactory() | 80 UtilityServiceFactory::UtilityServiceFactory() |
| 49 : network_registry_(base::MakeUnique<service_manager::BinderRegistry>()) {} | 81 : network_registry_(base::MakeUnique<service_manager::BinderRegistry>()) {} |
| 50 | 82 |
| 51 UtilityServiceFactory::~UtilityServiceFactory() {} | 83 UtilityServiceFactory::~UtilityServiceFactory() {} |
| 52 | 84 |
| 53 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { | 85 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { |
| 54 GetContentClient()->utility()->RegisterServices(services); | 86 GetContentClient()->utility()->RegisterServices(services); |
| 55 | 87 |
| 56 ServiceInfo video_capture_info; | 88 ServiceInfo video_capture_info; |
| 57 video_capture_info.factory = base::Bind(&CreateVideoCaptureService); | 89 video_capture_info.factory = base::Bind(&CreateVideoCaptureService); |
| 58 services->insert( | 90 services->insert( |
| 59 std::make_pair(video_capture::mojom::kServiceName, video_capture_info)); | 91 std::make_pair(video_capture::mojom::kServiceName, video_capture_info)); |
| 60 | 92 |
| 61 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 93 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 62 ServiceInfo info; | 94 ServiceInfo info; |
| 63 info.factory = base::Bind(&media::CreateMediaService); | 95 info.factory = base::Bind(&CreateMediaService); |
| 64 services->insert(std::make_pair("media", info)); | 96 services->insert(std::make_pair("media", info)); |
| 65 #endif | 97 #endif |
| 66 | 98 |
| 67 ServiceInfo shape_detection_info; | 99 ServiceInfo shape_detection_info; |
| 68 shape_detection_info.factory = | 100 shape_detection_info.factory = |
| 69 base::Bind(&shape_detection::ShapeDetectionService::Create); | 101 base::Bind(&shape_detection::ShapeDetectionService::Create); |
| 70 services->insert(std::make_pair(shape_detection::mojom::kServiceName, | 102 services->insert(std::make_pair(shape_detection::mojom::kServiceName, |
| 71 shape_detection_info)); | 103 shape_detection_info)); |
| 72 | 104 |
| 73 ServiceInfo data_decoder_info; | 105 ServiceInfo data_decoder_info; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 98 utility_thread->Shutdown(); | 130 utility_thread->Shutdown(); |
| 99 utility_thread->ReleaseProcessIfNeeded(); | 131 utility_thread->ReleaseProcessIfNeeded(); |
| 100 } | 132 } |
| 101 | 133 |
| 102 std::unique_ptr<service_manager::Service> | 134 std::unique_ptr<service_manager::Service> |
| 103 UtilityServiceFactory::CreateNetworkService() { | 135 UtilityServiceFactory::CreateNetworkService() { |
| 104 return base::MakeUnique<NetworkService>(std::move(network_registry_)); | 136 return base::MakeUnique<NetworkService>(std::move(network_registry_)); |
| 105 } | 137 } |
| 106 | 138 |
| 107 } // namespace content | 139 } // namespace content |
| OLD | NEW |