[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "base/allocator/allocator_extension.h" | ||||
6 | |||||
7 | #include "base/logging.h" | ||||
8 | |||||
9 | namespace base { | ||||
10 | namespace allocator { | ||||
11 | |||||
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 12 | bool GetAllocatorWasteSize(size_t* size) { |
13 | thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function = | ||||
14 | thunks::GetGetAllocatorWasteSizeFunction(); | ||||
15 | return get_allocator_waste_size_function != NULL && | ||||
16 | get_allocator_waste_size_function(size); | ||||
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 17 | } |
18 | |||||
[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 19 | void GetStats(char* buffer, int buffer_length) { |
20 | DCHECK_GT(buffer_length, 0); | ||||
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 21 | thunks::GetStatsFunction get_stats_function = thunks::GetGetStatsFunction(); |
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 22 | if (get_stats_function) |
[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 23 | get_stats_function(buffer, buffer_length); |
24 | else | ||||
25 | buffer[0] = '\0'; | ||||
26 | } | ||||
27 | |||||
28 | void ReleaseFreeMemory() { | ||||
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 29 | thunks::ReleaseFreeMemoryFunction release_free_memory_function = |
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 30 | thunks::GetReleaseFreeMemoryFunction(); |
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 31 | if (release_free_memory_function) |
[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 32 | release_free_memory_function(); |
33 | } | ||||
34 | |||||
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 35 | void SetGetAllocatorWasteSizeFunction( |
36 | thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function) { | ||||
37 | DCHECK_EQ(thunks::GetGetAllocatorWasteSizeFunction(), | ||||
38 | reinterpret_cast<thunks::GetAllocatorWasteSizeFunction>(NULL)); | ||||
39 | thunks::SetGetAllocatorWasteSizeFunction(get_allocator_waste_size_function); | ||||
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 40 | } |
41 | |||||
42 | void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) { | ||||
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 43 | DCHECK_EQ(thunks::GetGetStatsFunction(), |
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 44 | reinterpret_cast<thunks::GetStatsFunction>(NULL)); |
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 45 | thunks::SetGetStatsFunction(get_stats_function); |
[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 46 | } |
47 | |||||
48 | void SetReleaseFreeMemoryFunction( | ||||
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 49 | thunks::ReleaseFreeMemoryFunction release_free_memory_function) { |
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 50 | DCHECK_EQ(thunks::GetReleaseFreeMemoryFunction(), |
[email protected] | 094c893 | 2012-09-17 11:44:10 | [diff] [blame] | 51 | reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL)); |
[email protected] | 3b875959 | 2012-12-07 12:19:51 | [diff] [blame] | 52 | thunks::SetReleaseFreeMemoryFunction(release_free_memory_function); |
[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 53 | } |
54 | |||||
ssid | 0943409 | 2015-10-26 23:05:04 | [diff] [blame^] | 55 | void SetGetNumericPropertyFunction( |
56 | thunks::GetNumericPropertyFunction get_numeric_property_function) { | ||||
57 | DCHECK_EQ(thunks::GetGetNumericPropertyFunction(), | ||||
58 | reinterpret_cast<thunks::GetNumericPropertyFunction>(NULL)); | ||||
59 | thunks::SetGetNumericPropertyFunction(get_numeric_property_function); | ||||
60 | } | ||||
61 | |||||
[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 62 | } // namespace allocator |
63 | } // namespace base |