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 "content/public/common/content_client.h" | 8 #include "content/public/common/content_client.h" |
9 #include "content/public/utility/content_utility_client.h" | 9 #include "content/public/utility/content_utility_client.h" |
10 #include "content/public/utility/utility_thread.h" | 10 #include "content/public/utility/utility_thread.h" |
11 #include "content/utility/utility_thread_impl.h" | 11 #include "content/utility/utility_thread_impl.h" |
| 12 #include "services/data_decoder/data_decoder_service.h" |
| 13 #include "services/data_decoder/public/interfaces/constants.mojom.h" |
12 #include "services/shape_detection/public/interfaces/constants.mojom.h" | 14 #include "services/shape_detection/public/interfaces/constants.mojom.h" |
13 #include "services/shape_detection/shape_detection_service.h" | 15 #include "services/shape_detection/shape_detection_service.h" |
14 | 16 |
15 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 17 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
16 #include "media/mojo/services/media_service_factory.h" // nogncheck | 18 #include "media/mojo/services/media_service_factory.h" // nogncheck |
17 #endif | 19 #endif |
18 | 20 |
19 namespace content { | 21 namespace content { |
20 | 22 |
| 23 namespace { |
| 24 |
| 25 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { |
| 26 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 27 return data_decoder::DataDecoderService::Create(); |
| 28 } |
| 29 |
| 30 } // namespace |
| 31 |
21 UtilityServiceFactory::UtilityServiceFactory() {} | 32 UtilityServiceFactory::UtilityServiceFactory() {} |
22 | 33 |
23 UtilityServiceFactory::~UtilityServiceFactory() {} | 34 UtilityServiceFactory::~UtilityServiceFactory() {} |
24 | 35 |
25 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { | 36 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { |
26 GetContentClient()->utility()->RegisterServices(services); | 37 GetContentClient()->utility()->RegisterServices(services); |
27 | 38 |
28 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 39 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
29 ServiceInfo info; | 40 ServiceInfo info; |
30 info.factory = base::Bind(&media::CreateMediaService); | 41 info.factory = base::Bind(&media::CreateMediaService); |
31 services->insert(std::make_pair("media", info)); | 42 services->insert(std::make_pair("media", info)); |
32 #endif | 43 #endif |
33 ServiceInfo shape_detection_info; | 44 ServiceInfo shape_detection_info; |
34 shape_detection_info.factory = | 45 shape_detection_info.factory = |
35 base::Bind(&shape_detection::ShapeDetectionService::Create); | 46 base::Bind(&shape_detection::ShapeDetectionService::Create); |
36 services->insert(std::make_pair(shape_detection::mojom::kServiceName, | 47 services->insert(std::make_pair(shape_detection::mojom::kServiceName, |
37 shape_detection_info)); | 48 shape_detection_info)); |
| 49 |
| 50 ServiceInfo data_decoder_info; |
| 51 data_decoder_info.factory = base::Bind(&CreateDataDecoderService); |
| 52 services->insert( |
| 53 std::make_pair(data_decoder::mojom::kServiceName, data_decoder_info)); |
38 } | 54 } |
39 | 55 |
40 void UtilityServiceFactory::OnServiceQuit() { | 56 void UtilityServiceFactory::OnServiceQuit() { |
41 UtilityThread::Get()->ReleaseProcessIfNeeded(); | 57 UtilityThread::Get()->ReleaseProcessIfNeeded(); |
42 } | 58 } |
43 | 59 |
44 void UtilityServiceFactory::OnLoadFailed() { | 60 void UtilityServiceFactory::OnLoadFailed() { |
45 UtilityThreadImpl* utility_thread = | 61 UtilityThreadImpl* utility_thread = |
46 static_cast<UtilityThreadImpl*>(UtilityThread::Get()); | 62 static_cast<UtilityThreadImpl*>(UtilityThread::Get()); |
47 utility_thread->Shutdown(); | 63 utility_thread->Shutdown(); |
48 utility_thread->ReleaseProcessIfNeeded(); | 64 utility_thread->ReleaseProcessIfNeeded(); |
49 } | 65 } |
50 | 66 |
51 } // namespace content | 67 } // namespace content |
OLD | NEW |