Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: services/ui/public/cpp/gpu_service.cc

Issue 2247183005: services/ui: Get rid of IPC::ChannelHandle type converter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/public/cpp/gpu_service.h ('k') | services/ui/public/interfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // In browser process, EstablishGpuChannelSync() is only used by testing & 145 // In browser process, EstablishGpuChannelSync() is only used by testing &
146 // GpuProcessTransportFactory::GetGLHelper(). For GetGLHelper(), it expects 146 // GpuProcessTransportFactory::GetGLHelper(). For GetGLHelper(), it expects
147 // the gpu channel has been established, so it should not reach here. 147 // the gpu channel has been established, so it should not reach here.
148 // For testing, the asyc method should not be used. 148 // For testing, the asyc method should not be used.
149 // In renderer process, we only use EstablishGpuChannelSync(). 149 // In renderer process, we only use EstablishGpuChannelSync().
150 // So the gpu_service_ should be null here. 150 // So the gpu_service_ should be null here.
151 DCHECK(!gpu_service_); 151 DCHECK(!gpu_service_);
152 152
153 int client_id = 0; 153 int client_id = 0;
154 mojom::ChannelHandlePtr channel_handle; 154 mojo::ScopedMessagePipeHandle channel_handle;
155 gpu::GPUInfo gpu_info; 155 gpu::GPUInfo gpu_info;
156 connector_->ConnectToInterface("mojo:ui", &gpu_service_); 156 connector_->ConnectToInterface("mojo:ui", &gpu_service_);
157 { 157 {
158 base::AutoUnlock auto_unlock(lock_); 158 base::AutoUnlock auto_unlock(lock_);
159 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call; 159 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
160 if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle, 160 if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle,
161 &gpu_info)) { 161 &gpu_info)) {
162 DLOG(WARNING) 162 DLOG(WARNING)
163 << "Channel encountered error while establishing gpu channel."; 163 << "Channel encountered error while establishing gpu channel.";
164 return; 164 return;
165 } 165 }
166 } 166 }
167 const bool locked = true; 167 const bool locked = true;
168 EstablishGpuChannelOnMainThreadDone(locked, client_id, 168 EstablishGpuChannelOnMainThreadDone(locked, client_id,
169 std::move(channel_handle), gpu_info); 169 std::move(channel_handle), gpu_info);
170 } 170 }
171 171
172 void GpuService::EstablishGpuChannelOnMainThreadDone( 172 void GpuService::EstablishGpuChannelOnMainThreadDone(
173 bool locked, 173 bool locked,
174 int client_id, 174 int client_id,
175 mojom::ChannelHandlePtr channel_handle, 175 mojo::ScopedMessagePipeHandle channel_handle,
176 const gpu::GPUInfo& gpu_info) { 176 const gpu::GPUInfo& gpu_info) {
177 DCHECK(IsMainThread()); 177 DCHECK(IsMainThread());
178 scoped_refptr<gpu::GpuChannelHost> gpu_channel; 178 scoped_refptr<gpu::GpuChannelHost> gpu_channel;
179 if (client_id) { 179 if (client_id) {
180 // TODO(penghuang): Get the real gpu info from mus. 180 // TODO(penghuang): Get the real gpu info from mus.
181 gpu_channel = gpu::GpuChannelHost::Create( 181 gpu_channel = gpu::GpuChannelHost::Create(
182 this, client_id, gpu::GPUInfo(), 182 this, client_id, gpu::GPUInfo(),
183 channel_handle.To<IPC::ChannelHandle>(), &shutdown_event_, 183 IPC::ChannelHandle(channel_handle.release()), &shutdown_event_,
184 gpu_memory_buffer_manager_.get()); 184 gpu_memory_buffer_manager_.get());
185 } 185 }
186 186
187 auto auto_lock = base::WrapUnique<base::AutoLock>( 187 auto auto_lock = base::WrapUnique<base::AutoLock>(
188 locked ? nullptr : new base::AutoLock(lock_)); 188 locked ? nullptr : new base::AutoLock(lock_));
189 DCHECK(is_establishing_); 189 DCHECK(is_establishing_);
190 DCHECK(!gpu_channel_); 190 DCHECK(!gpu_channel_);
191 191
192 is_establishing_ = false; 192 is_establishing_ = false;
193 gpu_channel_ = gpu_channel; 193 gpu_channel_ = gpu_channel;
(...skipping 27 matching lines...) Expand all
221 MojoResult result = mojo::UnwrapSharedMemoryHandle( 221 MojoResult result = mojo::UnwrapSharedMemoryHandle(
222 std::move(handle), &platform_handle, &shared_memory_size, &readonly); 222 std::move(handle), &platform_handle, &shared_memory_size, &readonly);
223 if (result != MOJO_RESULT_OK) 223 if (result != MOJO_RESULT_OK)
224 return nullptr; 224 return nullptr;
225 DCHECK_EQ(shared_memory_size, size); 225 DCHECK_EQ(shared_memory_size, size);
226 226
227 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); 227 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
228 } 228 }
229 229
230 } // namespace ui 230 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/gpu_service.h ('k') | services/ui/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698