OLD | NEW |
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) | 23 #if defined(OS_WIN) |
24 #include "content/common/sandbox_policy.h" | 24 #include "content/public/common/sandbox_init.h" |
25 #endif | 25 #endif |
26 | 26 |
27 using gpu::Buffer; | 27 using gpu::Buffer; |
28 | 28 |
29 CommandBufferProxyImpl::CommandBufferProxyImpl( | 29 CommandBufferProxyImpl::CommandBufferProxyImpl( |
30 GpuChannelHost* channel, | 30 GpuChannelHost* channel, |
31 int route_id) | 31 int route_id) |
32 : channel_(channel), | 32 : channel_(channel), |
33 route_id_(route_id), | 33 route_id_(route_id), |
34 flush_count_(0), | 34 flush_count_(0), |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // fails. Otherwise, callee takes ownership before this variable | 233 // fails. Otherwise, callee takes ownership before this variable |
234 // goes out of scope by duping the handle. | 234 // goes out of scope by duping the handle. |
235 scoped_ptr<base::SharedMemory> shm( | 235 scoped_ptr<base::SharedMemory> shm( |
236 channel_->factory()->AllocateSharedMemory(size)); | 236 channel_->factory()->AllocateSharedMemory(size)); |
237 if (!shm.get()) | 237 if (!shm.get()) |
238 return -1; | 238 return -1; |
239 | 239 |
240 base::SharedMemoryHandle handle = shm->handle(); | 240 base::SharedMemoryHandle handle = shm->handle(); |
241 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
242 // Windows needs to explicitly duplicate the handle out to another process. | 242 // Windows needs to explicitly duplicate the handle out to another process. |
243 if (!sandbox::BrokerDuplicateHandle(handle, channel_->gpu_pid(), | 243 if (!content::BrokerDuplicateHandle(handle, channel_->gpu_pid(), |
244 &handle, FILE_MAP_WRITE, 0)) { | 244 &handle, FILE_MAP_WRITE, 0)) { |
245 return -1; | 245 return -1; |
246 } | 246 } |
247 #elif defined(OS_POSIX) | 247 #elif defined(OS_POSIX) |
248 DCHECK(!handle.auto_close); | 248 DCHECK(!handle.auto_close); |
249 #endif | 249 #endif |
250 | 250 |
251 int32 id; | 251 int32 id; |
252 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_, | 252 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_, |
253 handle, | 253 handle, |
(...skipping 10 matching lines...) Expand all Loading... |
264 base::SharedMemory* shared_memory, | 264 base::SharedMemory* shared_memory, |
265 size_t size, | 265 size_t size, |
266 int32 id_request) { | 266 int32 id_request) { |
267 if (last_state_.error != gpu::error::kNoError) | 267 if (last_state_.error != gpu::error::kNoError) |
268 return -1; | 268 return -1; |
269 | 269 |
270 // Returns FileDescriptor with auto_close off. | 270 // Returns FileDescriptor with auto_close off. |
271 base::SharedMemoryHandle handle = shared_memory->handle(); | 271 base::SharedMemoryHandle handle = shared_memory->handle(); |
272 #if defined(OS_WIN) | 272 #if defined(OS_WIN) |
273 // Windows needs to explicitly duplicate the handle out to another process. | 273 // Windows needs to explicitly duplicate the handle out to another process. |
274 if (!sandbox::BrokerDuplicateHandle(handle, channel_->gpu_pid(), | 274 if (!content::BrokerDuplicateHandle(handle, channel_->gpu_pid(), |
275 &handle, FILE_MAP_WRITE, 0)) { | 275 &handle, FILE_MAP_WRITE, 0)) { |
276 return -1; | 276 return -1; |
277 } | 277 } |
278 #endif | 278 #endif |
279 | 279 |
280 int32 id; | 280 int32 id; |
281 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer( | 281 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer( |
282 route_id_, | 282 route_id_, |
283 handle, | 283 handle, |
284 size, | 284 size, |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 500 |
501 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( | 501 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( |
502 const GpuConsoleMessageCallback& callback) { | 502 const GpuConsoleMessageCallback& callback) { |
503 console_message_callback_ = callback; | 503 console_message_callback_ = callback; |
504 } | 504 } |
505 | 505 |
506 void CommandBufferProxyImpl::TryUpdateState() { | 506 void CommandBufferProxyImpl::TryUpdateState() { |
507 if (last_state_.error == gpu::error::kNoError) | 507 if (last_state_.error == gpu::error::kNoError) |
508 shared_state_->Read(&last_state_); | 508 shared_state_->Read(&last_state_); |
509 } | 509 } |
OLD | NEW |