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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 offset_(offset), | 63 offset_(offset), |
64 size_(size), | 64 size_(size), |
65 locked_(true) { | 65 locked_(true) { |
66 } | 66 } |
67 | 67 |
68 // Implemented below AshmemRegion since this requires the full definition of | 68 // Implemented below AshmemRegion since this requires the full definition of |
69 // AshmemRegion. | 69 // AshmemRegion. |
70 virtual ~DiscardableAshmemChunk(); | 70 virtual ~DiscardableAshmemChunk(); |
71 | 71 |
72 // DiscardableMemory: | 72 // DiscardableMemory: |
73 virtual LockDiscardableMemoryStatus Lock() OVERRIDE { | 73 virtual DiscardableMemoryLockStatus Lock() OVERRIDE { |
74 DCHECK(!locked_); | 74 DCHECK(!locked_); |
75 locked_ = true; | 75 locked_ = true; |
76 return internal::LockAshmemRegion(fd_, offset_, size_, address_); | 76 return internal::LockAshmemRegion(fd_, offset_, size_, address_); |
77 } | 77 } |
78 | 78 |
79 virtual void Unlock() OVERRIDE { | 79 virtual void Unlock() OVERRIDE { |
80 DCHECK(locked_); | 80 DCHECK(locked_); |
81 locked_ = false; | 81 locked_ = false; |
82 internal::UnlockAshmemRegion(fd_, offset_, size_, address_); | 82 internal::UnlockAshmemRegion(fd_, offset_, size_, address_); |
83 } | 83 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 DCHECK_LE(ashmem_regions_.size(), 5U); | 409 DCHECK_LE(ashmem_regions_.size(), 5U); |
410 const ScopedVector<AshmemRegion>::iterator it = std::find( | 410 const ScopedVector<AshmemRegion>::iterator it = std::find( |
411 ashmem_regions_.begin(), ashmem_regions_.end(), region); | 411 ashmem_regions_.begin(), ashmem_regions_.end(), region); |
412 DCHECK_NE(ashmem_regions_.end(), it); | 412 DCHECK_NE(ashmem_regions_.end(), it); |
413 std::swap(*it, ashmem_regions_.back()); | 413 std::swap(*it, ashmem_regions_.back()); |
414 ashmem_regions_.pop_back(); | 414 ashmem_regions_.pop_back(); |
415 } | 415 } |
416 | 416 |
417 } // namespace internal | 417 } // namespace internal |
418 } // namespace base | 418 } // namespace base |
OLD | NEW |