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

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

Issue 1469843002: Remove dependency on allocator from 'content' targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unify_allocator1_2
Patch Set: Fix build Created 5 years, 1 month 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
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 #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 // Initializes the allocator and the routes the extension functions
Primiano Tucci (use gerrit) 2015/11/25 12:47:17 "the routes the extension functions implementation
18 // implementations to base. This should be called only once and called before
19 // the other allocator extension functions. This function is NOT thread safe and
20 // the caller should ensure that it is called before any thread attempts to call
21 // the below functions.
22 // Do not call this function unless there is an allocator library that replaces
23 // the underlying weak function, which is expected to provide the necessary
24 // callbacks for the functions below. See InitializeAllocatorWeak.
25 BASE_EXPORT void InitializeAllocator();
26
17 // Request the allocator to report value of its waste memory size. 27 // 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 28 // 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 29 // not passed up to the application. It e.g. includes memory retained by free
20 // lists, internal data, chunks padding, etc. 30 // lists, internal data, chunks padding, etc.
21 // 31 //
22 // |size| pointer to the returned value, must be not NULL. 32 // |size| pointer to the returned value, must be not NULL.
23 // Returns true if the value has been returned, false otherwise. 33 // Returns true if the value has been returned, false otherwise.
24 BASE_EXPORT bool GetAllocatorWasteSize(size_t* size); 34 BASE_EXPORT bool GetAllocatorWasteSize(size_t* size);
25 35
26 // Request that the allocator print a human-readable description of the current 36 // Request that the allocator print a human-readable description of the current
27 // state of the allocator into a null-terminated string in the memory segment 37 // state of the allocator into a null-terminated string in the memory segment
28 // buffer[0,buffer_length-1]. 38 // buffer[0,buffer_length-1].
29 // 39 //
30 // |buffer| must point to a valid piece of memory 40 // |buffer| must point to a valid piece of memory
31 // |buffer_length| must be > 0. 41 // |buffer_length| must be > 0.
32 BASE_EXPORT void GetStats(char* buffer, int buffer_length); 42 BASE_EXPORT void GetStats(char* buffer, int buffer_length);
33 43
34 // Request that the allocator release any free memory it knows about to the 44 // Request that the allocator release any free memory it knows about to the
35 // system. 45 // system.
36 BASE_EXPORT void ReleaseFreeMemory(); 46 BASE_EXPORT void ReleaseFreeMemory();
37 47
48 // Returns the total bytes allocated in the current thread.
49 BASE_EXPORT size_t GetBytesAllocatedOnCurrentThread();
38 50
39 // These settings allow specifying a callback used to implement the allocator 51 // Get the named property's |value|. Returns true if the property is known.
40 // extension functions. These are optional, but if set they must only be set 52 // Returns false if the property is not a valid property name for the current
41 // once. These will typically called in an allocator-specific initialization 53 // malloc implementation.
42 // routine. 54 // |name| or |value| cannot be NULL
43 // 55 BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
44 // No threading promises are made. The caller is responsible for making sure
45 // these pointers are set before any other threads attempt to call the above
46 // functions.
47 BASE_EXPORT void SetGetAllocatorWasteSizeFunction(
48 thunks::GetAllocatorWasteSizeFunction get_allocator_waste_size_function);
49 56
50 BASE_EXPORT void SetGetStatsFunction( 57 // The following are used for heap profiling if the allocator implementation
51 thunks::GetStatsFunction get_stats_function); 58 // supports.
52 59
53 BASE_EXPORT void SetReleaseFreeMemoryFunction( 60 // Start and stop heap profiler:
54 thunks::ReleaseFreeMemoryFunction release_free_memory_function); 61 typedef thunks::AllocatorExtensionFunctions::StackGenerator
62 StackGeneratorFunction;
63 BASE_EXPORT void HeapProfilerStart(StackGeneratorFunction callback);
64 BASE_EXPORT void HeapProfilerStop();
55 65
56 BASE_EXPORT void SetGetNumericPropertyFunction( 66 // Generate current heap profiling information and return as string.
57 thunks::GetNumericPropertyFunction get_numeric_property_function); 67 BASE_EXPORT char* GetHeapProfile();
68
69 // Generate current heap profiling information and write to file.
70 BASE_EXPORT void HeapProfilerDump(const char* reason);
71
72 // Return true if heap profiler is running.
73 BASE_EXPORT bool IsHeapProfilerRunning();
58 74
59 } // namespace allocator 75 } // namespace allocator
60 } // namespace base 76 } // namespace base
61 77
62 #endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_ 78 #endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698