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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 Unmap(); | 370 Unmap(); |
371 } | 371 } |
372 | 372 |
373 if (process == GetCurrentProcess() && close_self) { | 373 if (process == GetCurrentProcess() && close_self) { |
374 *new_handle = SharedMemoryHandle(mapped_file, base::GetCurrentProcId()); | 374 *new_handle = SharedMemoryHandle(mapped_file, base::GetCurrentProcId()); |
375 return true; | 375 return true; |
376 } | 376 } |
377 | 377 |
378 if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process, &result, | 378 if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process, &result, |
379 access, FALSE, options)) { | 379 access, FALSE, options)) { |
| 380 // Debugging to help track down https://crbug.com/585013 |
| 381 DWORD last_error = ::GetLastError(); |
| 382 base::debug::Alias(&last_error); |
| 383 base::debug::DumpWithoutCrashing(); |
380 return false; | 384 return false; |
381 } | 385 } |
382 *new_handle = SharedMemoryHandle(result, base::GetProcId(process)); | 386 *new_handle = SharedMemoryHandle(result, base::GetProcId(process)); |
383 new_handle->SetOwnershipPassesToIPC(true); | 387 new_handle->SetOwnershipPassesToIPC(true); |
384 return true; | 388 return true; |
385 } | 389 } |
386 | 390 |
387 | 391 |
388 void SharedMemory::Close() { | 392 void SharedMemory::Close() { |
389 if (mapped_file_ != NULL) { | 393 if (mapped_file_ != NULL) { |
390 ::CloseHandle(mapped_file_); | 394 ::CloseHandle(mapped_file_); |
391 mapped_file_ = NULL; | 395 mapped_file_ = NULL; |
392 } | 396 } |
393 } | 397 } |
394 | 398 |
395 SharedMemoryHandle SharedMemory::handle() const { | 399 SharedMemoryHandle SharedMemory::handle() const { |
396 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); | 400 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); |
397 } | 401 } |
398 | 402 |
399 } // namespace base | 403 } // namespace base |
OLD | NEW |