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 CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 5 #ifndef CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ |
6 #define CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 6 #define CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ |
7 | 7 |
8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h" | 12 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 namespace trace_event { | 15 namespace trace_event { |
16 class MemoryAllocatorDump; | 16 class MemoryAllocatorDump; |
17 class ProcessMemoryDump; | 17 class ProcessMemoryDump; |
18 } // namespace base | 18 } // namespace base |
19 } // namespace trace_event | 19 } // namespace trace_event |
20 | 20 |
21 namespace skia { | |
22 class SkTraceMemoryDump_Chrome; | |
23 } // namespace skia | |
24 | |
21 namespace content { | 25 namespace content { |
22 | 26 |
23 class WebMemoryAllocatorDumpImpl; | 27 class WebMemoryAllocatorDumpImpl; |
24 | 28 |
25 // Implements the blink::WebProcessMemoryDump interface by means of proxying the | 29 // Implements the blink::WebProcessMemoryDump interface by means of proxying the |
26 // calls to createMemoryAllocatorDump() to the underlying | 30 // calls to createMemoryAllocatorDump() to the underlying |
27 // base::trace_event::ProcessMemoryDump instance. | 31 // base::trace_event::ProcessMemoryDump instance. |
28 class CONTENT_EXPORT WebProcessMemoryDumpImpl final | 32 class CONTENT_EXPORT WebProcessMemoryDumpImpl final |
29 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { | 33 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { |
30 public: | 34 public: |
(...skipping 15 matching lines...) Expand all Loading... | |
46 blink::WebMemoryAllocatorDumpGuid guid); | 50 blink::WebMemoryAllocatorDumpGuid guid); |
47 virtual blink::WebMemoryAllocatorDump* getMemoryAllocatorDump( | 51 virtual blink::WebMemoryAllocatorDump* getMemoryAllocatorDump( |
48 const blink::WebString& absolute_name) const; | 52 const blink::WebString& absolute_name) const; |
49 virtual void clear(); | 53 virtual void clear(); |
50 virtual void takeAllDumpsFrom(blink::WebProcessMemoryDump* other); | 54 virtual void takeAllDumpsFrom(blink::WebProcessMemoryDump* other); |
51 virtual void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, | 55 virtual void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, |
52 blink::WebMemoryAllocatorDumpGuid target, | 56 blink::WebMemoryAllocatorDumpGuid target, |
53 int importance); | 57 int importance); |
54 virtual void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, | 58 virtual void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, |
55 blink::WebMemoryAllocatorDumpGuid target); | 59 blink::WebMemoryAllocatorDumpGuid target); |
60 virtual void AddSuballocation(blink::WebMemoryAllocatorDumpGuid source, | |
61 const blink::WebString& targetNodeName); | |
62 virtual SkTraceMemoryDump* CreateDumpAdapterForSkia( | |
63 blink::WebMemoryDumpLevelOfDetail levelOfDetail, | |
64 const blink::WebString& dumpNamePrefix); | |
56 | 65 |
57 const base::trace_event::ProcessMemoryDump* process_memory_dump() const { | 66 const base::trace_event::ProcessMemoryDump* process_memory_dump() const { |
58 return process_memory_dump_; | 67 return process_memory_dump_; |
59 } | 68 } |
60 | 69 |
61 private: | 70 private: |
62 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest, IntegrationTest); | 71 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest, IntegrationTest); |
63 | 72 |
64 blink::WebMemoryAllocatorDump* createWebMemoryAllocatorDump( | 73 blink::WebMemoryAllocatorDump* createWebMemoryAllocatorDump( |
65 base::trace_event::MemoryAllocatorDump* memory_allocator_dump); | 74 base::trace_event::MemoryAllocatorDump* memory_allocator_dump); |
66 | 75 |
67 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor). | 76 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor). |
68 scoped_ptr<base::trace_event::ProcessMemoryDump> owned_process_memory_dump_; | 77 scoped_ptr<base::trace_event::ProcessMemoryDump> owned_process_memory_dump_; |
69 | 78 |
70 // The underlying ProcessMemoryDump instance to which the | 79 // The underlying ProcessMemoryDump instance to which the |
71 // createMemoryAllocatorDump() calls will be proxied to. | 80 // createMemoryAllocatorDump() calls will be proxied to. |
72 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. | 81 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. |
73 | 82 |
74 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. | 83 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. |
75 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer | 84 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer |
76 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call. | 85 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call. |
77 // Those pointers are valid only within the scope of the call and can be | 86 // Those pointers are valid only within the scope of the call and can be |
78 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. | 87 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. |
79 base::ScopedPtrHashMap<base::trace_event::MemoryAllocatorDump*, | 88 base::ScopedPtrHashMap<base::trace_event::MemoryAllocatorDump*, |
80 scoped_ptr<WebMemoryAllocatorDumpImpl>> | 89 scoped_ptr<WebMemoryAllocatorDumpImpl>> |
81 memory_allocator_dumps_; | 90 memory_allocator_dumps_; |
82 | 91 |
92 // Stores SkTraceMemoryDump for the current ProcessMemoryDump. | |
Primiano Tucci (use gerrit)
2015/09/09 16:16:42
Please say: this class handles the memory ownershi
ssid
2015/09/10 11:08:26
Done.
| |
93 ScopedVector<skia::SkTraceMemoryDump_Chrome> sk_trace_dump_list_; | |
94 | |
83 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); | 95 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); |
84 }; | 96 }; |
85 | 97 |
86 } // namespace content | 98 } // namespace content |
87 | 99 |
88 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 100 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ |
OLD | NEW |