Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 WebMemoryDumpProvider_h | 5 #ifndef WebMemoryDumpProvider_h |
| 6 #define WebMemoryDumpProvider_h | 6 #define WebMemoryDumpProvider_h |
| 7 | 7 |
| 8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 class WebProcessMemoryDump; | 12 class WebProcessMemoryDump; |
| 13 | 13 |
| 14 // Used to specify the type of memory dump the WebMemoryDumpProvider should | 14 // Used to specify the type of memory dump the WebMemoryDumpProvider should |
| 15 // generate on dump requests. | 15 // generate on dump requests. |
| 16 enum class WebMemoryDumpLevelOfDetail { | 16 enum class WebMemoryDumpLevelOfDetail { |
| 17 Light, | 17 Light, |
| 18 Detailed | 18 Detailed |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 // Base interface to be part of the memory tracing infrastructure. Blink classes | 21 // Base interface to be part of the memory tracing infrastructure. Blink classes |
| 22 // can implement this interface and register themselves (see | 22 // can implement this interface and register themselves (see |
| 23 // Platform::registerMemoryDumpProvider()) to dump stats for their allocators. | 23 // Platform::registerMemoryDumpProvider()) to dump stats for their allocators. |
| 24 class BLINK_PLATFORM_EXPORT WebMemoryDumpProvider { | 24 class BLINK_PLATFORM_EXPORT WebMemoryDumpProvider { |
| 25 public: | 25 public: |
| 26 // Function types for functions that can be called on alloc and free to do | |
| 27 // heap profiling. | |
| 28 typedef void AllocationHook(void* address, size_t); | |
| 29 typedef void FreeHook(void* address); | |
| 30 | |
| 26 virtual ~WebMemoryDumpProvider(); | 31 virtual ~WebMemoryDumpProvider(); |
| 27 | 32 |
| 28 // Called by the MemoryDumpManager when generating memory dumps. | 33 // Called by the MemoryDumpManager when generating memory dumps. |
| 29 // WebMemoryDumpLevelOfDetail specifies the size of dump the embedders | 34 // WebMemoryDumpLevelOfDetail specifies the size of dump the embedders |
| 30 // should generate on dump requests. Embedders are expected to populate | 35 // should generate on dump requests. Embedders are expected to populate |
| 31 // the WebProcessMemoryDump* argument depending on the level and return true | 36 // the WebProcessMemoryDump* argument depending on the level and return true |
| 32 // on success or false if anything went wrong and the dump should be | 37 // on success or false if anything went wrong and the dump should be |
| 33 // considered invalid. | 38 // considered invalid. |
| 34 virtual bool onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) = 0; | 39 virtual bool onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) = 0; |
| 40 | |
| 41 // Because Blink cannot depend on base, heap profiling bookkeeping has to | |
| 42 // be done in the glue layer for now. This method allows the glue layer to | |
| 43 // detect for which dump provider it should do the bookkeeping. | |
|
Primiano Tucci (use gerrit)
2015/10/19 21:32:04
s/for which dump provider it should do the bookkee
haraken
2015/10/20 00:14:19
Add a TODO and mention that this should be removed
Ruud van Asseldonk
2015/10/20 11:43:57
Done, though that does miss the fact that the glue
| |
| 44 virtual bool supportsHeapProfiling() { return false; } | |
| 45 | |
| 46 // Called by the memory dump manager to enable heap profiling (with | |
| 47 // non-null hook functions) or called to disable heap profiling (with null | |
| 48 // pointers). This is a workaround for the fact that Blink cannot use | |
|
Primiano Tucci (use gerrit)
2015/10/19 21:32:03
Remove the "Ths is a workaround" part. You already
Ruud van Asseldonk
2015/10/20 11:43:57
Done.
| |
| 49 // |base::trace_event::AllocationRegister| and do the bookkeeping itself. | |
| 50 virtual void onHeapProfilingEnabled(AllocationHook* allocationHook, FreeHook * freeHook) {} | |
| 35 }; | 51 }; |
| 36 | 52 |
| 37 } // namespace blink | 53 } // namespace blink |
| 38 | 54 |
| 39 #endif // WebMemoryDumpProvider_h | 55 #endif // WebMemoryDumpProvider_h |
| OLD | NEW |