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

Side by Side Diff: content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc

Issue 1166443004: Further clean up pepper's use of SharedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: Fix compile error on windows. 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
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/renderer/pepper/pepper_proxy_channel_delegate_impl.h" 5 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
6 6
7 #include "content/child/child_process.h" 7 #include "content/child/child_process.h"
8 #include "content/common/sandbox_util.h" 8 #include "content/common/sandbox_util.h"
9 9
10 #if defined(OS_WIN) || defined(OS_MACOSX)
11 #include "content/public/common/sandbox_init.h"
12 #endif // defined(OS_WIN) || defined(OS_MACOSX)
13
10 namespace content { 14 namespace content {
11 15
12 PepperProxyChannelDelegateImpl::~PepperProxyChannelDelegateImpl() {} 16 PepperProxyChannelDelegateImpl::~PepperProxyChannelDelegateImpl() {}
13 17
14 base::SingleThreadTaskRunner* 18 base::SingleThreadTaskRunner*
15 PepperProxyChannelDelegateImpl::GetIPCTaskRunner() { 19 PepperProxyChannelDelegateImpl::GetIPCTaskRunner() {
16 // This is called only in the renderer so we know we have a child process. 20 // This is called only in the renderer so we know we have a child process.
17 DCHECK(ChildProcess::current()) << "Must be in the renderer."; 21 DCHECK(ChildProcess::current()) << "Must be in the renderer.";
18 return ChildProcess::current()->io_task_runner(); 22 return ChildProcess::current()->io_task_runner();
19 } 23 }
20 24
21 base::WaitableEvent* PepperProxyChannelDelegateImpl::GetShutdownEvent() { 25 base::WaitableEvent* PepperProxyChannelDelegateImpl::GetShutdownEvent() {
22 DCHECK(ChildProcess::current()) << "Must be in the renderer."; 26 DCHECK(ChildProcess::current()) << "Must be in the renderer.";
23 return ChildProcess::current()->GetShutDownEvent(); 27 return ChildProcess::current()->GetShutDownEvent();
24 } 28 }
25 29
26 IPC::PlatformFileForTransit 30 IPC::PlatformFileForTransit
27 PepperProxyChannelDelegateImpl::ShareHandleWithRemote( 31 PepperProxyChannelDelegateImpl::ShareHandleWithRemote(
28 base::PlatformFile handle, 32 base::PlatformFile handle,
29 base::ProcessId remote_pid, 33 base::ProcessId remote_pid,
30 bool should_close_source) { 34 bool should_close_source) {
31 return BrokerGetFileHandleForProcess(handle, remote_pid, should_close_source); 35 return BrokerGetFileHandleForProcess(handle, remote_pid, should_close_source);
32 } 36 }
33 37
34 base::SharedMemoryHandle 38 base::SharedMemoryHandle
35 PepperProxyChannelDelegateImpl::ShareSharedMemoryHandleWithRemote( 39 PepperProxyChannelDelegateImpl::ShareSharedMemoryHandleWithRemote(
36 const base::SharedMemoryHandle& handle, 40 const base::SharedMemoryHandle& handle,
37 base::ProcessId remote_pid) { 41 base::ProcessId remote_pid) {
38 base::PlatformFile local_platform_file = 42 #if defined(OS_WIN) || defined(OS_MACOSX)
39 #if defined(OS_POSIX) 43 base::SharedMemoryHandle duped_handle;
piman 2015/06/03 17:44:44 nit: just initialize this with base::SharedMemory:
40 handle.fd; 44 bool success =
41 #elif defined(OS_WIN) 45 BrokerDuplicateSharedMemoryHandle(handle, remote_pid, &duped_handle);
42 handle; 46 if (success)
47 return duped_handle;
48 return base::SharedMemory::NULLHandle();
43 #else 49 #else
44 #error Not implemented. 50 return base::SharedMemory::DuplicateHandle(handle);
45 #endif 51 #endif // defined(OS_WIN) || defined(OS_MACOSX)
46 return ShareHandleWithRemote(local_platform_file, remote_pid, false);
47 } 52 }
48 53
49 } // namespace content 54 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698