| 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" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 return builder.Build(); | 142 return builder.Build(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace | 145 } // namespace |
| 146 | 146 |
| 147 GpuChildThread::GpuChildThread( | 147 GpuChildThread::GpuChildThread( |
| 148 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, | 148 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, |
| 149 bool dead_on_arrival, | 149 bool dead_on_arrival, |
| 150 const gpu::GPUInfo& gpu_info, | 150 const gpu::GPUInfo& gpu_info, |
| 151 const gpu::GpuFeatureInfo& gpu_feature_info, |
| 151 const DeferredMessages& deferred_messages, | 152 const DeferredMessages& deferred_messages, |
| 152 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 153 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 153 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), | 154 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), |
| 154 dead_on_arrival_(dead_on_arrival), | 155 dead_on_arrival_(dead_on_arrival), |
| 155 gpu_info_(gpu_info), | 156 gpu_info_(gpu_info), |
| 156 deferred_messages_(deferred_messages), | 157 deferred_messages_(deferred_messages), |
| 157 in_browser_process_(false), | 158 in_browser_process_(false), |
| 158 gpu_service_( | 159 gpu_service_(new ui::GpuService(gpu_info, |
| 159 new ui::GpuService(gpu_info, | 160 std::move(watchdog_thread), |
| 160 std::move(watchdog_thread), | 161 gpu_memory_buffer_factory, |
| 161 gpu_memory_buffer_factory, | 162 ChildProcess::current()->io_task_runner(), |
| 162 ChildProcess::current()->io_task_runner())), | 163 gpu_feature_info)), |
| 163 gpu_main_binding_(this) { | 164 gpu_main_binding_(this) { |
| 164 #if defined(OS_WIN) | 165 #if defined(OS_WIN) |
| 165 target_services_ = NULL; | 166 target_services_ = NULL; |
| 166 #endif | 167 #endif |
| 167 g_thread_safe_sender.Get() = thread_safe_sender(); | 168 g_thread_safe_sender.Get() = thread_safe_sender(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 GpuChildThread::GpuChildThread( | 171 GpuChildThread::GpuChildThread( |
| 171 const InProcessChildThreadParams& params, | 172 const InProcessChildThreadParams& params, |
| 172 const gpu::GPUInfo& gpu_info, | 173 const gpu::GPUInfo& gpu_info, |
| 174 const gpu::GpuFeatureInfo& gpu_feature_info, |
| 173 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 175 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 174 : ChildThreadImpl(ChildThreadImpl::Options::Builder() | 176 : ChildThreadImpl(ChildThreadImpl::Options::Builder() |
| 175 .InBrowserProcess(params) | 177 .InBrowserProcess(params) |
| 176 .AddStartupFilter(new GpuMemoryBufferMessageFilter( | 178 .AddStartupFilter(new GpuMemoryBufferMessageFilter( |
| 177 gpu_memory_buffer_factory)) | 179 gpu_memory_buffer_factory)) |
| 178 .ConnectToBrowser(true) | 180 .ConnectToBrowser(true) |
| 179 .Build()), | 181 .Build()), |
| 180 dead_on_arrival_(false), | 182 dead_on_arrival_(false), |
| 181 gpu_info_(gpu_info), | 183 gpu_info_(gpu_info), |
| 182 in_browser_process_(true), | 184 in_browser_process_(true), |
| 183 gpu_service_( | 185 gpu_service_(new ui::GpuService(gpu_info, |
| 184 new ui::GpuService(gpu_info, | 186 nullptr /* watchdog thread */, |
| 185 nullptr /* watchdog thread */, | 187 gpu_memory_buffer_factory, |
| 186 gpu_memory_buffer_factory, | 188 ChildProcess::current()->io_task_runner(), |
| 187 ChildProcess::current()->io_task_runner())), | 189 gpu_feature_info)), |
| 188 gpu_main_binding_(this) { | 190 gpu_main_binding_(this) { |
| 189 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
| 190 target_services_ = NULL; | 192 target_services_ = NULL; |
| 191 #endif | 193 #endif |
| 192 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 194 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 193 switches::kSingleProcess) || | 195 switches::kSingleProcess) || |
| 194 base::CommandLine::ForCurrentProcess()->HasSwitch( | 196 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 195 switches::kInProcessGPU)); | 197 switches::kInProcessGPU)); |
| 196 | 198 |
| 197 g_thread_safe_sender.Get() = thread_safe_sender(); | 199 g_thread_safe_sender.Get() = thread_safe_sender(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 gpu_info_.video_decode_accelerator_capabilities = | 306 gpu_info_.video_decode_accelerator_capabilities = |
| 305 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences); | 307 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences); |
| 306 gpu_info_.video_encode_accelerator_supported_profiles = | 308 gpu_info_.video_encode_accelerator_supported_profiles = |
| 307 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences); | 309 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences); |
| 308 gpu_info_.jpeg_decode_accelerator_supported = | 310 gpu_info_.jpeg_decode_accelerator_supported = |
| 309 media::GpuJpegDecodeAccelerator::IsSupported(); | 311 media::GpuJpegDecodeAccelerator::IsSupported(); |
| 310 | 312 |
| 311 // Record initialization only after collecting the GPU info because that can | 313 // Record initialization only after collecting the GPU info because that can |
| 312 // take a significant amount of time. | 314 // take a significant amount of time. |
| 313 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 315 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
| 314 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); | 316 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_, |
| 317 gpu_service_->gpu_feature_info())); |
| 315 while (!deferred_messages_.empty()) { | 318 while (!deferred_messages_.empty()) { |
| 316 const LogMessage& log = deferred_messages_.front(); | 319 const LogMessage& log = deferred_messages_.front(); |
| 317 Send(new GpuHostMsg_OnLogMessage(log.severity, log.header, log.message)); | 320 Send(new GpuHostMsg_OnLogMessage(log.severity, log.header, log.message)); |
| 318 deferred_messages_.pop(); | 321 deferred_messages_.pop(); |
| 319 } | 322 } |
| 320 | 323 |
| 321 if (dead_on_arrival_) { | 324 if (dead_on_arrival_) { |
| 322 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; | 325 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; |
| 323 base::MessageLoop::current()->QuitWhenIdle(); | 326 base::MessageLoop::current()->QuitWhenIdle(); |
| 324 return; | 327 return; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 509 |
| 507 void GpuChildThread::BindServiceFactoryRequest( | 510 void GpuChildThread::BindServiceFactoryRequest( |
| 508 service_manager::mojom::ServiceFactoryRequest request) { | 511 service_manager::mojom::ServiceFactoryRequest request) { |
| 509 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; | 512 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; |
| 510 DCHECK(service_factory_); | 513 DCHECK(service_factory_); |
| 511 service_factory_bindings_.AddBinding(service_factory_.get(), | 514 service_factory_bindings_.AddBinding(service_factory_.get(), |
| 512 std::move(request)); | 515 std::move(request)); |
| 513 } | 516 } |
| 514 | 517 |
| 515 } // namespace content | 518 } // namespace content |
| OLD | NEW |