| 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_service.h" |    5 #include "services/ui/public/cpp/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   85                                          &gpu_info)) { |   85                                          &gpu_info)) { | 
|   86     DLOG(WARNING) |   86     DLOG(WARNING) | 
|   87         << "Channel encountered error while establishing gpu channel."; |   87         << "Channel encountered error while establishing gpu channel."; | 
|   88     return nullptr; |   88     return nullptr; | 
|   89   } |   89   } | 
|   90   OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info); |   90   OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info); | 
|   91   return gpu_channel_; |   91   return gpu_channel_; | 
|   92 } |   92 } | 
|   93  |   93  | 
|   94 gpu::GpuMemoryBufferManager* GpuService::GetGpuMemoryBufferManager() { |   94 gpu::GpuMemoryBufferManager* GpuService::GetGpuMemoryBufferManager() { | 
|   95   return gpu_memory_buffer_manager_.get(); |   95   return gpu_memory_buffer_manager(); | 
|   96 } |   96 } | 
|   97  |   97  | 
|   98 scoped_refptr<gpu::GpuChannelHost> GpuService::GetGpuChannel() { |   98 scoped_refptr<gpu::GpuChannelHost> GpuService::GetGpuChannel() { | 
|   99   DCHECK(IsMainThread()); |   99   DCHECK(IsMainThread()); | 
|  100   if (gpu_channel_ && gpu_channel_->IsLost()) { |  100   if (gpu_channel_ && gpu_channel_->IsLost()) { | 
|  101     gpu_channel_->DestroyChannel(); |  101     gpu_channel_->DestroyChannel(); | 
|  102     gpu_channel_ = nullptr; |  102     gpu_channel_ = nullptr; | 
|  103   } |  103   } | 
|  104   return gpu_channel_; |  104   return gpu_channel_; | 
|  105 } |  105 } | 
|  106  |  106  | 
|  107 void GpuService::OnEstablishedGpuChannel( |  107 void GpuService::OnEstablishedGpuChannel( | 
|  108     int client_id, |  108     int client_id, | 
|  109     mojo::ScopedMessagePipeHandle channel_handle, |  109     mojo::ScopedMessagePipeHandle channel_handle, | 
|  110     const gpu::GPUInfo& gpu_info) { |  110     const gpu::GPUInfo& gpu_info) { | 
|  111   DCHECK(IsMainThread()); |  111   DCHECK(IsMainThread()); | 
|  112   DCHECK(gpu_service_.get()); |  112   DCHECK(gpu_service_.get()); | 
|  113   DCHECK(!gpu_channel_); |  113   DCHECK(!gpu_channel_); | 
|  114  |  114  | 
|  115   if (client_id) { |  115   if (client_id) { | 
|  116     gpu_channel_ = gpu::GpuChannelHost::Create( |  116     gpu_channel_ = gpu::GpuChannelHost::Create( | 
|  117         this, client_id, gpu_info, IPC::ChannelHandle(channel_handle.release()), |  117         this, client_id, gpu_info, IPC::ChannelHandle(channel_handle.release()), | 
|  118         &shutdown_event_, gpu_memory_buffer_manager_.get()); |  118         &shutdown_event_, gpu_memory_buffer_manager()); | 
|  119   } |  119   } | 
|  120  |  120  | 
|  121   gpu_service_.reset(); |  121   gpu_service_.reset(); | 
|  122   for (const auto& i : establish_callbacks_) |  122   for (const auto& i : establish_callbacks_) | 
|  123     i.Run(gpu_channel_); |  123     i.Run(gpu_channel_); | 
|  124   establish_callbacks_.clear(); |  124   establish_callbacks_.clear(); | 
|  125 } |  125 } | 
|  126  |  126  | 
|  127 bool GpuService::IsMainThread() { |  127 bool GpuService::IsMainThread() { | 
|  128   return main_task_runner_->BelongsToCurrentThread(); |  128   return main_task_runner_->BelongsToCurrentThread(); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  146   MojoResult result = mojo::UnwrapSharedMemoryHandle( |  146   MojoResult result = mojo::UnwrapSharedMemoryHandle( | 
|  147       std::move(handle), &platform_handle, &shared_memory_size, &readonly); |  147       std::move(handle), &platform_handle, &shared_memory_size, &readonly); | 
|  148   if (result != MOJO_RESULT_OK) |  148   if (result != MOJO_RESULT_OK) | 
|  149     return nullptr; |  149     return nullptr; | 
|  150   DCHECK_EQ(shared_memory_size, size); |  150   DCHECK_EQ(shared_memory_size, size); | 
|  151  |  151  | 
|  152   return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); |  152   return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); | 
|  153 } |  153 } | 
|  154  |  154  | 
|  155 }  // namespace ui |  155 }  // namespace ui | 
| OLD | NEW |