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 <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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 private: | 82 private: |
83 vm_address_t buffer_; | 83 vm_address_t buffer_; |
84 const size_t size_; | 84 const size_t size_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMac); | 86 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryMac); |
87 }; | 87 }; |
88 | 88 |
89 } // namespace | 89 } // namespace |
90 | 90 |
91 // static | 91 // static |
92 void DiscardableMemory::RegisterMemoryPressureListeners() { | |
93 internal::DiscardableMemoryEmulated::RegisterMemoryPressureListeners(); | |
94 } | |
95 | |
96 // static | |
97 void DiscardableMemory::UnregisterMemoryPressureListeners() { | |
98 internal::DiscardableMemoryEmulated::UnregisterMemoryPressureListeners(); | |
99 } | |
100 | |
101 // static | |
102 void DiscardableMemory::GetSupportedTypes( | 92 void DiscardableMemory::GetSupportedTypes( |
103 std::vector<DiscardableMemoryType>* types) { | 93 std::vector<DiscardableMemoryType>* types) { |
104 const DiscardableMemoryType supported_types[] = { | 94 const DiscardableMemoryType supported_types[] = { |
105 DISCARDABLE_MEMORY_TYPE_MAC, | 95 DISCARDABLE_MEMORY_TYPE_MAC, |
106 DISCARDABLE_MEMORY_TYPE_EMULATED | 96 DISCARDABLE_MEMORY_TYPE_EMULATED |
107 }; | 97 }; |
108 types->assign(supported_types, supported_types + arraysize(supported_types)); | 98 types->assign(supported_types, supported_types + arraysize(supported_types)); |
109 } | 99 } |
110 | 100 |
111 // static | 101 // static |
(...skipping 30 matching lines...) Expand all Loading... |
142 } | 132 } |
143 | 133 |
144 // static | 134 // static |
145 void DiscardableMemory::PurgeForTesting() { | 135 void DiscardableMemory::PurgeForTesting() { |
146 int state = 0; | 136 int state = 0; |
147 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); | 137 vm_purgable_control(mach_task_self(), 0, VM_PURGABLE_PURGE_ALL, &state); |
148 internal::DiscardableMemoryEmulated::PurgeForTesting(); | 138 internal::DiscardableMemoryEmulated::PurgeForTesting(); |
149 } | 139 } |
150 | 140 |
151 } // namespace base | 141 } // namespace base |
OLD | NEW |