| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/allocator/allocator_extension.h" | 5 #include "base/allocator/allocator_extension.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 namespace allocator { | 10 namespace allocator { |
| 11 | 11 |
| 12 namespace { |
| 13 ReleaseFreeMemoryFunction g_release_free_memory_function = nullptr; |
| 14 GetNumericPropertyFunction g_get_numeric_property_function = nullptr; |
| 15 } |
| 16 |
| 12 void ReleaseFreeMemory() { | 17 void ReleaseFreeMemory() { |
| 13 thunks::ReleaseFreeMemoryFunction release_free_memory_function = | 18 if (g_release_free_memory_function) |
| 14 thunks::GetReleaseFreeMemoryFunction(); | 19 g_release_free_memory_function(); |
| 15 if (release_free_memory_function) | 20 } |
| 16 release_free_memory_function(); | 21 |
| 22 bool GetNumericProperty(const char* name, size_t* value) { |
| 23 return g_get_numeric_property_function && |
| 24 g_get_numeric_property_function(name, value); |
| 17 } | 25 } |
| 18 | 26 |
| 19 void SetReleaseFreeMemoryFunction( | 27 void SetReleaseFreeMemoryFunction( |
| 20 thunks::ReleaseFreeMemoryFunction release_free_memory_function) { | 28 ReleaseFreeMemoryFunction release_free_memory_function) { |
| 21 DCHECK_EQ(thunks::GetReleaseFreeMemoryFunction(), | 29 DCHECK(!g_release_free_memory_function); |
| 22 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL)); | 30 g_release_free_memory_function = release_free_memory_function; |
| 23 thunks::SetReleaseFreeMemoryFunction(release_free_memory_function); | |
| 24 } | 31 } |
| 25 | 32 |
| 26 void SetGetNumericPropertyFunction( | 33 void SetGetNumericPropertyFunction( |
| 27 thunks::GetNumericPropertyFunction get_numeric_property_function) { | 34 GetNumericPropertyFunction get_numeric_property_function) { |
| 28 DCHECK_EQ(thunks::GetGetNumericPropertyFunction(), | 35 DCHECK(!g_get_numeric_property_function); |
| 29 reinterpret_cast<thunks::GetNumericPropertyFunction>(NULL)); | 36 g_get_numeric_property_function = get_numeric_property_function; |
| 30 thunks::SetGetNumericPropertyFunction(get_numeric_property_function); | |
| 31 } | 37 } |
| 32 | 38 |
| 33 } // namespace allocator | 39 } // namespace allocator |
| 34 } // namespace base | 40 } // namespace base |
| OLD | NEW |