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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); | 58 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); |
59 if (channel) { | 59 if (channel) { |
60 main_task_runner_->PostTask(FROM_HERE, | 60 main_task_runner_->PostTask(FROM_HERE, |
61 base::Bind(callback, std::move(channel))); | 61 base::Bind(callback, std::move(channel))); |
62 return; | 62 return; |
63 } | 63 } |
64 establish_callbacks_.push_back(callback); | 64 establish_callbacks_.push_back(callback); |
65 if (gpu_service_) | 65 if (gpu_service_) |
66 return; | 66 return; |
67 | 67 |
68 connector_->ConnectToInterface("mojo:ui", &gpu_service_); | 68 connector_->ConnectToInterface("service:ui", &gpu_service_); |
69 gpu_service_->EstablishGpuChannel( | 69 gpu_service_->EstablishGpuChannel( |
70 base::Bind(&GpuService::OnEstablishedGpuChannel, base::Unretained(this))); | 70 base::Bind(&GpuService::OnEstablishedGpuChannel, base::Unretained(this))); |
71 } | 71 } |
72 | 72 |
73 scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() { | 73 scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() { |
74 DCHECK(IsMainThread()); | 74 DCHECK(IsMainThread()); |
75 if (GetGpuChannel()) | 75 if (GetGpuChannel()) |
76 return gpu_channel_; | 76 return gpu_channel_; |
77 | 77 |
78 int client_id = 0; | 78 int client_id = 0; |
79 mojo::ScopedMessagePipeHandle channel_handle; | 79 mojo::ScopedMessagePipeHandle channel_handle; |
80 gpu::GPUInfo gpu_info; | 80 gpu::GPUInfo gpu_info; |
81 connector_->ConnectToInterface("mojo:ui", &gpu_service_); | 81 connector_->ConnectToInterface("service:ui", &gpu_service_); |
82 | 82 |
83 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call; | 83 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call; |
84 if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle, | 84 if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle, |
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_; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |