OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_android.h" | 5 #include "base/memory/discardable_memory_android.h" |
6 | 6 |
7 #include <sys/mman.h> | 7 #include <sys/mman.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (failed) | 115 if (failed) |
116 DLOG(ERROR) << "Failed to unpin memory."; | 116 DLOG(ERROR) << "Failed to unpin memory."; |
117 // This allows us to catch accesses to unlocked memory. | 117 // This allows us to catch accesses to unlocked memory. |
118 DCHECK_EQ(0, mprotect(address, size, PROT_NONE)); | 118 DCHECK_EQ(0, mprotect(address, size, PROT_NONE)); |
119 return !failed; | 119 return !failed; |
120 } | 120 } |
121 | 121 |
122 } // namespace internal | 122 } // namespace internal |
123 | 123 |
124 // static | 124 // static |
125 void DiscardableMemory::RegisterMemoryPressureListeners() { | |
126 internal::DiscardableMemoryEmulated::RegisterMemoryPressureListeners(); | |
127 } | |
128 | |
129 // static | |
130 void DiscardableMemory::UnregisterMemoryPressureListeners() { | |
131 internal::DiscardableMemoryEmulated::UnregisterMemoryPressureListeners(); | |
132 } | |
133 | |
134 // static | |
135 void DiscardableMemory::GetSupportedTypes( | 125 void DiscardableMemory::GetSupportedTypes( |
136 std::vector<DiscardableMemoryType>* types) { | 126 std::vector<DiscardableMemoryType>* types) { |
137 const DiscardableMemoryType supported_types[] = { | 127 const DiscardableMemoryType supported_types[] = { |
138 DISCARDABLE_MEMORY_TYPE_ANDROID, | 128 DISCARDABLE_MEMORY_TYPE_ANDROID, |
139 DISCARDABLE_MEMORY_TYPE_EMULATED | 129 DISCARDABLE_MEMORY_TYPE_EMULATED |
140 }; | 130 }; |
141 types->assign(supported_types, supported_types + arraysize(supported_types)); | 131 types->assign(supported_types, supported_types + arraysize(supported_types)); |
142 } | 132 } |
143 | 133 |
144 // static | 134 // static |
(...skipping 24 matching lines...) Expand all Loading... |
169 bool DiscardableMemory::PurgeForTestingSupported() { | 159 bool DiscardableMemory::PurgeForTestingSupported() { |
170 return false; | 160 return false; |
171 } | 161 } |
172 | 162 |
173 // static | 163 // static |
174 void DiscardableMemory::PurgeForTesting() { | 164 void DiscardableMemory::PurgeForTesting() { |
175 NOTIMPLEMENTED(); | 165 NOTIMPLEMENTED(); |
176 } | 166 } |
177 | 167 |
178 } // namespace base | 168 } // namespace base |
OLD | NEW |