Chromium Code Reviews| Index: base/memory/shared_memory_posix.cc |
| diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc |
| index 3a18faa83dd70e82c8381d33cc247afa270339a9..f0018c333fff52ccfcc63dac4764e7e64b1e976d 100644 |
| --- a/base/memory/shared_memory_posix.cc |
| +++ b/base/memory/shared_memory_posix.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/files/scoped_file.h" |
| #include "base/logging.h" |
| #include "base/memory/shared_memory_helper.h" |
| +#include "base/memory/shared_memory_tracker.h" |
| #include "base/posix/eintr_wrapper.h" |
| #include "base/posix/safe_strerror.h" |
| #include "base/process/process_metrics.h" |
| @@ -283,8 +284,10 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { |
| bool mmap_succeeded = memory_ != (void*)-1 && memory_ != NULL; |
| if (mmap_succeeded) { |
| mapped_size_ = bytes; |
| - DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) & |
| - (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1)); |
| + DCHECK_EQ(0U, |
| + reinterpret_cast<uintptr_t>(memory_) & |
| + (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1)); |
| + SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this); |
| } else { |
| memory_ = NULL; |
| } |
| @@ -297,6 +300,7 @@ bool SharedMemory::Unmap() { |
| return false; |
| munmap(memory_, mapped_size_); |
| + SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); |
| memory_ = NULL; |
| mapped_size_ = 0; |
| return true; |
| @@ -390,4 +394,14 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process, |
| return true; |
| } |
| +bool SharedMemory::GetUniqueId(SharedMemory::UniqueId* id) const { |
| + base::ThreadRestrictions::AssertIOAllowed(); |
| + struct stat file_stat; |
| + if (fstat(static_cast<int>(handle().fd), &file_stat) != 0) |
|
Primiano Tucci (use gerrit)
2017/02/27 14:10:50
as this is a I/O syscall it might be safer to wrap
hajimehoshi
2017/02/28 06:59:25
Done (Darwin doesn't reach here anyway).
|
| + return false; |
| + id->first = file_stat.st_dev; |
| + id->second = file_stat.st_ino; |
| + return true; |
| +} |
| + |
| } // namespace base |