Chromium Code Reviews| 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_mus.h" | 5 #include "services/ui/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 24 matching lines...) Expand all Loading... | |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 namespace ui { | 37 namespace ui { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const int kLocalGpuChannelClientId = 1; | 40 const int kLocalGpuChannelClientId = 1; |
| 41 const uint64_t kLocalGpuChannelClientTracingId = 1; | 41 const uint64_t kLocalGpuChannelClientTracingId = 1; |
| 42 | 42 |
| 43 void EstablishGpuChannelDone( | 43 void EstablishGpuChannelDone( |
| 44 int client_id, | 44 int client_id, |
| 45 const IPC::ChannelHandle* channel_handle, | 45 IPC::ChannelHandle* channel_handle, |
| 46 const GpuServiceMus::EstablishGpuChannelCallback& callback) { | 46 const GpuServiceMus::EstablishGpuChannelCallback& callback) { |
| 47 callback.Run(channel_handle ? client_id : -1, *channel_handle); | 47 callback.Run(channel_handle ? client_id : -1, channel_handle); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 GpuServiceMus::GpuServiceMus() | 51 GpuServiceMus::GpuServiceMus() |
| 52 : next_client_id_(kLocalGpuChannelClientId), | 52 : next_client_id_(kLocalGpuChannelClientId), |
| 53 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 53 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 54 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, | 54 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 55 base::WaitableEvent::InitialState::NOT_SIGNALED), | 55 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 56 gpu_thread_("GpuThread"), | 56 gpu_thread_("GpuThread"), |
| 57 io_thread_("GpuIOThread") { | 57 io_thread_("GpuIOThread") { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 69 | 69 |
| 70 void GpuServiceMus::EstablishGpuChannel( | 70 void GpuServiceMus::EstablishGpuChannel( |
| 71 uint64_t client_tracing_id, | 71 uint64_t client_tracing_id, |
| 72 bool preempts, | 72 bool preempts, |
| 73 bool allow_view_command_buffers, | 73 bool allow_view_command_buffers, |
| 74 bool allow_real_time_streams, | 74 bool allow_real_time_streams, |
| 75 const EstablishGpuChannelCallback& callback) { | 75 const EstablishGpuChannelCallback& callback) { |
| 76 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
| 77 | 77 |
| 78 if (!gpu_channel_manager_) { | 78 if (!gpu_channel_manager_) { |
| 79 callback.Run(-1, IPC::ChannelHandle()); | 79 callback.Run(-1, nullptr); |
|
dcheng
2016/08/18 00:06:01
I would probably just throw a IPC::ChannelHandle o
| |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| 83 const int client_id = ++next_client_id_; | 83 const int client_id = ++next_client_id_; |
| 84 IPC::ChannelHandle* channel_handle = new IPC::ChannelHandle; | 84 IPC::ChannelHandle* channel_handle = new IPC::ChannelHandle; |
| 85 gpu_thread_.task_runner()->PostTaskAndReply( | 85 gpu_thread_.task_runner()->PostTaskAndReply( |
| 86 FROM_HERE, | 86 FROM_HERE, |
| 87 base::Bind(&GpuServiceMus::EstablishGpuChannelOnGpuThread, | 87 base::Bind(&GpuServiceMus::EstablishGpuChannelOnGpuThread, |
| 88 base::Unretained(this), client_id, client_tracing_id, preempts, | 88 base::Unretained(this), client_id, client_tracing_id, preempts, |
| 89 allow_view_command_buffers, allow_real_time_streams, | 89 allow_view_command_buffers, allow_real_time_streams, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 return shm; | 266 return shm; |
| 267 } | 267 } |
| 268 | 268 |
| 269 // static | 269 // static |
| 270 GpuServiceMus* GpuServiceMus::GetInstance() { | 270 GpuServiceMus* GpuServiceMus::GetInstance() { |
| 271 return base::Singleton<GpuServiceMus, | 271 return base::Singleton<GpuServiceMus, |
| 272 base::LeakySingletonTraits<GpuServiceMus>>::get(); | 272 base::LeakySingletonTraits<GpuServiceMus>>::get(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace ui | 275 } // namespace ui |
| OLD | NEW |