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

Side by Side Diff: mojo/edk/embedder/platform_shared_buffer.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
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | mojo/edk/system/platform_wrapper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/edk/embedder/platform_shared_buffer.h" 5 #include "mojo/edk/embedder/platform_shared_buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 shared_memory_.reset(new base::SharedMemory); 231 shared_memory_.reset(new base::SharedMemory);
232 return shared_memory_->Create(options); 232 return shared_memory_->Create(options);
233 } 233 }
234 234
235 bool PlatformSharedBuffer::InitFromPlatformHandle( 235 bool PlatformSharedBuffer::InitFromPlatformHandle(
236 ScopedPlatformHandle platform_handle) { 236 ScopedPlatformHandle platform_handle) {
237 DCHECK(!shared_memory_); 237 DCHECK(!shared_memory_);
238 238
239 #if defined(OS_WIN) 239 #if defined(OS_WIN)
240 base::SharedMemoryHandle handle(platform_handle.release().handle, 240 base::SharedMemoryHandle handle(platform_handle.release().handle);
241 base::GetCurrentProcId());
242 #elif defined(OS_MACOSX) && !defined(OS_IOS) 241 #elif defined(OS_MACOSX) && !defined(OS_IOS)
243 base::SharedMemoryHandle handle; 242 base::SharedMemoryHandle handle;
244 handle = base::SharedMemoryHandle(platform_handle.release().port, num_bytes_, 243 handle = base::SharedMemoryHandle(platform_handle.release().port, num_bytes_);
245 base::GetCurrentProcId());
246 #else 244 #else
247 base::SharedMemoryHandle handle( 245 base::SharedMemoryHandle handle(
248 base::FileDescriptor(platform_handle.release().handle, false)); 246 base::FileDescriptor(platform_handle.release().handle, false));
249 #endif 247 #endif
250 248
251 shared_memory_.reset(new base::SharedMemory(handle, read_only_)); 249 shared_memory_.reset(new base::SharedMemory(handle, read_only_));
252 return true; 250 return true;
253 } 251 }
254 252
255 bool PlatformSharedBuffer::InitFromPlatformHandlePair( 253 bool PlatformSharedBuffer::InitFromPlatformHandlePair(
256 ScopedPlatformHandle rw_platform_handle, 254 ScopedPlatformHandle rw_platform_handle,
257 ScopedPlatformHandle ro_platform_handle) { 255 ScopedPlatformHandle ro_platform_handle) {
258 #if defined(OS_MACOSX) 256 #if defined(OS_MACOSX)
259 NOTREACHED(); 257 NOTREACHED();
260 return false; 258 return false;
261 #else // defined(OS_MACOSX) 259 #else // defined(OS_MACOSX)
262 260
263 #if defined(OS_WIN) 261 #if defined(OS_WIN)
264 base::SharedMemoryHandle handle(rw_platform_handle.release().handle, 262 base::SharedMemoryHandle handle(rw_platform_handle.release().handle);
265 base::GetCurrentProcId()); 263 base::SharedMemoryHandle ro_handle(ro_platform_handle.release().handle);
266 base::SharedMemoryHandle ro_handle(ro_platform_handle.release().handle,
267 base::GetCurrentProcId());
268 #else // defined(OS_WIN) 264 #else // defined(OS_WIN)
269 base::SharedMemoryHandle handle( 265 base::SharedMemoryHandle handle(
270 base::FileDescriptor(rw_platform_handle.release().handle, false)); 266 base::FileDescriptor(rw_platform_handle.release().handle, false));
271 base::SharedMemoryHandle ro_handle( 267 base::SharedMemoryHandle ro_handle(
272 base::FileDescriptor(ro_platform_handle.release().handle, false)); 268 base::FileDescriptor(ro_platform_handle.release().handle, false));
273 #endif // defined(OS_WIN) 269 #endif // defined(OS_WIN)
274 270
275 DCHECK(!shared_memory_); 271 DCHECK(!shared_memory_);
276 shared_memory_.reset(new base::SharedMemory(handle, false)); 272 shared_memory_.reset(new base::SharedMemory(handle, false));
277 ro_shared_memory_.reset(new base::SharedMemory(ro_handle, true)); 273 ro_shared_memory_.reset(new base::SharedMemory(ro_handle, true));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding; 326 base_ = static_cast<char*>(shared_memory_.memory()) + offset_rounding;
331 return true; 327 return true;
332 } 328 }
333 329
334 void PlatformSharedBufferMapping::Unmap() { 330 void PlatformSharedBufferMapping::Unmap() {
335 shared_memory_.Unmap(); 331 shared_memory_.Unmap();
336 } 332 }
337 333
338 } // namespace edk 334 } // namespace edk
339 } // namespace mojo 335 } // namespace mojo
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | mojo/edk/system/platform_wrapper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698