Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: base/allocator/allocator_extension.cc

Issue 10825250: Expose memory allocator internal stats and properties. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add jemalloc.h include Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/allocator/allocator_extension.h ('k') | base/allocator/allocator_extension_thunks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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) {
13 thunks::GetPropertyFunction get_property_function =
14 base::allocator::thunks::GetGetPropertyFunction();
15 return get_property_function != NULL && get_property_function(name, value);
16 }
17
12 void GetStats(char* buffer, int buffer_length) { 18 void GetStats(char* buffer, int buffer_length) {
13 DCHECK_GT(buffer_length, 0); 19 DCHECK_GT(buffer_length, 0);
14 if (thunks::GetStatsFunction* get_stats_function = 20 thunks::GetStatsFunction get_stats_function =
15 base::allocator::thunks::GetGetStatsFunction()) 21 base::allocator::thunks::GetGetStatsFunction();
22 if (get_stats_function)
16 get_stats_function(buffer, buffer_length); 23 get_stats_function(buffer, buffer_length);
17 else 24 else
18 buffer[0] = '\0'; 25 buffer[0] = '\0';
19 } 26 }
20 27
21 void ReleaseFreeMemory() { 28 void ReleaseFreeMemory() {
22 if (thunks::ReleaseFreeMemoryFunction* release_free_memory_function = 29 thunks::ReleaseFreeMemoryFunction release_free_memory_function =
23 base::allocator::thunks::GetReleaseFreeMemoryFunction()) 30 base::allocator::thunks::GetReleaseFreeMemoryFunction();
31 if (release_free_memory_function)
24 release_free_memory_function(); 32 release_free_memory_function();
25 } 33 }
26 34
27 void SetGetStatsFunction(thunks::GetStatsFunction* get_stats_function) { 35 void SetGetPropertyFunction(
36 thunks::GetPropertyFunction get_property_function) {
37 DCHECK_EQ(base::allocator::thunks::GetGetPropertyFunction(),
38 reinterpret_cast<thunks::GetPropertyFunction>(NULL));
39 base::allocator::thunks::SetGetPropertyFunction(get_property_function);
40 }
41
42 void SetGetStatsFunction(thunks::GetStatsFunction get_stats_function) {
28 DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(), 43 DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(),
29 reinterpret_cast<thunks::GetStatsFunction*>(NULL)); 44 reinterpret_cast<thunks::GetStatsFunction>(NULL));
30 base::allocator::thunks::SetGetStatsFunction(get_stats_function); 45 base::allocator::thunks::SetGetStatsFunction(get_stats_function);
31 } 46 }
32 47
33 void SetReleaseFreeMemoryFunction( 48 void SetReleaseFreeMemoryFunction(
34 thunks::ReleaseFreeMemoryFunction* release_free_memory_function) { 49 thunks::ReleaseFreeMemoryFunction release_free_memory_function) {
35 DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(), 50 DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(),
36 reinterpret_cast<thunks::ReleaseFreeMemoryFunction*>(NULL)); 51 reinterpret_cast<thunks::ReleaseFreeMemoryFunction>(NULL));
37 base::allocator::thunks::SetReleaseFreeMemoryFunction( 52 base::allocator::thunks::SetReleaseFreeMemoryFunction(
38 release_free_memory_function); 53 release_free_memory_function);
39 } 54 }
40 55
41 } // namespace allocator 56 } // namespace allocator
42 } // namespace base 57 } // namespace base
OLDNEW
« no previous file with comments | « base/allocator/allocator_extension.h ('k') | base/allocator/allocator_extension_thunks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698