Chromium Code Reviews| 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 <memory> | |
| 8 #include <utility> | |
| 9 | |
| 7 #include "base/bind.h" | 10 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 9 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
| 10 #include "content/network/network_service.h" | 13 #include "content/network/network_service.h" |
| 11 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
| 12 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/common/service_names.mojom.h" | 16 #include "content/public/common/service_names.mojom.h" |
| 14 #include "content/public/utility/content_utility_client.h" | 17 #include "content/public/utility/content_utility_client.h" |
| 15 #include "content/public/utility/utility_thread.h" | 18 #include "content/public/utility/utility_thread.h" |
| 16 #include "content/utility/utility_thread_impl.h" | 19 #include "content/utility/utility_thread_impl.h" |
| 20 #include "printing/features/features.h" | |
| 17 #include "services/data_decoder/data_decoder_service.h" | 21 #include "services/data_decoder/data_decoder_service.h" |
| 18 #include "services/data_decoder/public/interfaces/constants.mojom.h" | 22 #include "services/data_decoder/public/interfaces/constants.mojom.h" |
| 19 #include "services/shape_detection/public/interfaces/constants.mojom.h" | 23 #include "services/shape_detection/public/interfaces/constants.mojom.h" |
| 20 #include "services/shape_detection/shape_detection_service.h" | 24 #include "services/shape_detection/shape_detection_service.h" |
| 21 | 25 |
| 22 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 26 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
| 23 #include "media/mojo/services/media_service_factory.h" // nogncheck | 27 #include "media/mojo/services/media_service_factory.h" // nogncheck |
| 24 #endif | 28 #endif |
| 25 | 29 |
| 30 #if BUILDFLAG(ENABLE_PRINTING) | |
| 31 // nogncheck because dependency on //printing is conditional upon | |
|
jam
2017/04/24 15:18:05
content/ currently doesn't know about components/p
Wei Li
2017/04/27 05:34:16
Done.
| |
| 32 // enable_basic_printing or enable_print_preview flags. | |
| 33 #include "components/printing/service/pdf_compositor_service.h" // nogncheck | |
| 34 #include "components/printing/service/public/interfaces/pdf_compositor.mojom.h" // nogncheck | |
| 35 #endif | |
| 36 | |
| 26 namespace content { | 37 namespace content { |
| 27 | 38 |
| 28 namespace { | 39 namespace { |
| 29 | 40 |
| 30 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { | 41 std::unique_ptr<service_manager::Service> CreateDataDecoderService() { |
| 31 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 42 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 32 return data_decoder::DataDecoderService::Create(); | 43 return data_decoder::DataDecoderService::Create(); |
| 33 } | 44 } |
| 34 | 45 |
| 46 #if BUILDFLAG(ENABLE_PRINTING) | |
| 47 std::unique_ptr<service_manager::Service> CreatePdfCompositorService() { | |
| 48 content::UtilityThread::Get()->EnsureBlinkInitialized(); | |
| 49 content::UtilityThread::Get()->EnsureReadyForSkia(); | |
| 50 return printing::PdfCompositorService::Create( | |
| 51 GetContentClient()->GetUserAgent(), | |
| 52 ChildProcess::current()->io_task_runner()); | |
| 53 } | |
| 54 #endif | |
| 55 | |
| 35 } // namespace | 56 } // namespace |
| 36 | 57 |
| 37 UtilityServiceFactory::UtilityServiceFactory() {} | 58 UtilityServiceFactory::UtilityServiceFactory() {} |
| 38 | 59 |
| 39 UtilityServiceFactory::~UtilityServiceFactory() {} | 60 UtilityServiceFactory::~UtilityServiceFactory() {} |
| 40 | 61 |
| 41 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { | 62 void UtilityServiceFactory::RegisterServices(ServiceMap* services) { |
| 42 GetContentClient()->utility()->RegisterServices(services); | 63 GetContentClient()->utility()->RegisterServices(services); |
| 43 | 64 |
| 44 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) | 65 #if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 58 std::make_pair(data_decoder::mojom::kServiceName, data_decoder_info)); | 79 std::make_pair(data_decoder::mojom::kServiceName, data_decoder_info)); |
| 59 | 80 |
| 60 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 81 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 61 switches::kEnableNetworkService)) { | 82 switches::kEnableNetworkService)) { |
| 62 ServiceInfo network_info; | 83 ServiceInfo network_info; |
| 63 network_info.factory = base::Bind(&NetworkService::CreateNetworkService); | 84 network_info.factory = base::Bind(&NetworkService::CreateNetworkService); |
| 64 network_info.task_runner = ChildProcess::current()->io_task_runner(); | 85 network_info.task_runner = ChildProcess::current()->io_task_runner(); |
| 65 services->insert( | 86 services->insert( |
| 66 std::make_pair(content::mojom::kNetworkServiceName, network_info)); | 87 std::make_pair(content::mojom::kNetworkServiceName, network_info)); |
| 67 } | 88 } |
| 89 | |
| 90 #if BUILDFLAG(ENABLE_PRINTING) | |
| 91 ServiceInfo pdf_compositor_info; | |
| 92 pdf_compositor_info.factory = base::Bind(&CreatePdfCompositorService); | |
| 93 services->insert( | |
| 94 std::make_pair(printing::mojom::kServiceName, pdf_compositor_info)); | |
| 95 #endif | |
| 68 } | 96 } |
| 69 | 97 |
| 70 void UtilityServiceFactory::OnServiceQuit() { | 98 void UtilityServiceFactory::OnServiceQuit() { |
| 71 UtilityThread::Get()->ReleaseProcessIfNeeded(); | 99 UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| 72 } | 100 } |
| 73 | 101 |
| 74 void UtilityServiceFactory::OnLoadFailed() { | 102 void UtilityServiceFactory::OnLoadFailed() { |
| 75 UtilityThreadImpl* utility_thread = | 103 UtilityThreadImpl* utility_thread = |
| 76 static_cast<UtilityThreadImpl*>(UtilityThread::Get()); | 104 static_cast<UtilityThreadImpl*>(UtilityThread::Get()); |
| 77 utility_thread->Shutdown(); | 105 utility_thread->Shutdown(); |
| 78 utility_thread->ReleaseProcessIfNeeded(); | 106 utility_thread->ReleaseProcessIfNeeded(); |
| 79 } | 107 } |
| 80 | 108 |
| 81 } // namespace content | 109 } // namespace content |
| OLD | NEW |