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 WebProcessMemoryDump_h | |
6 #define WebProcessMemoryDump_h | |
7 | |
8 #include "base/trace_event/heap_profiler_allocation_context.h" | |
9 #include "platform/WebMemoryAllocatorDump.h" | |
10 #include "public/platform/WebCommon.h" | |
11 #include "public/platform/WebString.h" | |
12 | |
13 class SkTraceMemoryDump; | |
14 | |
15 namespace base { | |
16 | |
17 class DiscardableMemory; | |
18 | |
19 namespace trace_event { | |
20 | |
21 class ProcessMemoryDump; | |
22 class TraceEventMemoryOverhead; | |
23 | |
24 } // namespace trace_event | |
25 } // namespace base | |
26 | |
27 namespace blink { | |
28 | |
29 // Used to specify the type of memory dump the WebProcessMemoryDump should | |
30 // generate on dump requests. | |
31 // TODO(hajimehoshi): Remove this and use base::trace_event:: | |
32 // MemoryDumpLevelOfDetail instead. | |
33 enum class WebMemoryDumpLevelOfDetail { | |
34 Light, | |
35 Detailed | |
36 }; | |
37 | |
38 // A container which holds all the dumps for the various allocators for a given | |
39 // process. Embedders of WebMemoryDumpProvider are expected to populate a | |
40 // WebProcessMemoryDump instance with the stats of their allocators. | |
41 class BLINK_PLATFORM_EXPORT WebProcessMemoryDump { | |
42 public: | |
43 virtual ~WebProcessMemoryDump(); | |
44 | |
45 // Creates a new MemoryAllocatorDump with the given name and returns the | |
46 // empty object back to the caller. |absoluteName| uniquely identifies the | |
47 // dump within the scope of a ProcessMemoryDump. It is possible to express | |
48 // nesting by means of a slash-separated path naming (e.g., | |
49 // "allocator_name/arena_1/subheap_X"). | |
50 // |guid| is an optional identifier, unique among all processes within the | |
51 // scope of a global dump. This is only relevant when using | |
52 // addOwnershipEdge(). If omitted, it will be automatically generated. | |
53 virtual WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& a
bsoluteName, WebMemoryAllocatorDumpGuid) = 0; | |
54 | |
55 virtual WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& a
bsoluteName) = 0; | |
56 | |
57 // Gets a previously created MemoryAllocatorDump given its name. | |
58 virtual WebMemoryAllocatorDump* getMemoryAllocatorDump(const WebString& abso
luteName) const = 0; | |
59 | |
60 // Removes all the WebMemoryAllocatorDump(s) contained in this instance. | |
61 // This WebProcessMemoryDump can be safely reused as if it was new once this | |
62 // method returns. | |
63 virtual void clear() = 0; | |
64 | |
65 // Merges all WebMemoryAllocatorDump(s) contained in |other| inside this | |
66 // WebProcessMemoryDump, transferring their ownership to this instance. | |
67 // |other| will be an empty WebProcessMemoryDump after this method returns | |
68 // and can be reused as if it was new. | |
69 virtual void takeAllDumpsFrom(WebProcessMemoryDump* other) = 0; | |
70 | |
71 // Adds an ownership relationship between two MemoryAllocatorDump(s) with | |
72 // the semantics: |source| owns |target|, and has the effect of attributing | |
73 // the memory usage of |target| to |source|. |importance| is optional and | |
74 // relevant only for the cases of co-ownership, where it acts as a z-index: | |
75 // the owner with the highest importance will be attributed |target|'s | |
76 // memory. | |
77 virtual void addOwnershipEdge(WebMemoryAllocatorDumpGuid source, WebMemoryAl
locatorDumpGuid target, int importance) = 0; | |
78 | |
79 virtual void addOwnershipEdge(WebMemoryAllocatorDumpGuid source, WebMemoryAl
locatorDumpGuid target) = 0; | |
80 | |
81 // Utility method to add a suballocation relationship with the following | |
82 // semantics: |source| is suballocated from |target_node_name|. | |
83 // This creates a child node of |target_node_name| and adds an ownership | |
84 // edge between |source| and the new child node. As a result, the UI will | |
85 // not account the memory of |source| in the target node. | |
86 virtual void addSuballocation(WebMemoryAllocatorDumpGuid source, const WebSt
ring& targetNodeName) = 0; | |
87 | |
88 // Returns the SkTraceMemoryDump proxy interface that can be passed to Skia | |
89 // to dump into this WebProcessMemoryDump. Multiple SkTraceMemoryDump | |
90 // objects can be created using this method. The created dumpers are owned | |
91 // by WebProcessMemoryDump and cannot outlive the WebProcessMemoryDump | |
92 // object owning them. |dumpNamePrefix| is prefix appended to each dump | |
93 // created by the SkTraceMemoryDump implementation, if the dump should be | |
94 // placed under different namespace and not "skia". | |
95 virtual SkTraceMemoryDump* createDumpAdapterForSkia(const WebString& dumpNam
ePrefix) = 0; | |
96 | |
97 virtual blink::WebMemoryAllocatorDump* createDiscardableMemoryAllocatorDump(
const std::string& name, base::DiscardableMemory*) = 0; | |
98 | |
99 // Dumps heap memory usage. |allocatorName| is used as an absolute name for | |
100 // base::trace_event::ProcessMemoryDump::DumpHeapUsage(). | |
101 virtual void dumpHeapUsage(const base::hash_map<base::trace_event::Allocatio
nContext, base::trace_event::AllocationMetrics>& metricsByContext, base::trace_e
vent::TraceEventMemoryOverhead&, const char* allocatorName) = 0; | |
102 }; | |
103 | |
104 } // namespace blink | |
105 | |
106 #endif // WebProcessMemoryDump_h | |
OLD | NEW |