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

Side by Side Diff: mojo/public/cpp/system/platform_handle.cc

Issue 2849243002: Get rid of all pid references from base::SharedMemoryHandle. (Closed)
Patch Set: fix invalid handle Chrome IPC. Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mojo/public/cpp/system/platform_handle.h" 5 #include "mojo/public/cpp/system/platform_handle.h"
6 6
7 #if defined(OS_MACOSX) && !defined(OS_IOS) 7 #if defined(OS_MACOSX) && !defined(OS_IOS)
8 #include <mach/mach.h> 8 #include <mach/mach.h>
9 #include "base/mac/mach_logging.h" 9 #include "base/mac/mach_logging.h"
10 #endif 10 #endif
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 if (size) 111 if (size)
112 *size = num_bytes; 112 *size = num_bytes;
113 113
114 if (read_only) 114 if (read_only)
115 *read_only = flags & MOJO_PLATFORM_SHARED_BUFFER_HANDLE_FLAG_READ_ONLY; 115 *read_only = flags & MOJO_PLATFORM_SHARED_BUFFER_HANDLE_FLAG_READ_ONLY;
116 116
117 #if defined(OS_MACOSX) && !defined(OS_IOS) 117 #if defined(OS_MACOSX) && !defined(OS_IOS)
118 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT); 118 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
119 *memory_handle = base::SharedMemoryHandle( 119 *memory_handle = base::SharedMemoryHandle(
120 static_cast<mach_port_t>(platform_handle.value), num_bytes, 120 static_cast<mach_port_t>(platform_handle.value), num_bytes);
121 base::GetCurrentProcId());
122 #elif defined(OS_POSIX) 121 #elif defined(OS_POSIX)
123 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR); 122 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR);
124 *memory_handle = base::SharedMemoryHandle( 123 *memory_handle = base::SharedMemoryHandle(
125 base::FileDescriptor(static_cast<int>(platform_handle.value), false)); 124 base::FileDescriptor(static_cast<int>(platform_handle.value), false));
126 #elif defined(OS_WIN) 125 #elif defined(OS_WIN)
127 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE); 126 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE);
128 *memory_handle = base::SharedMemoryHandle( 127 *memory_handle =
129 reinterpret_cast<HANDLE>(platform_handle.value), 128 base::SharedMemoryHandle(reinterpret_cast<HANDLE>(platform_handle.value));
130 base::GetCurrentProcId());
131 #endif 129 #endif
132 130
133 return MOJO_RESULT_OK; 131 return MOJO_RESULT_OK;
134 } 132 }
135 133
136 #if defined(OS_MACOSX) && !defined(OS_IOS) 134 #if defined(OS_MACOSX) && !defined(OS_IOS)
137 ScopedHandle WrapMachPort(mach_port_t port) { 135 ScopedHandle WrapMachPort(mach_port_t port) {
138 kern_return_t kr = 136 kern_return_t kr =
139 mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1); 137 mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1);
140 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) 138 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
(...skipping 21 matching lines...) Expand all
162 if (result != MOJO_RESULT_OK) 160 if (result != MOJO_RESULT_OK)
163 return result; 161 return result;
164 162
165 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT); 163 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
166 *port = static_cast<mach_port_t>(platform_handle.value); 164 *port = static_cast<mach_port_t>(platform_handle.value);
167 return MOJO_RESULT_OK; 165 return MOJO_RESULT_OK;
168 } 166 }
169 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 167 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
170 168
171 } // namespace mojo 169 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/platform_wrapper_unittest.cc ('k') | sandbox/win/src/process_mitigations_win32k_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698