| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 memory_ = NULL; | 291 memory_ = NULL; |
| 292 } | 292 } |
| 293 | 293 |
| 294 return mmap_succeeded; | 294 return mmap_succeeded; |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool SharedMemory::Unmap() { | 297 bool SharedMemory::Unmap() { |
| 298 if (memory_ == NULL) | 298 if (memory_ == NULL) |
| 299 return false; | 299 return false; |
| 300 | 300 |
| 301 SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); |
| 301 munmap(memory_, mapped_size_); | 302 munmap(memory_, mapped_size_); |
| 302 SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); | |
| 303 memory_ = NULL; | 303 memory_ = NULL; |
| 304 mapped_size_ = 0; | 304 mapped_size_ = 0; |
| 305 return true; | 305 return true; |
| 306 } | 306 } |
| 307 | 307 |
| 308 SharedMemoryHandle SharedMemory::handle() const { | 308 SharedMemoryHandle SharedMemory::handle() const { |
| 309 return shm_; | 309 return shm_; |
| 310 } | 310 } |
| 311 | 311 |
| 312 SharedMemoryHandle SharedMemory::TakeHandle() { | 312 SharedMemoryHandle SharedMemory::TakeHandle() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return true; | 353 return true; |
| 354 } | 354 } |
| 355 #endif // !defined(OS_ANDROID) | 355 #endif // !defined(OS_ANDROID) |
| 356 | 356 |
| 357 SharedMemoryHandle SharedMemory::GetReadOnlyHandle() { | 357 SharedMemoryHandle SharedMemory::GetReadOnlyHandle() { |
| 358 CHECK(readonly_shm_.IsValid()); | 358 CHECK(readonly_shm_.IsValid()); |
| 359 return readonly_shm_.Duplicate(); | 359 return readonly_shm_.Duplicate(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace base | 362 } // namespace base |
| OLD | NEW |