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_ptr.h" |
| 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/trace_event/memory_dump_request_args.h" |
11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
12 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h" | 14 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h" |
13 | 15 |
14 namespace base { | 16 namespace base { |
15 namespace trace_event { | 17 namespace trace_event { |
16 class MemoryAllocatorDump; | 18 class MemoryAllocatorDump; |
17 class ProcessMemoryDump; | 19 class ProcessMemoryDump; |
18 } // namespace base | 20 } // namespace base |
19 } // namespace trace_event | 21 } // namespace trace_event |
20 | 22 |
| 23 namespace skia { |
| 24 class SkTraceMemoryDump_Chrome; |
| 25 } // namespace skia |
| 26 |
21 namespace content { | 27 namespace content { |
22 | 28 |
23 class WebMemoryAllocatorDumpImpl; | 29 class WebMemoryAllocatorDumpImpl; |
24 | 30 |
25 // Implements the blink::WebProcessMemoryDump interface by means of proxying the | 31 // Implements the blink::WebProcessMemoryDump interface by means of proxying the |
26 // calls to createMemoryAllocatorDump() to the underlying | 32 // calls to createMemoryAllocatorDump() to the underlying |
27 // base::trace_event::ProcessMemoryDump instance. | 33 // base::trace_event::ProcessMemoryDump instance. |
28 class CONTENT_EXPORT WebProcessMemoryDumpImpl final | 34 class CONTENT_EXPORT WebProcessMemoryDumpImpl final |
29 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { | 35 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { |
30 public: | 36 public: |
31 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying | 37 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying |
32 // ProcessMemoryDump. | 38 // ProcessMemoryDump. |
33 WebProcessMemoryDumpImpl(); | 39 WebProcessMemoryDumpImpl(); |
34 | 40 |
35 // Wraps (without owning) an existing ProcessMemoryDump. | 41 // Wraps (without owning) an existing ProcessMemoryDump. |
36 explicit WebProcessMemoryDumpImpl( | 42 explicit WebProcessMemoryDumpImpl( |
| 43 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
37 base::trace_event::ProcessMemoryDump* process_memory_dump); | 44 base::trace_event::ProcessMemoryDump* process_memory_dump); |
38 | 45 |
39 ~WebProcessMemoryDumpImpl() override; | 46 ~WebProcessMemoryDumpImpl() override; |
40 | 47 |
41 // blink::WebProcessMemoryDump implementation. | 48 // blink::WebProcessMemoryDump implementation. |
42 blink::WebMemoryAllocatorDump* createMemoryAllocatorDump( | 49 blink::WebMemoryAllocatorDump* createMemoryAllocatorDump( |
43 const blink::WebString& absolute_name) override; | 50 const blink::WebString& absolute_name) override; |
44 blink::WebMemoryAllocatorDump* createMemoryAllocatorDump( | 51 blink::WebMemoryAllocatorDump* createMemoryAllocatorDump( |
45 const blink::WebString& absolute_name, | 52 const blink::WebString& absolute_name, |
46 blink::WebMemoryAllocatorDumpGuid guid) override; | 53 blink::WebMemoryAllocatorDumpGuid guid) override; |
47 blink::WebMemoryAllocatorDump* getMemoryAllocatorDump( | 54 blink::WebMemoryAllocatorDump* getMemoryAllocatorDump( |
48 const blink::WebString& absolute_name) const override; | 55 const blink::WebString& absolute_name) const override; |
49 void clear() override; | 56 void clear() override; |
50 void takeAllDumpsFrom(blink::WebProcessMemoryDump* other) override; | 57 void takeAllDumpsFrom(blink::WebProcessMemoryDump* other) override; |
51 void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, | 58 void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, |
52 blink::WebMemoryAllocatorDumpGuid target, | 59 blink::WebMemoryAllocatorDumpGuid target, |
53 int importance) override; | 60 int importance) override; |
54 void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, | 61 void AddOwnershipEdge(blink::WebMemoryAllocatorDumpGuid source, |
55 blink::WebMemoryAllocatorDumpGuid target) override; | 62 blink::WebMemoryAllocatorDumpGuid target) override; |
| 63 virtual void AddSuballocation( |
| 64 blink::WebMemoryAllocatorDumpGuid source, |
| 65 const blink::WebString& targetNodeName) override; |
| 66 virtual SkTraceMemoryDump* CreateDumpAdapterForSkia( |
| 67 const blink::WebString& dumpNamePrefix) override; |
56 | 68 |
57 const base::trace_event::ProcessMemoryDump* process_memory_dump() const { | 69 const base::trace_event::ProcessMemoryDump* process_memory_dump() const { |
58 return process_memory_dump_; | 70 return process_memory_dump_; |
59 } | 71 } |
60 | 72 |
61 private: | 73 private: |
62 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest, IntegrationTest); | 74 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest, IntegrationTest); |
63 | 75 |
64 blink::WebMemoryAllocatorDump* createWebMemoryAllocatorDump( | 76 blink::WebMemoryAllocatorDump* createWebMemoryAllocatorDump( |
65 base::trace_event::MemoryAllocatorDump* memory_allocator_dump); | 77 base::trace_event::MemoryAllocatorDump* memory_allocator_dump); |
66 | 78 |
67 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor). | 79 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor). |
68 scoped_ptr<base::trace_event::ProcessMemoryDump> owned_process_memory_dump_; | 80 scoped_ptr<base::trace_event::ProcessMemoryDump> owned_process_memory_dump_; |
69 | 81 |
70 // The underlying ProcessMemoryDump instance to which the | 82 // The underlying ProcessMemoryDump instance to which the |
71 // createMemoryAllocatorDump() calls will be proxied to. | 83 // createMemoryAllocatorDump() calls will be proxied to. |
72 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. | 84 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. |
73 | 85 |
| 86 // TODO(ssid): Remove it once this information is added to ProcessMemoryDump. |
| 87 base::trace_event::MemoryDumpLevelOfDetail level_of_detail_; |
| 88 |
74 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. | 89 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. |
75 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer | 90 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer |
76 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call. | 91 // 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 | 92 // Those pointers are valid only within the scope of the call and can be |
78 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. | 93 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. |
79 base::ScopedPtrHashMap<base::trace_event::MemoryAllocatorDump*, | 94 base::ScopedPtrHashMap<base::trace_event::MemoryAllocatorDump*, |
80 scoped_ptr<WebMemoryAllocatorDumpImpl>> | 95 scoped_ptr<WebMemoryAllocatorDumpImpl>> |
81 memory_allocator_dumps_; | 96 memory_allocator_dumps_; |
82 | 97 |
| 98 // Stores SkTraceMemoryDump for the current ProcessMemoryDump. |
| 99 ScopedVector<skia::SkTraceMemoryDump_Chrome> sk_trace_dump_list_; |
| 100 |
83 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); | 101 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); |
84 }; | 102 }; |
85 | 103 |
86 } // namespace content | 104 } // namespace content |
87 | 105 |
88 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 106 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ |
OLD | NEW |