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.h" | 5 #include "base/memory/discardable_memory.h" |
6 | 6 |
7 #include <mach/mach.h> | 7 #include <mach/mach.h> |
8 #include <sys/mman.h> | 8 #include <sys/mman.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 return memory.PassAs<DiscardableMemory>(); | 141 return memory.PassAs<DiscardableMemory>(); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 NOTREACHED(); | 145 NOTREACHED(); |
146 return scoped_ptr<DiscardableMemory>(); | 146 return scoped_ptr<DiscardableMemory>(); |
147 } | 147 } |
148 | 148 |
149 // static | 149 // static |
150 bool DiscardableMemory::PurgeForTestingSupported() { | 150 bool DiscardableMemory::PurgeForTestingSupported(DiscardableMemoryType type) { |
151 return true; | 151 switch (type) { |
| 152 case DISCARDABLE_MEMORY_TYPE_EMULATED: |
| 153 case DISCARDABLE_MEMORY_TYPE_MAC: |
| 154 return true; |
| 155 default: |
| 156 return false; |
| 157 } |
152 } | 158 } |
153 | 159 |
154 // static | 160 // static |
155 void DiscardableMemory::PurgeForTesting() { | 161 void DiscardableMemory::PurgeForTesting(DiscardableMemoryType type) { |
156 int state = 0; | 162 switch (type) { |
157 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); | 163 case DISCARDABLE_MEMORY_TYPE_EMULATED: |
158 internal::DiscardableMemoryEmulated::PurgeForTesting(); | 164 internal::DiscardableMemoryEmulated::PurgeForTesting(); |
| 165 return; |
| 166 case DISCARDABLE_MEMORY_TYPE_MAC: { |
| 167 int state = 0; |
| 168 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); |
| 169 internal::DiscardableMemoryEmulated::PurgeForTesting(); |
| 170 return; |
| 171 } |
| 172 default: |
| 173 NOTREACHED(); |
| 174 } |
159 } | 175 } |
160 | 176 |
161 } // namespace base | 177 } // namespace base |
OLD | NEW |