| 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/public/cpp/gpu/gpu_service.h" | 5 #include "services/ui/public/cpp/gpu/gpu_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 void GpuService::OnEstablishedGpuChannel( | 108 void GpuService::OnEstablishedGpuChannel( |
| 109 int client_id, | 109 int client_id, |
| 110 mojo::ScopedMessagePipeHandle channel_handle, | 110 mojo::ScopedMessagePipeHandle channel_handle, |
| 111 const gpu::GPUInfo& gpu_info) { | 111 const gpu::GPUInfo& gpu_info) { |
| 112 DCHECK(IsMainThread()); | 112 DCHECK(IsMainThread()); |
| 113 DCHECK(gpu_service_.get()); | 113 DCHECK(gpu_service_.get()); |
| 114 DCHECK(!gpu_channel_); | 114 DCHECK(!gpu_channel_); |
| 115 | 115 |
| 116 if (client_id) { | 116 if (client_id && channel_handle.is_valid()) { |
| 117 gpu_channel_ = gpu::GpuChannelHost::Create( | 117 gpu_channel_ = gpu::GpuChannelHost::Create( |
| 118 this, client_id, gpu_info, IPC::ChannelHandle(channel_handle.release()), | 118 this, client_id, gpu_info, IPC::ChannelHandle(channel_handle.release()), |
| 119 &shutdown_event_, gpu_memory_buffer_manager_.get()); | 119 &shutdown_event_, gpu_memory_buffer_manager_.get()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 gpu_service_.reset(); | 122 gpu_service_.reset(); |
| 123 for (const auto& i : establish_callbacks_) | 123 for (const auto& i : establish_callbacks_) |
| 124 i.Run(gpu_channel_); | 124 i.Run(gpu_channel_); |
| 125 establish_callbacks_.clear(); | 125 establish_callbacks_.clear(); |
| 126 } | 126 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 147 MojoResult result = mojo::UnwrapSharedMemoryHandle( | 147 MojoResult result = mojo::UnwrapSharedMemoryHandle( |
| 148 std::move(handle), &platform_handle, &shared_memory_size, &readonly); | 148 std::move(handle), &platform_handle, &shared_memory_size, &readonly); |
| 149 if (result != MOJO_RESULT_OK) | 149 if (result != MOJO_RESULT_OK) |
| 150 return nullptr; | 150 return nullptr; |
| 151 DCHECK_EQ(shared_memory_size, size); | 151 DCHECK_EQ(shared_memory_size, size); |
| 152 | 152 |
| 153 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); | 153 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace ui | 156 } // namespace ui |
| OLD | NEW |