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 void GetStats(char* buffer, int buffer_length) { | |
13 DCHECK_GT(buffer_length, 0); | |
14 thunks::GetStatsFunction get_stats_function = thunks::GetGetStatsFunction(); | |
15 if (get_stats_function) | |
16 get_stats_function(buffer, buffer_length); | |
17 else | |
18 buffer[0] = '\0'; | |
19 } | |
20 | |
21 void ReleaseFreeMemory() { | 12 void ReleaseFreeMemory() { |
22 thunks::ReleaseFreeMemoryFunction release_free_memory_function = | 13 thunks::ReleaseFreeMemoryFunction release_free_memory_function = |
23 thunks::GetReleaseFreeMemoryFunction(); | 14 thunks::GetReleaseFreeMemoryFunction(); |
24 if (release_free_memory_function) | 15 if (release_free_memory_function) |
25 release_free_memory_function(); | 16 release_free_memory_function(); |
26 } | 17 } |
27 | 18 |
28 void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) { | |
29 DCHECK_EQ(thunks::GetGetStatsFunction(), | |
30 reinterpret_cast<thunks::GetStatsFunction>(NULL)); | |
31 thunks::SetGetStatsFunction(get_stats_function); | |
32 } | |
33 | |
34 void SetReleaseFreeMemoryFunction( | 19 void SetReleaseFreeMemoryFunction( |
35 thunks::ReleaseFreeMemoryFunction release_free_memory_function) { | 20 thunks::ReleaseFreeMemoryFunction release_free_memory_function) { |
36 DCHECK_EQ(thunks::GetReleaseFreeMemoryFunction(), | 21 DCHECK_EQ(thunks::GetReleaseFreeMemoryFunction(), |
37 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL)); | 22 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL)); |
38 thunks::SetReleaseFreeMemoryFunction(release_free_memory_function); | 23 thunks::SetReleaseFreeMemoryFunction(release_free_memory_function); |
39 } | 24 } |
40 | 25 |
41 void SetGetNumericPropertyFunction( | 26 void SetGetNumericPropertyFunction( |
42 thunks::GetNumericPropertyFunction get_numeric_property_function) { | 27 thunks::GetNumericPropertyFunction get_numeric_property_function) { |
43 DCHECK_EQ(thunks::GetGetNumericPropertyFunction(), | 28 DCHECK_EQ(thunks::GetGetNumericPropertyFunction(), |
44 reinterpret_cast<thunks::GetNumericPropertyFunction>(NULL)); | 29 reinterpret_cast<thunks::GetNumericPropertyFunction>(NULL)); |
45 thunks::SetGetNumericPropertyFunction(get_numeric_property_function); | 30 thunks::SetGetNumericPropertyFunction(get_numeric_property_function); |
46 } | 31 } |
47 | 32 |
48 } // namespace allocator | 33 } // namespace allocator |
49 } // namespace base | 34 } // namespace base |
OLD | NEW |