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

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

Issue 10081018: Revert 132218 - Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://svn.chromium.org/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
27 using gpu::Buffer; 23 using gpu::Buffer;
28 24
29 CommandBufferProxyImpl::CommandBufferProxyImpl( 25 CommandBufferProxyImpl::CommandBufferProxyImpl(
30 GpuChannelHost* channel, 26 GpuChannelHost* channel,
31 int route_id) 27 int route_id)
32 : channel_(channel), 28 : channel_(channel),
33 route_id_(route_id), 29 route_id_(route_id),
34 flush_count_(0), 30 flush_count_(0),
35 last_put_offset_(-1) { 31 last_put_offset_(-1) {
36 } 32 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 227
232 // Take ownership of shared memory. This will close the handle if Send below 228 // Take ownership of shared memory. This will close the handle if Send below
233 // fails. Otherwise, callee takes ownership before this variable 229 // fails. Otherwise, callee takes ownership before this variable
234 // goes out of scope by duping the handle. 230 // goes out of scope by duping the handle.
235 scoped_ptr<base::SharedMemory> shm( 231 scoped_ptr<base::SharedMemory> shm(
236 channel_->factory()->AllocateSharedMemory(size)); 232 channel_->factory()->AllocateSharedMemory(size));
237 if (!shm.get()) 233 if (!shm.get())
238 return -1; 234 return -1;
239 235
240 base::SharedMemoryHandle handle = shm->handle(); 236 base::SharedMemoryHandle handle = shm->handle();
241 #if defined(OS_WIN) 237 #if defined(OS_POSIX)
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)
248 DCHECK(!handle.auto_close); 238 DCHECK(!handle.auto_close);
249 #endif 239 #endif
250 240
251 int32 id; 241 int32 id;
252 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_, 242 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_,
253 handle, 243 handle,
254 size, 244 size,
255 id_request, 245 id_request,
256 &id))) { 246 &id))) {
257 return -1; 247 return -1;
258 } 248 }
259 249
260 return id; 250 return id;
261 } 251 }
262 252
263 int32 CommandBufferProxyImpl::RegisterTransferBuffer( 253 int32 CommandBufferProxyImpl::RegisterTransferBuffer(
264 base::SharedMemory* shared_memory, 254 base::SharedMemory* shared_memory,
265 size_t size, 255 size_t size,
266 int32 id_request) { 256 int32 id_request) {
267 if (last_state_.error != gpu::error::kNoError) 257 if (last_state_.error != gpu::error::kNoError)
268 return -1; 258 return -1;
269 259
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
280 int32 id; 260 int32 id;
281 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer( 261 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(
282 route_id_, 262 route_id_,
283 handle, 263 shared_memory->handle(), // Returns FileDescriptor with auto_close off.
284 size, 264 size,
285 id_request, 265 id_request,
286 &id))) { 266 &id))) {
287 return -1; 267 return -1;
288 } 268 }
289 269
290 return id; 270 return id;
291 } 271 }
292 272
293 void CommandBufferProxyImpl::DestroyTransferBuffer(int32 id) { 273 void CommandBufferProxyImpl::DestroyTransferBuffer(int32 id) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 480
501 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( 481 void CommandBufferProxyImpl::SetOnConsoleMessageCallback(
502 const GpuConsoleMessageCallback& callback) { 482 const GpuConsoleMessageCallback& callback) {
503 console_message_callback_ = callback; 483 console_message_callback_ = callback;
504 } 484 }
505 485
506 void CommandBufferProxyImpl::TryUpdateState() { 486 void CommandBufferProxyImpl::TryUpdateState() {
507 if (last_state_.error == gpu::error::kNoError) 487 if (last_state_.error == gpu::error::kNoError)
508 shared_state_->Read(&last_state_); 488 shared_state_->Read(&last_state_);
509 } 489 }
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