| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WebMemoryDumpProvider_h | |
| 6 #define WebMemoryDumpProvider_h | |
| 7 | |
| 8 #include "WebCommon.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 class WebProcessMemoryDump; | |
| 13 | |
| 14 // Used to specify the type of memory dump the WebMemoryDumpProvider should | |
| 15 // generate on dump requests. | |
| 16 // TODO(hajimehoshi): Remove this and use base::trace_event:: | |
| 17 // MemoryDumpLevelOfDetail instead. | |
| 18 enum class WebMemoryDumpLevelOfDetail { | |
| 19 Light, | |
| 20 Detailed | |
| 21 }; | |
| 22 | |
| 23 // Base interface to be part of the memory tracing infrastructure. Blink classes | |
| 24 // can implement this interface and register themselves (see | |
| 25 // Platform::registerMemoryDumpProvider()) to dump stats for their allocators. | |
| 26 class BLINK_PLATFORM_EXPORT WebMemoryDumpProvider { | |
| 27 public: | |
| 28 // Function types for functions that can be called on alloc and free to do | |
| 29 // heap profiling. | |
| 30 typedef void AllocationHook(void* address, size_t, const char*); | |
| 31 typedef void FreeHook(void* address); | |
| 32 | |
| 33 virtual ~WebMemoryDumpProvider(); | |
| 34 | |
| 35 // Called by the MemoryDumpManager when generating memory dumps. | |
| 36 // WebMemoryDumpLevelOfDetail specifies the size of dump the embedders | |
| 37 // should generate on dump requests. Embedders are expected to populate | |
| 38 // the WebProcessMemoryDump* argument depending on the level and return true | |
| 39 // on success or false if anything went wrong and the dump should be | |
| 40 // considered invalid. | |
| 41 virtual bool onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*)
= 0; | |
| 42 | |
| 43 // Because Blink cannot depend on base, heap profiling bookkeeping has to | |
| 44 // be done in the glue layer for now. This method allows the glue layer to | |
| 45 // detect whether the current dump provider supports heap profiling. | |
| 46 // TODO(ruuda): Remove once wtf can depend on base and do bookkeeping in the | |
| 47 // provider itself. | |
| 48 virtual bool supportsHeapProfiling() { return false; } | |
| 49 | |
| 50 // Called by the memory dump manager to enable heap profiling (with true) or | |
| 51 // called to disable heap profiling (with false). | |
| 52 virtual void onHeapProfilingEnabled(bool enabled) {} | |
| 53 }; | |
| 54 | |
| 55 } // namespace blink | |
| 56 | |
| 57 #endif // WebMemoryDumpProvider_h | |
| OLD | NEW |