OLD | NEW |
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 Loading... |
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 |
OLD | NEW |