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

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

Issue 257383004: Revert 267170 "Use DiscardableMemoryManager on Android." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 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_ASHMEM: 118 case DISCARDABLE_MEMORY_TYPE_ANDROID:
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() {
151 return true;
152 }
153
154 // static
150 void DiscardableMemory::PurgeForTesting() { 155 void DiscardableMemory::PurgeForTesting() {
151 int state = 0; 156 int state = 0;
152 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); 157 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state);
153 internal::DiscardableMemoryEmulated::PurgeForTesting(); 158 internal::DiscardableMemoryEmulated::PurgeForTesting();
154 } 159 }
155 160
156 } // namespace base 161 } // namespace base
OLDNEW
« no previous file with comments | « trunk/src/base/memory/discardable_memory_linux.cc ('k') | trunk/src/base/memory/discardable_memory_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698