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

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 compilation issues on non-Android platforms 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
« no previous file with comments | « base/memory/discardable_memory_linux.cc ('k') | base/memory/discardable_memory_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 DISCARDABLE_MEMORY_TYPE_MALLOC 108 DISCARDABLE_MEMORY_TYPE_MALLOC
109 }; 109 };
110 types->assign(supported_types, supported_types + arraysize(supported_types)); 110 types->assign(supported_types, supported_types + arraysize(supported_types));
111 } 111 }
112 112
113 // static 113 // static
114 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType( 114 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
115 DiscardableMemoryType type, size_t size) { 115 DiscardableMemoryType type, size_t size) {
116 switch (type) { 116 switch (type) {
117 case DISCARDABLE_MEMORY_TYPE_NONE: 117 case DISCARDABLE_MEMORY_TYPE_NONE:
118 case DISCARDABLE_MEMORY_TYPE_ANDROID: 118 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
119 return scoped_ptr<DiscardableMemory>(); 119 return scoped_ptr<DiscardableMemory>();
120 case DISCARDABLE_MEMORY_TYPE_MAC: { 120 case DISCARDABLE_MEMORY_TYPE_MAC: {
121 scoped_ptr<DiscardableMemoryMac> memory(new DiscardableMemoryMac(size)); 121 scoped_ptr<DiscardableMemoryMac> memory(new DiscardableMemoryMac(size));
122 if (!memory->Initialize()) 122 if (!memory->Initialize())
123 return scoped_ptr<DiscardableMemory>(); 123 return scoped_ptr<DiscardableMemory>();
124 124
125 return memory.PassAs<DiscardableMemory>(); 125 return memory.PassAs<DiscardableMemory>();
126 } 126 }
127 case DISCARDABLE_MEMORY_TYPE_EMULATED: { 127 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
128 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 128 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
(...skipping 11 matching lines...) Expand all
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();
reveman 2014/04/28 16:02:24 if we add a type parameter then we shouldn't purge
Philippe 2014/04/28 16:31:22 Yes, that was a mistake. I got rid of the type tho
170 return;
171 }
172 default:
173 NOTREACHED();
174 }
159 } 175 }
160 176
161 } // namespace base 177 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_linux.cc ('k') | base/memory/discardable_memory_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698