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