| 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/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
| 14 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "content/child/child_process.h" | 16 #include "content/child/child_process.h" |
| 17 #include "content/child/thread_safe_sender.h" | 17 #include "content/child/thread_safe_sender.h" |
| 18 #include "content/common/establish_channel_params.h" | 18 #include "content/common/establish_channel_params.h" |
| 19 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" | 19 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
| 20 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 20 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 21 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 21 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
| 22 #include "content/common/gpu/media/media_service.h" | 22 #include "content/common/gpu/media/media_service.h" |
| 23 #include "content/common/gpu_host_messages.h" | 23 #include "content/common/gpu_host_messages.h" |
| 24 #include "content/common/media/media_permission_dispatcher.h" |
| 24 #include "content/gpu/gpu_process_control_impl.h" | 25 #include "content/gpu/gpu_process_control_impl.h" |
| 25 #include "content/gpu/gpu_watchdog_thread.h" | 26 #include "content/gpu/gpu_watchdog_thread.h" |
| 26 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/gpu/content_gpu_client.h" | 29 #include "content/public/gpu/content_gpu_client.h" |
| 29 #include "gpu/command_buffer/service/gpu_switches.h" | 30 #include "gpu/command_buffer/service/gpu_switches.h" |
| 30 #include "gpu/config/gpu_info_collector.h" | 31 #include "gpu/config/gpu_info_collector.h" |
| 31 #include "gpu/config/gpu_switches.h" | 32 #include "gpu/config/gpu_switches.h" |
| 32 #include "gpu/config/gpu_util.h" | 33 #include "gpu/config/gpu_util.h" |
| 33 #include "gpu/ipc/common/memory_stats.h" | 34 #include "gpu/ipc/common/memory_stats.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 215 } |
| 215 | 216 |
| 216 void GpuChildThread::Shutdown() { | 217 void GpuChildThread::Shutdown() { |
| 217 ChildThreadImpl::Shutdown(); | 218 ChildThreadImpl::Shutdown(); |
| 218 logging::SetLogMessageHandler(NULL); | 219 logging::SetLogMessageHandler(NULL); |
| 219 } | 220 } |
| 220 | 221 |
| 221 void GpuChildThread::Init(const base::Time& process_start_time) { | 222 void GpuChildThread::Init(const base::Time& process_start_time) { |
| 222 process_start_time_ = process_start_time; | 223 process_start_time_ = process_start_time; |
| 223 | 224 |
| 224 process_control_.reset(new GpuProcessControlImpl()); | 225 process_control_.reset(new GpuProcessControlImpl(GetMediaPermission())); |
| 225 // Use of base::Unretained(this) is safe here because |service_registry()| | 226 // Use of base::Unretained(this) is safe here because |service_registry()| |
| 226 // will be destroyed before GpuChildThread is destructed. | 227 // will be destroyed before GpuChildThread is destructed. |
| 227 service_registry()->AddService(base::Bind( | 228 service_registry()->AddService(base::Bind( |
| 228 &GpuChildThread::BindProcessControlRequest, base::Unretained(this))); | 229 &GpuChildThread::BindProcessControlRequest, base::Unretained(this))); |
| 229 | 230 |
| 230 if (GetContentClient()->gpu()) // NULL in tests. | 231 if (GetContentClient()->gpu()) // NULL in tests. |
| 231 GetContentClient()->gpu()->RegisterMojoServices(service_registry()); | 232 GetContentClient()->gpu()->RegisterMojoServices(service_registry()); |
| 232 } | 233 } |
| 233 | 234 |
| 234 bool GpuChildThread::Send(IPC::Message* msg) { | 235 bool GpuChildThread::Send(IPC::Message* msg) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 571 } |
| 571 #endif | 572 #endif |
| 572 | 573 |
| 573 void GpuChildThread::OnLoseAllContexts() { | 574 void GpuChildThread::OnLoseAllContexts() { |
| 574 if (gpu_channel_manager_) { | 575 if (gpu_channel_manager_) { |
| 575 gpu_channel_manager_->DestroyAllChannels(); | 576 gpu_channel_manager_->DestroyAllChannels(); |
| 576 media_service_->DestroyAllChannels(); | 577 media_service_->DestroyAllChannels(); |
| 577 } | 578 } |
| 578 } | 579 } |
| 579 | 580 |
| 581 template <typename Interface> |
| 582 void GpuChildThread::GetInterface(mojo::InterfaceRequest<Interface> request) { |
| 583 service_registry()->ConnectToRemoteService(std::move(request)); |
| 584 } |
| 585 |
| 586 media::MediaPermission* GpuChildThread::GetMediaPermission() { |
| 587 if (!media_permission_dispatcher_) { |
| 588 // Use of base::Unretained(this) is safe here because |
| 589 // |media_permission_dispatcher_| will be destroyed before GpuChildThread |
| 590 // is destructed. |
| 591 media_permission_dispatcher_.reset(new MediaPermissionDispatcher(base::Bind( |
| 592 &GpuChildThread::GetInterface<blink::mojom::PermissionService>, |
| 593 base::Unretained(this)))); |
| 594 } |
| 595 return media_permission_dispatcher_.get(); |
| 596 } |
| 597 |
| 580 void GpuChildThread::BindProcessControlRequest( | 598 void GpuChildThread::BindProcessControlRequest( |
| 581 mojo::InterfaceRequest<mojom::ProcessControl> request) { | 599 mojo::InterfaceRequest<mojom::ProcessControl> request) { |
| 582 DVLOG(1) << "GPU: Binding ProcessControl request"; | 600 DVLOG(1) << "GPU: Binding ProcessControl request"; |
| 583 DCHECK(process_control_); | 601 DCHECK(process_control_); |
| 584 process_control_bindings_.AddBinding(process_control_.get(), | 602 process_control_bindings_.AddBinding(process_control_.get(), |
| 585 std::move(request)); | 603 std::move(request)); |
| 586 } | 604 } |
| 587 | 605 |
| 588 } // namespace content | 606 } // namespace content |
| OLD | NEW |