| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_thread_impl.h" | 5 #include "content/utility/utility_thread_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "content/child/blink_platform_impl.h" | 12 #include "content/child/blink_platform_impl.h" |
| 13 #include "content/child/child_process.h" | 13 #include "content/child/child_process.h" |
| 14 #include "content/common/child_process_messages.h" | 14 #include "content/common/child_process_messages.h" |
| 15 #include "content/common/utility_messages.h" | 15 #include "content/common/utility_messages.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "content/public/common/service_manager_connection.h" |
| 18 #include "content/public/common/simple_connection_filter.h" |
| 17 #include "content/public/utility/content_utility_client.h" | 19 #include "content/public/utility/content_utility_client.h" |
| 18 #include "content/utility/utility_blink_platform_impl.h" | 20 #include "content/utility/utility_blink_platform_impl.h" |
| 19 #include "content/utility/utility_service_factory.h" | 21 #include "content/utility/utility_service_factory.h" |
| 20 #include "ipc/ipc_sync_channel.h" | 22 #include "ipc/ipc_sync_channel.h" |
| 21 #include "ppapi/features/features.h" | 23 #include "ppapi/features/features.h" |
| 22 #include "services/service_manager/public/cpp/interface_registry.h" | 24 #include "services/service_manager/public/cpp/binder_registry.h" |
| 23 #include "third_party/WebKit/public/web/WebKit.h" | 25 #include "third_party/WebKit/public/web/WebKit.h" |
| 24 | 26 |
| 25 #if defined(OS_POSIX) && BUILDFLAG(ENABLE_PLUGINS) | 27 #if defined(OS_POSIX) && BUILDFLAG(ENABLE_PLUGINS) |
| 26 #include "base/files/file_path.h" | 28 #include "base/files/file_path.h" |
| 27 #include "content/common/plugin_list.h" | 29 #include "content/common/plugin_list.h" |
| 28 #endif | 30 #endif |
| 29 | 31 |
| 30 namespace content { | 32 namespace content { |
| 31 | 33 |
| 32 UtilityThreadImpl::UtilityThreadImpl() | 34 UtilityThreadImpl::UtilityThreadImpl() |
| 33 : ChildThreadImpl(ChildThreadImpl::Options::Builder().Build()) { | 35 : ChildThreadImpl(ChildThreadImpl::Options::Builder() |
| 36 .AutoStartServiceManagerConnection(false) |
| 37 .Build()) { |
| 34 Init(); | 38 Init(); |
| 35 } | 39 } |
| 36 | 40 |
| 37 UtilityThreadImpl::UtilityThreadImpl(const InProcessChildThreadParams& params) | 41 UtilityThreadImpl::UtilityThreadImpl(const InProcessChildThreadParams& params) |
| 38 : ChildThreadImpl(ChildThreadImpl::Options::Builder() | 42 : ChildThreadImpl(ChildThreadImpl::Options::Builder() |
| 43 .AutoStartServiceManagerConnection(false) |
| 39 .InBrowserProcess(params) | 44 .InBrowserProcess(params) |
| 40 .Build()) { | 45 .Build()) { |
| 41 Init(); | 46 Init(); |
| 42 } | 47 } |
| 43 | 48 |
| 44 UtilityThreadImpl::~UtilityThreadImpl() { | 49 UtilityThreadImpl::~UtilityThreadImpl() { |
| 45 } | 50 } |
| 46 | 51 |
| 47 void UtilityThreadImpl::Shutdown() { | 52 void UtilityThreadImpl::Shutdown() { |
| 48 ChildThreadImpl::Shutdown(); | 53 ChildThreadImpl::Shutdown(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 72 return; | 77 return; |
| 73 } | 78 } |
| 74 | 79 |
| 75 blink_platform_impl_.reset(new UtilityBlinkPlatformImpl); | 80 blink_platform_impl_.reset(new UtilityBlinkPlatformImpl); |
| 76 blink::Platform::Initialize(blink_platform_impl_.get()); | 81 blink::Platform::Initialize(blink_platform_impl_.get()); |
| 77 } | 82 } |
| 78 | 83 |
| 79 void UtilityThreadImpl::Init() { | 84 void UtilityThreadImpl::Init() { |
| 80 batch_mode_ = false; | 85 batch_mode_ = false; |
| 81 ChildProcess::current()->AddRefProcess(); | 86 ChildProcess::current()->AddRefProcess(); |
| 87 |
| 88 auto registry = base::MakeUnique<service_manager::BinderRegistry>(); |
| 89 registry->AddInterface( |
| 90 base::Bind(&UtilityThreadImpl::BindServiceFactoryRequest, |
| 91 base::Unretained(this)), |
| 92 base::ThreadTaskRunnerHandle::Get()); |
| 93 ChildThread::Get()->GetServiceManagerConnection()->AddConnectionFilter( |
| 94 base::MakeUnique<SimpleConnectionFilter>(std::move(registry))); |
| 95 |
| 82 GetContentClient()->utility()->UtilityThreadStarted(); | 96 GetContentClient()->utility()->UtilityThreadStarted(); |
| 83 | 97 |
| 84 service_factory_.reset(new UtilityServiceFactory); | 98 service_factory_.reset(new UtilityServiceFactory); |
| 85 GetInterfaceRegistry()->AddInterface(base::Bind( | |
| 86 &UtilityThreadImpl::BindServiceFactoryRequest, base::Unretained(this))); | |
| 87 | 99 |
| 88 GetContentClient()->utility()->ExposeInterfacesToBrowser( | 100 StartServiceManagerConnection(); |
| 89 GetInterfaceRegistry()); | |
| 90 } | 101 } |
| 91 | 102 |
| 92 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 103 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 93 if (GetContentClient()->utility()->OnMessageReceived(msg)) | 104 if (GetContentClient()->utility()->OnMessageReceived(msg)) |
| 94 return true; | 105 return true; |
| 95 | 106 |
| 96 bool handled = true; | 107 bool handled = true; |
| 97 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) | 108 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) |
| 98 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 109 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
| 99 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 110 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 112 } | 123 } |
| 113 | 124 |
| 114 void UtilityThreadImpl::BindServiceFactoryRequest( | 125 void UtilityThreadImpl::BindServiceFactoryRequest( |
| 115 service_manager::mojom::ServiceFactoryRequest request) { | 126 service_manager::mojom::ServiceFactoryRequest request) { |
| 116 DCHECK(service_factory_); | 127 DCHECK(service_factory_); |
| 117 service_factory_bindings_.AddBinding(service_factory_.get(), | 128 service_factory_bindings_.AddBinding(service_factory_.get(), |
| 118 std::move(request)); | 129 std::move(request)); |
| 119 } | 130 } |
| 120 | 131 |
| 121 } // namespace content | 132 } // namespace content |
| OLD | NEW |