| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/gpu/gpu_service_internal.h" | 5 #include "services/ui/gpu/gpu_service_internal.h" |
| 6 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 callback.Run(std::move(*channel_handle)); | 43 callback.Run(std::move(*channel_handle)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 GpuServiceInternal::GpuServiceInternal() | 48 GpuServiceInternal::GpuServiceInternal() |
| 49 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 49 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 50 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, | 50 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 51 base::WaitableEvent::InitialState::NOT_SIGNALED), | 51 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 52 gpu_thread_("GpuThread"), | 52 gpu_thread_("GpuThread"), |
| 53 io_thread_("GpuIOThread"), | 53 io_thread_("GpuIOThread") {} |
| 54 binding_(this) {} | |
| 55 | 54 |
| 56 GpuServiceInternal::~GpuServiceInternal() { | 55 GpuServiceInternal::~GpuServiceInternal() { |
| 57 // Signal this event before destroying the child process. That way all | 56 // Signal this event before destroying the child process. That way all |
| 58 // background threads can cleanup. | 57 // background threads can cleanup. |
| 59 // For example, in the renderer the RenderThread instances will be able to | 58 // For example, in the renderer the RenderThread instances will be able to |
| 60 // notice shutdown before the render process begins waiting for them to exit. | 59 // notice shutdown before the render process begins waiting for them to exit. |
| 61 shutdown_event_.Signal(); | 60 shutdown_event_.Signal(); |
| 62 io_thread_.Stop(); | 61 io_thread_.Stop(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void GpuServiceInternal::Add(mojom::GpuServiceInternalRequest request) { | 64 void GpuServiceInternal::Add(mojom::GpuServiceInternalRequest request) { |
| 66 binding_.Bind(std::move(request)); | 65 bindings_.AddBinding(this, std::move(request)); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void GpuServiceInternal::EstablishGpuChannelInternal( | 68 void GpuServiceInternal::EstablishGpuChannelInternal( |
| 70 int32_t client_id, | 69 int32_t client_id, |
| 71 uint64_t client_tracing_id, | 70 uint64_t client_tracing_id, |
| 72 bool preempts, | 71 bool preempts, |
| 73 bool allow_view_command_buffers, | 72 bool allow_view_command_buffers, |
| 74 bool allow_real_time_streams, | 73 bool allow_real_time_streams, |
| 75 const EstablishGpuChannelCallback& callback) { | 74 const EstablishGpuChannelCallback& callback) { |
| 76 DCHECK(CalledOnValidThread()); | 75 DCHECK(CalledOnValidThread()); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 allow_real_time_streams, callback); | 250 allow_real_time_streams, callback); |
| 252 } | 251 } |
| 253 | 252 |
| 254 // static | 253 // static |
| 255 GpuServiceInternal* GpuServiceInternal::GetInstance() { | 254 GpuServiceInternal* GpuServiceInternal::GetInstance() { |
| 256 return base::Singleton<GpuServiceInternal, | 255 return base::Singleton<GpuServiceInternal, |
| 257 base::LeakySingletonTraits<GpuServiceInternal>>::get(); | 256 base::LeakySingletonTraits<GpuServiceInternal>>::get(); |
| 258 } | 257 } |
| 259 | 258 |
| 260 } // namespace ui | 259 } // namespace ui |
| OLD | NEW |