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

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

Issue 1665553002: metrics: Connect leak detector to allocator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify alloc hook registration; Enclose more stuff in CrOS #ifdef Created 4 years, 9 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
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 <type_traits> // for std::add_pointer
11
10 #include "base/base_export.h" 12 #include "base/base_export.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 14
13 namespace base { 15 namespace base {
14 namespace allocator { 16 namespace allocator {
15 17
18 // Callback types for alloc and free.
19 using AllocHookFunc = std::add_pointer<void(const void*, size_t)>::type;
Primiano Tucci (use gerrit) 2016/03/02 22:16:11 I think there is an unresolved comment here, maybe
Simon Que 2016/03/02 22:35:25 Done.
20 using FreeHookFunc = std::add_pointer<void(const void*)>::type;
21
16 // Request that the allocator release any free memory it knows about to the 22 // Request that the allocator release any free memory it knows about to the
17 // system. 23 // system.
18 BASE_EXPORT void ReleaseFreeMemory(); 24 BASE_EXPORT void ReleaseFreeMemory();
19 25
20 // Get the named property's |value|. Returns true if the property is known. 26 // Get the named property's |value|. Returns true if the property is known.
21 // Returns false if the property is not a valid property name for the current 27 // Returns false if the property is not a valid property name for the current
22 // allocator implementation. 28 // allocator implementation.
23 // |name| or |value| cannot be NULL 29 // |name| or |value| cannot be NULL
24 BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value); 30 BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
25 31
26 BASE_EXPORT bool IsHeapProfilerRunning(); 32 BASE_EXPORT bool IsHeapProfilerRunning();
27 33
34 // Register callbacks for alloc and free. Can only store one callback at a time
35 // for each of alloc and free.
36 BASE_EXPORT void SetHooks(AllocHookFunc alloc_hook, FreeHookFunc free_hook);
37
38 // Attempts to unwind the call stack from the current location where this
39 // function is being called from. Must be called from a hook function registered
40 // by calling SetSingle{Alloc,Free}Hook, directly or indirectly.
41 //
42 // Arguments:
43 // stack: pointer to a pre-allocated array of void*'s.
44 // max_stack_size: indicates the size of the array in |stack|.
45 // skip_count: Indicates how many initial call stack levels to skip before
46 // storing the caller of alloc/free. This value might not be
47 // used, depending on the specific implementation.
48 //
49 // Returns the number of call stack frames stored in |stack|, or 0 if no call
50 // stack information is available.
51 BASE_EXPORT int GetCallStack(void** stack, int max_stack_size, int skip_count);
Primiano Tucci (use gerrit) 2016/03/02 22:16:11 There is another unresolved comment here: It looks
Simon Que 2016/03/02 22:35:25 Done.
52
28 } // namespace allocator 53 } // namespace allocator
29 } // namespace base 54 } // namespace base
30 55
31 #endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_ 56 #endif // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
OLDNEW
« no previous file with comments | « no previous file | base/allocator/allocator_extension.cc » ('j') | base/allocator/allocator_extension.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698