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

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

Issue 195863005: Use DiscardableMemoryManager on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add |DiscardableMemoryAshmem::is_locked| 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/discardable_memory_emulated.h" 8 #include "base/memory/discardable_memory_emulated.h"
9 #include "base/memory/discardable_memory_malloc.h" 9 #include "base/memory/discardable_memory_malloc.h"
10 10
(...skipping 17 matching lines...) Expand all
28 DISCARDABLE_MEMORY_TYPE_MALLOC 28 DISCARDABLE_MEMORY_TYPE_MALLOC
29 }; 29 };
30 types->assign(supported_types, supported_types + arraysize(supported_types)); 30 types->assign(supported_types, supported_types + arraysize(supported_types));
31 } 31 }
32 32
33 // static 33 // static
34 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType( 34 scoped_ptr<DiscardableMemory> DiscardableMemory::CreateLockedMemoryWithType(
35 DiscardableMemoryType type, size_t size) { 35 DiscardableMemoryType type, size_t size) {
36 switch (type) { 36 switch (type) {
37 case DISCARDABLE_MEMORY_TYPE_NONE: 37 case DISCARDABLE_MEMORY_TYPE_NONE:
38 case DISCARDABLE_MEMORY_TYPE_ANDROID: 38 case DISCARDABLE_MEMORY_TYPE_ASHMEM:
39 case DISCARDABLE_MEMORY_TYPE_MAC: 39 case DISCARDABLE_MEMORY_TYPE_MAC:
40 return scoped_ptr<DiscardableMemory>(); 40 return scoped_ptr<DiscardableMemory>();
41 case DISCARDABLE_MEMORY_TYPE_EMULATED: { 41 case DISCARDABLE_MEMORY_TYPE_EMULATED: {
42 scoped_ptr<internal::DiscardableMemoryEmulated> memory( 42 scoped_ptr<internal::DiscardableMemoryEmulated> memory(
43 new internal::DiscardableMemoryEmulated(size)); 43 new internal::DiscardableMemoryEmulated(size));
44 if (!memory->Initialize()) 44 if (!memory->Initialize())
45 return scoped_ptr<DiscardableMemory>(); 45 return scoped_ptr<DiscardableMemory>();
46 46
47 return memory.PassAs<DiscardableMemory>(); 47 return memory.PassAs<DiscardableMemory>();
48 } 48 }
49 case DISCARDABLE_MEMORY_TYPE_MALLOC: { 49 case DISCARDABLE_MEMORY_TYPE_MALLOC: {
50 scoped_ptr<internal::DiscardableMemoryMalloc> memory( 50 scoped_ptr<internal::DiscardableMemoryMalloc> memory(
51 new internal::DiscardableMemoryMalloc(size)); 51 new internal::DiscardableMemoryMalloc(size));
52 if (!memory->Initialize()) 52 if (!memory->Initialize())
53 return scoped_ptr<DiscardableMemory>(); 53 return scoped_ptr<DiscardableMemory>();
54 54
55 return memory.PassAs<DiscardableMemory>(); 55 return memory.PassAs<DiscardableMemory>();
56 } 56 }
57 } 57 }
58 58
59 NOTREACHED(); 59 NOTREACHED();
60 return scoped_ptr<DiscardableMemory>(); 60 return scoped_ptr<DiscardableMemory>();
61 } 61 }
62 62
63 // static 63 // static
64 bool DiscardableMemory::PurgeForTestingSupported() {
65 return true;
66 }
67
68 // static
69 void DiscardableMemory::PurgeForTesting() { 64 void DiscardableMemory::PurgeForTesting() {
70 internal::DiscardableMemoryEmulated::PurgeForTesting(); 65 internal::DiscardableMemoryEmulated::PurgeForTesting();
71 } 66 }
72 67
73 } // namespace base 68 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698