Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / WebProcessMemoryDump.h
blob27c6e1abbcc4b6aebd74c29d48021748a3a85b1c
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.
5 #ifndef WebProcessMemoryDump_h
6 #define WebProcessMemoryDump_h
8 #include "WebCommon.h"
9 #include "WebMemoryAllocatorDump.h"
10 #include "WebString.h"
12 namespace blink {
14 // A container which holds all the dumps for the various allocators for a given
15 // process. Embedders of WebMemoryDumpProvider are expected to populate a
16 // WebProcessMemoryDump instance with the stats of their allocators.
17 class BLINK_PLATFORM_EXPORT WebProcessMemoryDump {
18 public:
19 virtual ~WebProcessMemoryDump();
21 // Creates a new MemoryAllocatorDump with the given name and returns the
22 // empty object back to the caller. |absoluteName| uniquely identifies the
23 // dump within the scope of a ProcessMemoryDump. It is possible to express
24 // nesting by means of a slash-separated path naming (e.g.,
25 // "allocator_name/arena_1/subheap_X").
26 // |guid| is an optional identifier, unique among all processes within the
27 // scope of a global dump. This is only relevant when using
28 // AddOwnershipEdge(). If omitted, it will be automatically generated.
29 virtual WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& absoluteName, WebMemoryAllocatorDumpGuid guid)
31 BLINK_ASSERT_NOT_REACHED();
32 return nullptr;
35 virtual WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& absoluteName)
37 BLINK_ASSERT_NOT_REACHED();
38 return nullptr;
41 // Gets a previously created MemoryAllocatorDump given its name.
42 virtual WebMemoryAllocatorDump* getMemoryAllocatorDump(const WebString& absoluteName) const
44 BLINK_ASSERT_NOT_REACHED();
45 return nullptr;
48 // Removes all the WebMemoryAllocatorDump(s) contained in this instance.
49 // This WebProcessMemoryDump can be safely reused as if it was new once this
50 // method returns.
51 virtual void clear()
53 BLINK_ASSERT_NOT_REACHED();
56 // Merges all WebMemoryAllocatorDump(s) contained in |other| inside this
57 // WebProcessMemoryDump, transferring their ownership to this instance.
58 // |other| will be an empty WebProcessMemoryDump after this method returns
59 // and can be reused as if it was new.
60 virtual void takeAllDumpsFrom(WebProcessMemoryDump* other)
62 BLINK_ASSERT_NOT_REACHED();
65 // Adds an ownership relationship between two MemoryAllocatorDump(s) with
66 // the semantics: |source| owns |target|, and has the effect of attributing
67 // the memory usage of |target| to |source|. |importance| is optional and
68 // relevant only for the cases of co-ownership, where it acts as a z-index:
69 // the owner with the highest importance will be attributed |target|'s
70 // memory.
71 virtual void AddOwnershipEdge(WebMemoryAllocatorDumpGuid source, WebMemoryAllocatorDumpGuid target, int importance)
73 BLINK_ASSERT_NOT_REACHED();
76 virtual void AddOwnershipEdge(WebMemoryAllocatorDumpGuid source, WebMemoryAllocatorDumpGuid target)
78 BLINK_ASSERT_NOT_REACHED();
82 } // namespace blink
84 #endif // WebProcessMemoryDump_h