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 #ifndef BASE_ALLOCATOR_ALLOCATOR_EXTENSION_THUNKS_H_ | 5 #ifndef BASE_ALLOCATOR_ALLOCATOR_EXTENSION_THUNKS_H_ |
6 #define BASE_ALLOCATOR_ALLOCATOR_EXTENSION_THUNKS_H_ | 6 #define BASE_ALLOCATOR_ALLOCATOR_EXTENSION_THUNKS_H_ |
7 | 7 |
8 #include <stddef.h> // for size_t | 8 #include <stddef.h> // for size_t |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 namespace allocator { | 11 namespace allocator { |
12 namespace thunks { | 12 namespace thunks { |
13 | 13 |
14 // WARNING: You probably don't want to use this file unless you are routing a | 14 // WARNING: You probably don't want to use this file unless you are routing a |
15 // new allocator extension from a specific allocator implementation to base. | 15 // new allocator extension from a specific allocator implementation to base. |
16 // See allocator_extension.h to see the interface that base exports. | 16 // See allocator_extension.h to see the interface that base exports. |
17 | 17 |
18 typedef bool (*GetAllocatorWasteSizeFunction)(size_t* size); | 18 // Pointers to all the allcator extension functions that are used in chrome. |
19 void SetGetAllocatorWasteSizeFunction( | 19 struct AllocatorExtensionFunctions { |
20 GetAllocatorWasteSizeFunction get_allocator_waste_size_function); | 20 typedef bool (*GetAllocatorWasteSize)(size_t* size); |
21 GetAllocatorWasteSizeFunction GetGetAllocatorWasteSizeFunction(); | 21 typedef void (*GetStats)(char* buffer, int buffer_length); |
| 22 typedef void (*ReleaseFreeMemory)(); |
| 23 typedef unsigned int (*GetBytesAllocatedOnCurrentThread)(); |
| 24 typedef bool (*GetNumericProperty)(const char* name, size_t* value); |
22 | 25 |
23 typedef void (*GetStatsFunction)(char* buffer, int buffer_length); | 26 typedef int (*StackGenerator)(int skip_count, void** stack); |
24 void SetGetStatsFunction(GetStatsFunction get_stats_function); | 27 typedef void (*HeapProfilerStart)(StackGenerator callback); |
25 GetStatsFunction GetGetStatsFunction(); | 28 typedef void (*HeapProfilerStop)(); |
| 29 typedef char* (*GetHeapProfile)(); |
| 30 typedef void (*HeapProfilerDump)(const char* reason); |
| 31 typedef bool (*IsHeapProfilerRunning)(); |
26 | 32 |
27 typedef void (*ReleaseFreeMemoryFunction)(); | 33 GetAllocatorWasteSize get_allocator_waste_size; |
28 void SetReleaseFreeMemoryFunction( | 34 GetStats get_stats; |
29 ReleaseFreeMemoryFunction release_free_memory_function); | 35 ReleaseFreeMemory release_free_memory; |
30 ReleaseFreeMemoryFunction GetReleaseFreeMemoryFunction(); | 36 GetBytesAllocatedOnCurrentThread get_bytes_allocated_on_current_thread; |
| 37 GetNumericProperty get_numeric_property; |
31 | 38 |
32 typedef bool (*GetNumericPropertyFunction)(const char* name, size_t* value); | 39 HeapProfilerStart heap_profiler_start; |
33 void SetGetNumericPropertyFunction( | 40 HeapProfilerStop heap_profiler_stop; |
34 GetNumericPropertyFunction get_numeric_property_function); | 41 GetHeapProfile get_heap_profile; |
35 GetNumericPropertyFunction GetGetNumericPropertyFunction(); | 42 HeapProfilerDump heap_profiler_dump; |
| 43 IsHeapProfilerRunning is_heap_profiler_running; |
| 44 }; |
| 45 |
| 46 void SetAllocatorExtensionFunctions(AllocatorExtensionFunctions functions); |
| 47 AllocatorExtensionFunctions GetAllocatorExtensionFunctions(); |
36 | 48 |
37 } // namespace thunks | 49 } // namespace thunks |
38 } // namespace allocator | 50 } // namespace allocator |
39 } // namespace base | 51 } // namespace base |
40 | 52 |
41 #endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_THUNKS_H_ | 53 #endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_THUNKS_H_ |
OLD | NEW |