OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
6 | 6 |
7 #include <aclapi.h> | 7 #include <aclapi.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 if (process == GetCurrentProcess() && close_self) { | 300 if (process == GetCurrentProcess() && close_self) { |
301 *new_handle = SharedMemoryHandle(mapped_file, base::GetCurrentProcId()); | 301 *new_handle = SharedMemoryHandle(mapped_file, base::GetCurrentProcId()); |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process, &result, | 305 if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process, &result, |
306 access, FALSE, options)) { | 306 access, FALSE, options)) { |
307 return false; | 307 return false; |
308 } | 308 } |
309 *new_handle = SharedMemoryHandle(result, base::GetProcId(process)); | 309 *new_handle = SharedMemoryHandle(result, base::GetProcId(process)); |
| 310 new_handle->SetOwnershipPassesToIPC(true); |
310 return true; | 311 return true; |
311 } | 312 } |
312 | 313 |
313 | 314 |
314 void SharedMemory::Close() { | 315 void SharedMemory::Close() { |
315 if (mapped_file_ != NULL) { | 316 if (mapped_file_ != NULL) { |
316 ::CloseHandle(mapped_file_); | 317 ::CloseHandle(mapped_file_); |
317 mapped_file_ = NULL; | 318 mapped_file_ = NULL; |
318 } | 319 } |
319 } | 320 } |
320 | 321 |
321 SharedMemoryHandle SharedMemory::handle() const { | 322 SharedMemoryHandle SharedMemory::handle() const { |
322 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); | 323 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); |
323 } | 324 } |
324 | 325 |
325 } // namespace base | 326 } // namespace base |
OLD | NEW |