Expose memory allocator internal stats and properties.
Review URL: https://chromiumcodereview.appspot.com/10825250
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157102 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/allocator/allocator_extension.cc b/base/allocator/allocator_extension.cc
index 7ae11da..d4ed6d7 100644
--- a/base/allocator/allocator_extension.cc
+++ b/base/allocator/allocator_extension.cc
@@ -9,31 +9,46 @@
namespace base {
namespace allocator {
+bool GetProperty(const char* name, size_t* value) {
+ thunks::GetPropertyFunction get_property_function =
+ base::allocator::thunks::GetGetPropertyFunction();
+ return get_property_function != NULL && get_property_function(name, value);
+}
+
void GetStats(char* buffer, int buffer_length) {
DCHECK_GT(buffer_length, 0);
- if (thunks::GetStatsFunction* get_stats_function =
- base::allocator::thunks::GetGetStatsFunction())
+ thunks::GetStatsFunction get_stats_function =
+ base::allocator::thunks::GetGetStatsFunction();
+ if (get_stats_function)
get_stats_function(buffer, buffer_length);
else
buffer[0] = '\0';
}
void ReleaseFreeMemory() {
- if (thunks::ReleaseFreeMemoryFunction* release_free_memory_function =
- base::allocator::thunks::GetReleaseFreeMemoryFunction())
+ thunks::ReleaseFreeMemoryFunction release_free_memory_function =
+ base::allocator::thunks::GetReleaseFreeMemoryFunction();
+ if (release_free_memory_function)
release_free_memory_function();
}
-void SetGetStatsFunction(thunks::GetStatsFunction* get_stats_function) {
+void SetGetPropertyFunction(
+ thunks::GetPropertyFunction get_property_function) {
+ DCHECK_EQ(base::allocator::thunks::GetGetPropertyFunction(),
+ reinterpret_cast<thunks::GetPropertyFunction>(NULL));
+ base::allocator::thunks::SetGetPropertyFunction(get_property_function);
+}
+
+void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) {
DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(),
- reinterpret_cast<thunks::GetStatsFunction*>(NULL));
+ reinterpret_cast<thunks::GetStatsFunction>(NULL));
base::allocator::thunks::SetGetStatsFunction(get_stats_function);
}
void SetReleaseFreeMemoryFunction(
- thunks::ReleaseFreeMemoryFunction* release_free_memory_function) {
+ thunks::ReleaseFreeMemoryFunction release_free_memory_function) {
DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(),
- reinterpret_cast<thunks::ReleaseFreeMemoryFunction*>(NULL));
+ reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL));
base::allocator::thunks::SetReleaseFreeMemoryFunction(
release_free_memory_function);
}