OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/discardable_memory_allocator_android.h" | 5 #include "base/memory/discardable_memory_allocator_android.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 offset_(offset), | 65 offset_(offset), |
66 size_(size), | 66 size_(size), |
67 locked_(true) { | 67 locked_(true) { |
68 } | 68 } |
69 | 69 |
70 // Implemented below AshmemRegion since this requires the full definition of | 70 // Implemented below AshmemRegion since this requires the full definition of |
71 // AshmemRegion. | 71 // AshmemRegion. |
72 virtual ~DiscardableAshmemChunk(); | 72 virtual ~DiscardableAshmemChunk(); |
73 | 73 |
74 // DiscardableMemory: | 74 // DiscardableMemory: |
75 virtual LockDiscardableMemoryStatus Lock() OVERRIDE { | 75 virtual DiscardableMemoryLockStatus Lock() OVERRIDE { |
76 DCHECK(!locked_); | 76 DCHECK(!locked_); |
77 locked_ = true; | 77 locked_ = true; |
78 return internal::LockAshmemRegion(fd_, offset_, size_, address_); | 78 return internal::LockAshmemRegion(fd_, offset_, size_, address_); |
79 } | 79 } |
80 | 80 |
81 virtual void Unlock() OVERRIDE { | 81 virtual void Unlock() OVERRIDE { |
82 DCHECK(locked_); | 82 DCHECK(locked_); |
83 locked_ = false; | 83 locked_ = false; |
84 internal::UnlockAshmemRegion(fd_, offset_, size_, address_); | 84 internal::UnlockAshmemRegion(fd_, offset_, size_, address_); |
85 } | 85 } |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 DCHECK_LE(ashmem_regions_.size(), 5U); | 423 DCHECK_LE(ashmem_regions_.size(), 5U); |
424 const ScopedVector<AshmemRegion>::iterator it = std::find( | 424 const ScopedVector<AshmemRegion>::iterator it = std::find( |
425 ashmem_regions_.begin(), ashmem_regions_.end(), region); | 425 ashmem_regions_.begin(), ashmem_regions_.end(), region); |
426 DCHECK_NE(ashmem_regions_.end(), it); | 426 DCHECK_NE(ashmem_regions_.end(), it); |
427 std::swap(*it, ashmem_regions_.back()); | 427 std::swap(*it, ashmem_regions_.back()); |
428 ashmem_regions_.pop_back(); | 428 ashmem_regions_.pop_back(); |
429 } | 429 } |
430 | 430 |
431 } // namespace internal | 431 } // namespace internal |
432 } // namespace base | 432 } // namespace base |
OLD | NEW |