Chromium Code Reviews| 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 bool GetProperty(const char* name, size_t* value) { | 12 bool GetAllocatorWasteSize(size_t* size) { |
| 13 thunks::GetPropertyFunction get_property_function = | 13 thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function = |
| 14 base::allocator::thunks::GetGetPropertyFunction(); | 14 base::allocator::thunks::GetGetAllocatorWasteSizeFunction(); |
|
darin (slow to review)
2012/10/23 17:28:30
nit: no need for base::allocator:: prefix when you
alexeif
2012/10/23 18:00:15
Done.
| |
| 15 return get_property_function != NULL && get_property_function(name, value); | 15 return get_allocator_waste_size_function != NULL && |
| 16 get_allocator_waste_size_function(size); | |
| 16 } | 17 } |
| 17 | 18 |
| 18 void GetStats(char* buffer, int buffer_length) { | 19 void GetStats(char* buffer, int buffer_length) { |
| 19 DCHECK_GT(buffer_length, 0); | 20 DCHECK_GT(buffer_length, 0); |
| 20 thunks::GetStatsFunction get_stats_function = | 21 thunks::GetStatsFunction get_stats_function = |
| 21 base::allocator::thunks::GetGetStatsFunction(); | 22 base::allocator::thunks::GetGetStatsFunction(); |
| 22 if (get_stats_function) | 23 if (get_stats_function) |
| 23 get_stats_function(buffer, buffer_length); | 24 get_stats_function(buffer, buffer_length); |
| 24 else | 25 else |
| 25 buffer[0] = '\0'; | 26 buffer[0] = '\0'; |
| 26 } | 27 } |
| 27 | 28 |
| 28 void ReleaseFreeMemory() { | 29 void ReleaseFreeMemory() { |
| 29 thunks::ReleaseFreeMemoryFunction release_free_memory_function = | 30 thunks::ReleaseFreeMemoryFunction release_free_memory_function = |
| 30 base::allocator::thunks::GetReleaseFreeMemoryFunction(); | 31 base::allocator::thunks::GetReleaseFreeMemoryFunction(); |
| 31 if (release_free_memory_function) | 32 if (release_free_memory_function) |
| 32 release_free_memory_function(); | 33 release_free_memory_function(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void SetGetPropertyFunction( | 36 void SetGetAllocatorWasteSizeFunction( |
| 36 thunks::GetPropertyFunction get_property_function) { | 37 thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function) { |
| 37 DCHECK_EQ(base::allocator::thunks::GetGetPropertyFunction(), | 38 DCHECK_EQ(base::allocator::thunks::GetGetAllocatorWasteSizeFunction(), |
| 38 reinterpret_cast<thunks::GetPropertyFunction>(NULL)); | 39 reinterpret_cast<thunks::GetAllocatorWasteSizeFunction>(NULL)); |
| 39 base::allocator::thunks::SetGetPropertyFunction(get_property_function); | 40 base::allocator::thunks::SetGetAllocatorWasteSizeFunction( |
|
darin (slow to review)
2012/10/23 17:28:30
ditto: no need for base::allocator::
alexeif
2012/10/23 18:00:15
Done.
| |
| 41 get_allocator_waste_size_function); | |
| 40 } | 42 } |
| 41 | 43 |
| 42 void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) { | 44 void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) { |
| 43 DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(), | 45 DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(), |
| 44 reinterpret_cast<thunks::GetStatsFunction>(NULL)); | 46 reinterpret_cast<thunks::GetStatsFunction>(NULL)); |
| 45 base::allocator::thunks::SetGetStatsFunction(get_stats_function); | 47 base::allocator::thunks::SetGetStatsFunction(get_stats_function); |
| 46 } | 48 } |
| 47 | 49 |
| 48 void SetReleaseFreeMemoryFunction( | 50 void SetReleaseFreeMemoryFunction( |
| 49 thunks::ReleaseFreeMemoryFunction release_free_memory_function) { | 51 thunks::ReleaseFreeMemoryFunction release_free_memory_function) { |
| 50 DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(), | 52 DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(), |
| 51 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL)); | 53 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL)); |
| 52 base::allocator::thunks::SetReleaseFreeMemoryFunction( | 54 base::allocator::thunks::SetReleaseFreeMemoryFunction( |
| 53 release_free_memory_function); | 55 release_free_memory_function); |
| 54 } | 56 } |
| 55 | 57 |
| 56 } // namespace allocator | 58 } // namespace allocator |
| 57 } // namespace base | 59 } // namespace base |
| OLD | NEW |