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

Side by Side Diff: content/common/gpu/client/command_buffer_proxy_impl.cc

Issue 9958034: Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/gpu/client/command_buffer_proxy_impl.h" 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "content/common/child_process_messages.h" 13 #include "content/common/child_process_messages.h"
14 #include "content/common/gpu/gpu_memory_allocation.h" 14 #include "content/common/gpu/gpu_memory_allocation.h"
15 #include "content/common/gpu/client/gpu_channel_host.h" 15 #include "content/common/gpu/client/gpu_channel_host.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/plugin_messages.h" 17 #include "content/common/plugin_messages.h"
18 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
19 #include "gpu/command_buffer/common/cmd_buffer_common.h" 19 #include "gpu/command_buffer/common/cmd_buffer_common.h"
20 #include "gpu/command_buffer/common/command_buffer_shared.h" 20 #include "gpu/command_buffer/common/command_buffer_shared.h"
21 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
22 22
23 #if defined(OS_WIN)
24 #include "content/common/sandbox_policy.h"
25 #endif
26
23 using gpu::Buffer; 27 using gpu::Buffer;
24 28
25 CommandBufferProxyImpl::CommandBufferProxyImpl( 29 CommandBufferProxyImpl::CommandBufferProxyImpl(
26 GpuChannelHost* channel, 30 GpuChannelHost* channel,
27 int route_id) 31 int route_id)
28 : channel_(channel), 32 : channel_(channel),
29 route_id_(route_id), 33 route_id_(route_id),
30 flush_count_(0), 34 flush_count_(0),
31 last_put_offset_(-1) { 35 last_put_offset_(-1) {
32 } 36 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 231
228 // Take ownership of shared memory. This will close the handle if Send below 232 // Take ownership of shared memory. This will close the handle if Send below
229 // fails. Otherwise, callee takes ownership before this variable 233 // fails. Otherwise, callee takes ownership before this variable
230 // goes out of scope by duping the handle. 234 // goes out of scope by duping the handle.
231 scoped_ptr<base::SharedMemory> shm( 235 scoped_ptr<base::SharedMemory> shm(
232 channel_->factory()->AllocateSharedMemory(size)); 236 channel_->factory()->AllocateSharedMemory(size));
233 if (!shm.get()) 237 if (!shm.get())
234 return -1; 238 return -1;
235 239
236 base::SharedMemoryHandle handle = shm->handle(); 240 base::SharedMemoryHandle handle = shm->handle();
237 #if defined(OS_POSIX) 241 #if defined(OS_WIN)
242 // Windows needs to explicitly duplicate the handle out to another process.
243 if (!sandbox::BrokerDuplicateHandle(handle, channel_->gpu_pid(),
244 &handle, FILE_MAP_WRITE, 0)) {
245 return -1;
246 }
247 #elif defined(OS_POSIX)
238 DCHECK(!handle.auto_close); 248 DCHECK(!handle.auto_close);
239 #endif 249 #endif
240 250
241 int32 id; 251 int32 id;
242 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_, 252 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_,
243 handle, 253 handle,
244 size, 254 size,
245 id_request, 255 id_request,
246 &id))) { 256 &id))) {
247 return -1; 257 return -1;
248 } 258 }
249 259
250 return id; 260 return id;
251 } 261 }
252 262
253 int32 CommandBufferProxyImpl::RegisterTransferBuffer( 263 int32 CommandBufferProxyImpl::RegisterTransferBuffer(
254 base::SharedMemory* shared_memory, 264 base::SharedMemory* shared_memory,
255 size_t size, 265 size_t size,
256 int32 id_request) { 266 int32 id_request) {
257 if (last_state_.error != gpu::error::kNoError) 267 if (last_state_.error != gpu::error::kNoError)
258 return -1; 268 return -1;
259 269
270 // Returns FileDescriptor with auto_close off.
271 base::SharedMemoryHandle handle = shared_memory->handle();
272 #if defined(OS_WIN)
273 // Windows needs to explicitly duplicate the handle out to another process.
274 if (!sandbox::BrokerDuplicateHandle(handle, channel_->gpu_pid(),
275 &handle, FILE_MAP_WRITE, 0)) {
276 return -1;
277 }
278 #endif
279
260 int32 id; 280 int32 id;
261 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer( 281 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(
262 route_id_, 282 route_id_,
263 shared_memory->handle(), // Returns FileDescriptor with auto_close off. 283 handle,
264 size, 284 size,
265 id_request, 285 id_request,
266 &id))) { 286 &id))) {
267 return -1; 287 return -1;
268 } 288 }
269 289
270 return id; 290 return id;
271 } 291 }
272 292
273 void CommandBufferProxyImpl::DestroyTransferBuffer(int32 id) { 293 void CommandBufferProxyImpl::DestroyTransferBuffer(int32 id) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 500
481 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( 501 void CommandBufferProxyImpl::SetOnConsoleMessageCallback(
482 const GpuConsoleMessageCallback& callback) { 502 const GpuConsoleMessageCallback& callback) {
483 console_message_callback_ = callback; 503 console_message_callback_ = callback;
484 } 504 }
485 505
486 void CommandBufferProxyImpl::TryUpdateState() { 506 void CommandBufferProxyImpl::TryUpdateState() {
487 if (last_state_.error == gpu::error::kNoError) 507 if (last_state_.error == gpu::error::kNoError)
488 shared_state_->Read(&last_state_); 508 shared_state_->Read(&last_state_);
489 } 509 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/gpu_message_filter.cc ('k') | content/common/gpu/client/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698