| 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_H | 5 #ifndef BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H |
| 6 #define BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H | 6 #define BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H |
| 7 | 7 |
| 8 #include <stddef.h> // for size_t | 8 #include <stddef.h> // for size_t |
| 9 | 9 |
| 10 #include "base/allocator/allocator_extension_thunks.h" | 10 #include "base/allocator/allocator_extension_thunks.h" |
| 11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 namespace allocator { | 15 namespace allocator { |
| 16 | 16 |
| 17 // Request the allocator to report value of its internal state variable. | 17 // Request the allocator to report value of its waste memory size. |
| 18 // Waste size corresponds to memory that has been allocated from the OS but |
| 19 // not passed up to the application. It e.g. includes memory retained by free |
| 20 // lists, internal data, chunks padding, etc. |
| 18 // | 21 // |
| 19 // |name| name of the variable | 22 // |size| pointer to the returned value, must be not NULL. |
| 20 // |value| pointer to the returned value, must be not NULL. | 23 // Returns true if the value has been returned, false otherwise. |
| 21 // Returns true if the value has been returned, false if a variable with such | 24 BASE_EXPORT bool GetAllocatorWasteSize(size_t* size); |
| 22 // name does not exist. | |
| 23 BASE_EXPORT bool GetProperty(const char* name, size_t* value); | |
| 24 | 25 |
| 25 // Request that the allocator print a human-readable description of the current | 26 // Request that the allocator print a human-readable description of the current |
| 26 // state of the allocator into a null-terminated string in the memory segment | 27 // state of the allocator into a null-terminated string in the memory segment |
| 27 // buffer[0,buffer_length-1]. | 28 // buffer[0,buffer_length-1]. |
| 28 // | 29 // |
| 29 // |buffer| must point to a valid piece of memory | 30 // |buffer| must point to a valid piece of memory |
| 30 // |buffer_length| must be > 0. | 31 // |buffer_length| must be > 0. |
| 31 BASE_EXPORT void GetStats(char* buffer, int buffer_length); | 32 BASE_EXPORT void GetStats(char* buffer, int buffer_length); |
| 32 | 33 |
| 33 // Request that the allocator release any free memory it knows about to the | 34 // Request that the allocator release any free memory it knows about to the |
| 34 // system. | 35 // system. |
| 35 BASE_EXPORT void ReleaseFreeMemory(); | 36 BASE_EXPORT void ReleaseFreeMemory(); |
| 36 | 37 |
| 37 | 38 |
| 38 // These settings allow specifying a callback used to implement the allocator | 39 // These settings allow specifying a callback used to implement the allocator |
| 39 // extension functions. These are optional, but if set they must only be set | 40 // extension functions. These are optional, but if set they must only be set |
| 40 // once. These will typically called in an allocator-specific initialization | 41 // once. These will typically called in an allocator-specific initialization |
| 41 // routine. | 42 // routine. |
| 42 // | 43 // |
| 43 // No threading promises are made. The caller is responsible for making sure | 44 // No threading promises are made. The caller is responsible for making sure |
| 44 // these pointers are set before any other threads attempt to call the above | 45 // these pointers are set before any other threads attempt to call the above |
| 45 // functions. | 46 // functions. |
| 46 BASE_EXPORT void SetGetPropertyFunction( | 47 BASE_EXPORT void SetGetAllocatorWasteSizeFunction( |
| 47 thunks::GetPropertyFunction get_property_function); | 48 thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function); |
| 48 | 49 |
| 49 BASE_EXPORT void SetGetStatsFunction( | 50 BASE_EXPORT void SetGetStatsFunction( |
| 50 thunks::GetStatsFunction get_stats_function); | 51 thunks::GetStatsFunction get_stats_function); |
| 51 | 52 |
| 52 BASE_EXPORT void SetReleaseFreeMemoryFunction( | 53 BASE_EXPORT void SetReleaseFreeMemoryFunction( |
| 53 thunks::ReleaseFreeMemoryFunction release_free_memory_function); | 54 thunks::ReleaseFreeMemoryFunction release_free_memory_function); |
| 54 | 55 |
| 55 } // namespace allocator | 56 } // namespace allocator |
| 56 } // namespace base | 57 } // namespace base |
| 57 | 58 |
| 58 #endif | 59 #endif |
| OLD | NEW |