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 "ppapi/features/features.h" | 17 #include "media/mojo/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_PEPPER_CDMS) | 25 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
26 #include "base/memory/ptr_util.h" | 26 #include "media/mojo/services/media_service_factory.h" // nogncheck |
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 | |
32 #endif | 27 #endif |
33 | 28 |
34 namespace { | 29 namespace { |
35 | 30 |
36 std::unique_ptr<service_manager::Service> CreateVideoCaptureService() { | 31 std::unique_ptr<service_manager::Service> CreateVideoCaptureService() { |
37 return base::MakeUnique<video_capture::ServiceImpl>(); | 32 return base::MakeUnique<video_capture::ServiceImpl>(); |
38 } | 33 } |
39 | 34 |
40 } // anonymous namespace | 35 } // anonymous namespace |
41 | 36 |
42 namespace content { | 37 namespace content { |
43 | 38 |
44 namespace { | 39 namespace { |
45 | 40 |
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 | |
73 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { | 41 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { |
74 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 42 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
75 return data_decoder::DataDecoderService::Create(); | 43 return data_decoder::DataDecoderService::Create(); |
76 } | 44 } |
77 | 45 |
78 } // namespace | 46 } // namespace |
79 | 47 |
80 UtilityServiceFactory::UtilityServiceFactory() | 48 UtilityServiceFactory::UtilityServiceFactory() |
81 : network_registry_(base::MakeUnique<service_manager::BinderRegistry>()) {} | 49 : network_registry_(base::MakeUnique<service_manager::BinderRegistry>()) {} |
82 | 50 |
83 UtilityServiceFactory::~UtilityServiceFactory() {} | 51 UtilityServiceFactory::~UtilityServiceFactory() {} |
84 | 52 |
85 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { | 53 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { |
86 GetContentClient()->utility()->RegisterServices(services); | 54 GetContentClient()->utility()->RegisterServices(services); |
87 | 55 |
88 ServiceInfo video_capture_info; | 56 ServiceInfo video_capture_info; |
89 video_capture_info.factory = base::Bind(&CreateVideoCaptureService); | 57 video_capture_info.factory = base::Bind(&CreateVideoCaptureService); |
90 services->insert( | 58 services->insert( |
91 std::make_pair(video_capture::mojom::kServiceName, video_capture_info)); | 59 std::make_pair(video_capture::mojom::kServiceName, video_capture_info)); |
92 | 60 |
93 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 61 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
94 ServiceInfo info; | 62 ServiceInfo info; |
95 info.factory = base::Bind(&CreateMediaService); | 63 info.factory = base::Bind(&media::CreateMediaService); |
96 services->insert(std::make_pair("media", info)); | 64 services->insert(std::make_pair("media", info)); |
97 #endif | 65 #endif |
98 | 66 |
99 ServiceInfo shape_detection_info; | 67 ServiceInfo shape_detection_info; |
100 shape_detection_info.factory = | 68 shape_detection_info.factory = |
101 base::Bind(&shape_detection::ShapeDetectionService::Create); | 69 base::Bind(&shape_detection::ShapeDetectionService::Create); |
102 services->insert(std::make_pair(shape_detection::mojom::kServiceName, | 70 services->insert(std::make_pair(shape_detection::mojom::kServiceName, |
103 shape_detection_info)); | 71 shape_detection_info)); |
104 | 72 |
105 ServiceInfo data_decoder_info; | 73 ServiceInfo data_decoder_info; |
(...skipping 24 matching lines...) Expand all Loading... |
130 utility_thread->Shutdown(); | 98 utility_thread->Shutdown(); |
131 utility_thread->ReleaseProcessIfNeeded(); | 99 utility_thread->ReleaseProcessIfNeeded(); |
132 } | 100 } |
133 | 101 |
134 std::unique_ptr<service_manager::Service> | 102 std::unique_ptr<service_manager::Service> |
135 UtilityServiceFactory::CreateNetworkService() { | 103 UtilityServiceFactory::CreateNetworkService() { |
136 return base::MakeUnique<NetworkService>(std::move(network_registry_)); | 104 return base::MakeUnique<NetworkService>(std::move(network_registry_)); |
137 } | 105 } |
138 | 106 |
139 } // namespace content | 107 } // namespace content |
OLD | NEW |