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

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

Issue 1152273005: Prepare gpu_channel_host for SharedMemoryHandles not backed by POSIX fds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gpu_channel_host.h" 5 #include "content/common/gpu/client/gpu_channel_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/posix/eintr_wrapper.h" 11 #include "base/posix/eintr_wrapper.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "content/common/gpu/client/command_buffer_proxy_impl.h" 16 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
17 #include "content/common/gpu/gpu_messages.h" 17 #include "content/common/gpu/gpu_messages.h"
18 #include "ipc/ipc_sync_message_filter.h" 18 #include "ipc/ipc_sync_message_filter.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 #if defined(OS_WIN) 21 #if defined(OS_WIN) || defined(OS_MACOSX)
22 #include "content/public/common/sandbox_init.h" 22 #include "content/public/common/sandbox_init.h"
23 #endif 23 #endif
24 24
25 using base::AutoLock; 25 using base::AutoLock;
26 26
27 namespace content { 27 namespace content {
28 28
29 GpuListenerInfo::GpuListenerInfo() {} 29 GpuListenerInfo::GpuListenerInfo() {}
30 30
31 GpuListenerInfo::~GpuListenerInfo() {} 31 GpuListenerInfo::~GpuListenerInfo() {}
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 io_task_runner->PostTask( 296 io_task_runner->PostTask(
297 FROM_HERE, base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, 297 FROM_HERE, base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute,
298 channel_filter_.get(), route_id)); 298 channel_filter_.get(), route_id));
299 } 299 }
300 300
301 base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess( 301 base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess(
302 base::SharedMemoryHandle source_handle) { 302 base::SharedMemoryHandle source_handle) {
303 if (IsLost()) 303 if (IsLost())
304 return base::SharedMemory::NULLHandle(); 304 return base::SharedMemory::NULLHandle();
305 305
306 #if defined(OS_WIN) 306 #if defined(OS_WIN) || defined(OS_MACOSX)
307 // Windows needs to explicitly duplicate the handle out to another process. 307 // Windows needs to explicitly duplicate the handle out to another process.
308 base::SharedMemoryHandle target_handle; 308 base::SharedMemoryHandle target_handle;
309 base::ProcessId peer_pid; 309 base::ProcessId peer_pid;
310 { 310 {
311 AutoLock lock(context_lock_); 311 AutoLock lock(context_lock_);
312 if (!channel_) 312 if (!channel_)
313 return base::SharedMemory::NULLHandle(); 313 return base::SharedMemory::NULLHandle();
314 peer_pid = channel_->GetPeerPID(); 314 peer_pid = channel_->GetPeerPID();
315 } 315 }
316 if (!BrokerDuplicateHandle(source_handle, 316 bool success = BrokerDuplicateSharedMemoryHandle(source_handle, peer_pid,
317 peer_pid, 317 &target_handle);
318 &target_handle, 318 if (!success)
319 FILE_GENERIC_READ | FILE_GENERIC_WRITE,
320 0)) {
321 return base::SharedMemory::NULLHandle(); 319 return base::SharedMemory::NULLHandle();
322 }
323 320
324 return target_handle; 321 return target_handle;
325 #else 322 #else
326 int duped_handle = HANDLE_EINTR(dup(source_handle.fd)); 323 return base::SharedMemory::Duplicatehandle(source_handle);
jbauman 2015/06/03 22:01:41 incorrect capitalization of DuplicateHandle.
erikchen 2015/06/03 22:03:01 Done.
327 if (duped_handle < 0) 324 #endif // defined(OS_WIN) || defined(OS_MACOSX)
328 return base::SharedMemory::NULLHandle();
329
330 return base::FileDescriptor(duped_handle, true);
331 #endif
332 } 325 }
333 326
334 int32 GpuChannelHost::ReserveTransferBufferId() { 327 int32 GpuChannelHost::ReserveTransferBufferId() {
335 return next_transfer_buffer_id_.GetNext(); 328 return next_transfer_buffer_id_.GetNext();
336 } 329 }
337 330
338 gfx::GpuMemoryBufferHandle GpuChannelHost::ShareGpuMemoryBufferToGpuProcess( 331 gfx::GpuMemoryBufferHandle GpuChannelHost::ShareGpuMemoryBufferToGpuProcess(
339 const gfx::GpuMemoryBufferHandle& source_handle, 332 const gfx::GpuMemoryBufferHandle& source_handle,
340 bool* requires_sync_point) { 333 bool* requires_sync_point) {
341 switch (source_handle.type) { 334 switch (source_handle.type) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 429
437 listeners_.clear(); 430 listeners_.clear();
438 } 431 }
439 432
440 bool GpuChannelHost::MessageFilter::IsLost() const { 433 bool GpuChannelHost::MessageFilter::IsLost() const {
441 AutoLock lock(lock_); 434 AutoLock lock(lock_);
442 return lost_; 435 return lost_;
443 } 436 }
444 437
445 } // namespace content 438 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698