OLD | NEW |
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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 GetOptimalAshmemRegionSizeForAllocator()) {} | 37 GetOptimalAshmemRegionSizeForAllocator()) {} |
38 | 38 |
39 internal::DiscardableMemoryManager manager; | 39 internal::DiscardableMemoryManager manager; |
40 internal::DiscardableMemoryAshmemAllocator allocator; | 40 internal::DiscardableMemoryAshmemAllocator allocator; |
41 }; | 41 }; |
42 LazyInstance<SharedState>::Leaky g_shared_state = LAZY_INSTANCE_INITIALIZER; | 42 LazyInstance<SharedState>::Leaky g_shared_state = LAZY_INSTANCE_INITIALIZER; |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 // static | 46 // static |
47 void DiscardableMemory::ReleaseFreeMemory() { | |
48 internal::DiscardableMemoryShmem::ReleaseFreeMemory(); | |
49 } | |
50 | |
51 // static | |
52 bool DiscardableMemory::ReduceMemoryUsage() { | 47 bool DiscardableMemory::ReduceMemoryUsage() { |
53 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage(); | 48 return internal::DiscardableMemoryEmulated::ReduceMemoryUsage(); |
54 } | 49 } |
55 | 50 |
56 // static | 51 // static |
57 void DiscardableMemory::GetSupportedTypes( | 52 void DiscardableMemory::GetSupportedTypes( |
58 std::vector<DiscardableMemoryType>* types) { | 53 std::vector<DiscardableMemoryType>* types) { |
59 const DiscardableMemoryType supported_types[] = { | 54 const DiscardableMemoryType supported_types[] = { |
60 DISCARDABLE_MEMORY_TYPE_ASHMEM, | 55 DISCARDABLE_MEMORY_TYPE_ASHMEM, |
61 DISCARDABLE_MEMORY_TYPE_EMULATED, | 56 DISCARDABLE_MEMORY_TYPE_EMULATED, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 case DISCARDABLE_MEMORY_TYPE_NONE: | 92 case DISCARDABLE_MEMORY_TYPE_NONE: |
98 case DISCARDABLE_MEMORY_TYPE_MACH: | 93 case DISCARDABLE_MEMORY_TYPE_MACH: |
99 NOTREACHED(); | 94 NOTREACHED(); |
100 return nullptr; | 95 return nullptr; |
101 } | 96 } |
102 | 97 |
103 NOTREACHED(); | 98 NOTREACHED(); |
104 return nullptr; | 99 return nullptr; |
105 } | 100 } |
106 | 101 |
107 // static | |
108 void DiscardableMemory::PurgeForTesting() { | |
109 g_shared_state.Pointer()->manager.PurgeAll(); | |
110 internal::DiscardableMemoryEmulated::PurgeForTesting(); | |
111 internal::DiscardableMemoryShmem::PurgeForTesting(); | |
112 } | |
113 | |
114 } // namespace base | 102 } // namespace base |
OLD | NEW |