Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: base/memory/discardable_memory_mac.cc

Issue 195863005: Use DiscardableMemoryManager on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DiscardableMemoryAshmem + enable unit test on Android that exposes the bug Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698