Chromium Code Reviews| 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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/child/child_process.h" | 13 #include "content/child/child_process.h" |
| 14 #include "content/common/field_trial_recorder.mojom.h" | 14 #include "content/common/field_trial_recorder.mojom.h" |
| 15 #include "content/gpu/gpu_service_factory.h" | 15 #include "content/gpu/gpu_service_factory.h" |
| 16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/service_manager_connection.h" | 18 #include "content/public/common/service_manager_connection.h" |
| 19 #include "content/public/common/service_names.mojom.h" | 19 #include "content/public/common/service_names.mojom.h" |
| 20 #include "content/public/common/simple_connection_filter.h" | |
| 20 #include "content/public/gpu/content_gpu_client.h" | 21 #include "content/public/gpu/content_gpu_client.h" |
| 21 #include "gpu/command_buffer/common/activity_flags.h" | 22 #include "gpu/command_buffer/common/activity_flags.h" |
| 22 #include "gpu/ipc/service/gpu_watchdog_thread.h" | 23 #include "gpu/ipc/service/gpu_watchdog_thread.h" |
| 23 #include "ipc/ipc_sync_message_filter.h" | 24 #include "ipc/ipc_sync_message_filter.h" |
| 24 #include "media/gpu/ipc/service/media_gpu_channel_manager.h" | 25 #include "media/gpu/ipc/service/media_gpu_channel_manager.h" |
| 26 #include "services/service_manager/public/cpp/binder_registry.h" | |
| 25 #include "services/service_manager/public/cpp/connector.h" | 27 #include "services/service_manager/public/cpp/connector.h" |
| 26 #include "services/service_manager/public/cpp/interface_registry.h" | |
| 27 #include "services/ui/gpu/interfaces/gpu_service.mojom.h" | 28 #include "services/ui/gpu/interfaces/gpu_service.mojom.h" |
| 28 | 29 |
| 29 #if defined(USE_OZONE) | 30 #if defined(USE_OZONE) |
| 30 #include "ui/ozone/public/ozone_platform.h" | 31 #include "ui/ozone/public/ozone_platform.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
| 34 #include "media/base/android/media_drm_bridge_client.h" | 35 #include "media/base/android/media_drm_bridge_client.h" |
| 35 #endif | 36 #endif |
| 36 | 37 |
| 37 namespace content { | 38 namespace content { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 ChildThreadImpl::Options GetOptions() { | 41 ChildThreadImpl::Options GetOptions() { |
| 41 ChildThreadImpl::Options::Builder builder; | 42 ChildThreadImpl::Options::Builder builder; |
| 42 | 43 |
| 43 #if defined(USE_OZONE) | 44 #if defined(USE_OZONE) |
| 44 IPC::MessageFilter* message_filter = | 45 IPC::MessageFilter* message_filter = |
| 45 ui::OzonePlatform::GetInstance()->GetGpuMessageFilter(); | 46 ui::OzonePlatform::GetInstance()->GetGpuMessageFilter(); |
| 46 if (message_filter) | 47 if (message_filter) |
| 47 builder.AddStartupFilter(message_filter); | 48 builder.AddStartupFilter(message_filter); |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 51 builder.AutoStartServiceManagerConnection(false); | |
| 50 builder.ConnectToBrowser(true); | 52 builder.ConnectToBrowser(true); |
| 51 | 53 |
| 52 return builder.Build(); | 54 return builder.Build(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 } // namespace | 57 } // namespace |
| 56 | 58 |
| 57 GpuChildThread::GpuChildThread( | 59 GpuChildThread::GpuChildThread( |
| 58 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, | 60 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, |
| 59 bool dead_on_arrival, | 61 bool dead_on_arrival, |
| 60 const gpu::GPUInfo& gpu_info, | 62 const gpu::GPUInfo& gpu_info, |
| 61 const gpu::GpuFeatureInfo& gpu_feature_info, | 63 const gpu::GpuFeatureInfo& gpu_feature_info, |
| 62 DeferredMessages deferred_messages) | 64 DeferredMessages deferred_messages) |
| 63 : GpuChildThread(GetOptions(), | 65 : GpuChildThread(GetOptions(), |
| 64 std::move(watchdog_thread), | 66 std::move(watchdog_thread), |
| 65 dead_on_arrival, | 67 dead_on_arrival, |
| 66 false /* in_browser_process */, | 68 false /* in_browser_process */, |
| 67 gpu_info, | 69 gpu_info, |
| 68 gpu_feature_info) { | 70 gpu_feature_info) { |
| 69 deferred_messages_ = std::move(deferred_messages); | 71 deferred_messages_ = std::move(deferred_messages); |
| 70 } | 72 } |
| 71 | 73 |
| 72 GpuChildThread::GpuChildThread(const InProcessChildThreadParams& params, | 74 GpuChildThread::GpuChildThread(const InProcessChildThreadParams& params, |
| 73 const gpu::GPUInfo& gpu_info, | 75 const gpu::GPUInfo& gpu_info, |
| 74 const gpu::GpuFeatureInfo& gpu_feature_info) | 76 const gpu::GpuFeatureInfo& gpu_feature_info) |
| 75 : GpuChildThread(ChildThreadImpl::Options::Builder() | 77 : GpuChildThread(ChildThreadImpl::Options::Builder() |
| 76 .InBrowserProcess(params) | 78 .InBrowserProcess(params) |
|
Ken Rockot(use gerrit already)
2017/04/19 01:26:30
Need to turn off autostart for this constructor as
| |
| 77 .ConnectToBrowser(true) | 79 .ConnectToBrowser(true) |
| 78 .Build(), | 80 .Build(), |
| 79 nullptr /* watchdog_thread */, | 81 nullptr /* watchdog_thread */, |
| 80 false /* dead_on_arrival */, | 82 false /* dead_on_arrival */, |
| 81 true /* in_browser_process */, | 83 true /* in_browser_process */, |
| 82 gpu_info, | 84 gpu_info, |
| 83 gpu_feature_info) {} | 85 gpu_feature_info) {} |
| 84 | 86 |
| 85 GpuChildThread::GpuChildThread( | 87 GpuChildThread::GpuChildThread( |
| 86 const ChildThreadImpl::Options& options, | 88 const ChildThreadImpl::Options& options, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 112 void GpuChildThread::Init(const base::Time& process_start_time) { | 114 void GpuChildThread::Init(const base::Time& process_start_time) { |
| 113 gpu_service_->set_start_time(process_start_time); | 115 gpu_service_->set_start_time(process_start_time); |
| 114 | 116 |
| 115 #if defined(OS_ANDROID) | 117 #if defined(OS_ANDROID) |
| 116 // When running in in-process mode, this has been set in the browser at | 118 // When running in in-process mode, this has been set in the browser at |
| 117 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). | 119 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). |
| 118 if (!in_browser_process_) | 120 if (!in_browser_process_) |
| 119 media::SetMediaDrmBridgeClient( | 121 media::SetMediaDrmBridgeClient( |
| 120 GetContentClient()->GetMediaDrmBridgeClient()); | 122 GetContentClient()->GetMediaDrmBridgeClient()); |
| 121 #endif | 123 #endif |
| 122 // We don't want to process any incoming interface requests until | |
| 123 // OnInitialize() is invoked. | |
| 124 GetInterfaceRegistry()->PauseBinding(); | |
| 125 | |
| 126 if (GetContentClient()->gpu()) // NULL in tests. | 124 if (GetContentClient()->gpu()) // NULL in tests. |
| 127 GetContentClient()->gpu()->Initialize(this); | 125 GetContentClient()->gpu()->Initialize(this); |
| 128 AssociatedInterfaceRegistry* registry = &associated_interfaces_; | 126 AssociatedInterfaceRegistry* registry = &associated_interfaces_; |
| 129 registry->AddInterface(base::Bind( | 127 registry->AddInterface(base::Bind( |
| 130 &GpuChildThread::CreateGpuMainService, base::Unretained(this))); | 128 &GpuChildThread::CreateGpuMainService, base::Unretained(this))); |
| 131 } | 129 } |
| 132 | 130 |
| 133 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, | 131 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 134 const std::string& group_name) { | 132 const std::string& group_name) { |
| 135 mojom::FieldTrialRecorderPtr field_trial_recorder; | 133 mojom::FieldTrialRecorderPtr field_trial_recorder; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 gpu_service_->InitializeWithHost( | 187 gpu_service_->InitializeWithHost( |
| 190 std::move(gpu_host), | 188 std::move(gpu_host), |
| 191 gpu::GpuProcessActivityFlags(std::move(activity_flags)), | 189 gpu::GpuProcessActivityFlags(std::move(activity_flags)), |
| 192 sync_point_manager, ChildProcess::current()->GetShutDownEvent()); | 190 sync_point_manager, ChildProcess::current()->GetShutDownEvent()); |
| 193 CHECK(gpu_service_->media_gpu_channel_manager()); | 191 CHECK(gpu_service_->media_gpu_channel_manager()); |
| 194 | 192 |
| 195 // Only set once per process instance. | 193 // Only set once per process instance. |
| 196 service_factory_.reset(new GpuServiceFactory( | 194 service_factory_.reset(new GpuServiceFactory( |
| 197 gpu_service_->media_gpu_channel_manager()->AsWeakPtr())); | 195 gpu_service_->media_gpu_channel_manager()->AsWeakPtr())); |
| 198 | 196 |
| 199 GetInterfaceRegistry()->AddInterface(base::Bind( | 197 auto registry = base::MakeUnique<service_manager::BinderRegistry>(); |
| 200 &GpuChildThread::BindServiceFactoryRequest, base::Unretained(this))); | 198 registry->AddInterface(base::Bind(&GpuChildThread::BindServiceFactoryRequest, |
| 199 base::Unretained(this)), | |
| 200 base::ThreadTaskRunnerHandle::Get()); | |
| 201 GetServiceManagerConnection()->AddConnectionFilter( | |
| 202 base::MakeUnique<SimpleConnectionFilter>(std::move(registry))); | |
| 201 | 203 |
| 202 if (GetContentClient()->gpu()) { // NULL in tests. | 204 if (GetContentClient()->gpu()) // NULL in tests. |
| 203 GetContentClient()->gpu()->ExposeInterfacesToBrowser(GetInterfaceRegistry(), | 205 GetContentClient()->gpu()->GpuServiceInitialized(gpu_preferences); |
| 204 gpu_preferences); | |
| 205 GetContentClient()->gpu()->ConsumeInterfacesFromBrowser(GetConnector()); | |
| 206 } | |
| 207 | 206 |
| 208 GetInterfaceRegistry()->ResumeBinding(); | 207 StartServiceManagerConnection(); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void GpuChildThread::CreateFrameSinkManager( | 210 void GpuChildThread::CreateFrameSinkManager( |
| 212 cc::mojom::FrameSinkManagerRequest request, | 211 cc::mojom::FrameSinkManagerRequest request, |
| 213 cc::mojom::FrameSinkManagerClientPtr client) { | 212 cc::mojom::FrameSinkManagerClientPtr client) { |
| 214 NOTREACHED(); | 213 NOTREACHED(); |
| 215 } | 214 } |
| 216 | 215 |
| 217 void GpuChildThread::BindServiceFactoryRequest( | 216 void GpuChildThread::BindServiceFactoryRequest( |
| 218 service_manager::mojom::ServiceFactoryRequest request) { | 217 service_manager::mojom::ServiceFactoryRequest request) { |
| 219 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; | 218 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; |
| 220 DCHECK(service_factory_); | 219 DCHECK(service_factory_); |
| 221 service_factory_bindings_.AddBinding(service_factory_.get(), | 220 service_factory_bindings_.AddBinding(service_factory_.get(), |
| 222 std::move(request)); | 221 std::move(request)); |
| 223 } | 222 } |
| 224 | 223 |
| 225 } // namespace content | 224 } // namespace content |
| OLD | NEW |