| 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 "components/mus/gpu/gpu_service_mus.h" | 5 #include "components/mus/gpu/gpu_service_mus.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 28 matching lines...) Expand all Loading... |
| 39 int client_id, | 39 int client_id, |
| 40 std::unique_ptr<IPC::ChannelHandle> channel_handle, | 40 std::unique_ptr<IPC::ChannelHandle> channel_handle, |
| 41 const GpuServiceMus::EstablishGpuChannelCallback& callback) { | 41 const GpuServiceMus::EstablishGpuChannelCallback& callback) { |
| 42 callback.Run(channel_handle ? client_id : -1, *channel_handle); | 42 callback.Run(channel_handle ? client_id : -1, *channel_handle); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 GpuServiceMus::GpuServiceMus() | 46 GpuServiceMus::GpuServiceMus() |
| 47 : next_client_id_(kLocalGpuChannelClientId), | 47 : next_client_id_(kLocalGpuChannelClientId), |
| 48 main_message_loop_(base::MessageLoop::current()), | 48 main_message_loop_(base::MessageLoop::current()), |
| 49 shutdown_event_(true, false), | 49 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 50 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 50 gpu_thread_("GpuThread"), | 51 gpu_thread_("GpuThread"), |
| 51 io_thread_("GpuIOThread") { | 52 io_thread_("GpuIOThread") { |
| 52 Initialize(); | 53 Initialize(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 GpuServiceMus::~GpuServiceMus() { | 56 GpuServiceMus::~GpuServiceMus() { |
| 56 // Signal this event before destroying the child process. That way all | 57 // Signal this event before destroying the child process. That way all |
| 57 // background threads can cleanup. | 58 // background threads can cleanup. |
| 58 // For example, in the renderer the RenderThread instances will be able to | 59 // For example, in the renderer the RenderThread instances will be able to |
| 59 // notice shutdown before the render process begins waiting for them to exit. | 60 // notice shutdown before the render process begins waiting for them to exit. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 return shm; | 267 return shm; |
| 267 } | 268 } |
| 268 | 269 |
| 269 // static | 270 // static |
| 270 GpuServiceMus* GpuServiceMus::GetInstance() { | 271 GpuServiceMus* GpuServiceMus::GetInstance() { |
| 271 return base::Singleton<GpuServiceMus, | 272 return base::Singleton<GpuServiceMus, |
| 272 base::LeakySingletonTraits<GpuServiceMus>>::get(); | 273 base::LeakySingletonTraits<GpuServiceMus>>::get(); |
| 273 } | 274 } |
| 274 | 275 |
| 275 } // namespace mus | 276 } // namespace mus |
| OLD | NEW |