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

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

Issue 655003004: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 types->assign(supported_types, supported_types + arraysize(supported_types)); 169 types->assign(supported_types, supported_types + arraysize(supported_types));
170 } 170 }
171 171
172 // static 172 // static
173 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType( 173 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
174 DiscardableMemoryType type, size_t size) { 174 DiscardableMemoryType type, size_t size) {
175 switch (type) { 175 switch (type) {
176 case DISCARDABLE_MEMORY_TYPE_MAC: { 176 case DISCARDABLE_MEMORY_TYPE_MAC: {
177 scoped_ptr<DiscardableMemoryMac> memory(new DiscardableMemoryMac(size)); 177 scoped_ptr<DiscardableMemoryMac> memory(new DiscardableMemoryMac(size));
178 if (!memory->Initialize()) 178 if (!memory->Initialize())
179 return scoped_ptr<DiscardableMemory>(); 179 return nullptr;
180 180
181 return memory.PassAs<DiscardableMemory>(); 181 return memory.Pass();
182 } 182 }
183 case DISCARDABLE_MEMORY_TYPE_EMULATED: { 183 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
184 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 184 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
185 new internal::DiscardableMemoryEmulated(size)); 185 new internal::DiscardableMemoryEmulated(size));
186 if (!memory->Initialize()) 186 if (!memory->Initialize())
187 return scoped_ptr<DiscardableMemory>(); 187 return nullptr;
188 188
189 return memory.PassAs<DiscardableMemory>(); 189 return memory.Pass();
190 } 190 }
191 case DISCARDABLE_MEMORY_TYPE_NONE: 191 case DISCARDABLE_MEMORY_TYPE_NONE:
192 case DISCARDABLE_MEMORY_TYPE_ASHMEM: 192 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
193 NOTREACHED(); 193 NOTREACHED();
194 return scoped_ptr<DiscardableMemory>(); 194 return nullptr;
195 } 195 }
196 196
197 NOTREACHED(); 197 NOTREACHED();
198 return scoped_ptr<DiscardableMemory>(); 198 return nullptr;
199 } 199 }
200 200
201 // static 201 // static
202 void DiscardableMemory::PurgeForTesting() { 202 void DiscardableMemory::PurgeForTesting() {
203 int state = 0; 203 int state = 0;
204 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); 204 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state);
205 internal::DiscardableMemoryEmulated::PurgeForTesting(); 205 internal::DiscardableMemoryEmulated::PurgeForTesting();
206 } 206 }
207 207
208 } // namespace base 208 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698