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 WebProcessMemoryDumpImpl_h |
6 #define CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 6 #define WebProcessMemoryDumpImpl_h |
7 | 7 |
8 #include "base/containers/scoped_ptr_hash_map.h" | |
9 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
10 #include "base/macros.h" | 9 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/scoped_vector.h" | |
13 #include "base/trace_event/memory_dump_request_args.h" | 10 #include "base/trace_event/memory_dump_request_args.h" |
14 #include "content/common/content_export.h" | 11 #include "public/platform/WebProcessMemoryDump.h" |
15 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h" | 12 #include "wtf/HashMap.h" |
| 13 #include "wtf/OwnPtr.h" |
| 14 |
| 15 #include <map> |
| 16 #include <vector> |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class DiscardableMemory; | 19 class DiscardableMemory; |
19 namespace trace_event { | 20 namespace trace_event { |
20 class MemoryAllocatorDump; | 21 class MemoryAllocatorDump; |
21 class ProcessMemoryDump; | 22 class ProcessMemoryDump; |
22 } // namespace base | 23 } // namespace base |
23 } // namespace trace_event | 24 } // namespace trace_event |
24 | 25 |
25 namespace skia { | 26 namespace skia { |
26 class SkiaTraceMemoryDumpImpl; | 27 class SkiaTraceMemoryDumpImpl; |
27 } // namespace skia | 28 } // namespace skia |
28 | 29 |
29 namespace content { | 30 namespace blink { |
30 | 31 |
31 class WebMemoryAllocatorDumpImpl; | 32 class WebMemoryAllocatorDumpImpl; |
32 | 33 |
33 // Implements the blink::WebProcessMemoryDump interface by means of proxying the | 34 // Implements the blink::WebProcessMemoryDump interface by means of proxying the |
34 // calls to createMemoryAllocatorDump() to the underlying | 35 // calls to createMemoryAllocatorDump() to the underlying |
35 // base::trace_event::ProcessMemoryDump instance. | 36 // base::trace_event::ProcessMemoryDump instance. |
36 class CONTENT_EXPORT WebProcessMemoryDumpImpl final | 37 class BLINK_EXPORT WebProcessMemoryDumpImpl final |
37 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { | 38 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { |
38 public: | 39 public: |
39 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying | 40 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying |
40 // ProcessMemoryDump. | 41 // ProcessMemoryDump. |
41 WebProcessMemoryDumpImpl(); | 42 WebProcessMemoryDumpImpl(); |
42 | 43 |
43 // Wraps (without owning) an existing ProcessMemoryDump. | 44 // Wraps (without owning) an existing ProcessMemoryDump. |
44 explicit WebProcessMemoryDumpImpl( | 45 explicit WebProcessMemoryDumpImpl( |
45 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, | 46 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
46 base::trace_event::ProcessMemoryDump* process_memory_dump); | 47 base::trace_event::ProcessMemoryDump* process_memory_dump); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. | 96 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. |
96 | 97 |
97 // TODO(ssid): Remove it once this information is added to ProcessMemoryDump. | 98 // TODO(ssid): Remove it once this information is added to ProcessMemoryDump. |
98 base::trace_event::MemoryDumpLevelOfDetail level_of_detail_; | 99 base::trace_event::MemoryDumpLevelOfDetail level_of_detail_; |
99 | 100 |
100 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. | 101 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. |
101 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer | 102 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer |
102 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call. | 103 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call. |
103 // Those pointers are valid only within the scope of the call and can be | 104 // Those pointers are valid only within the scope of the call and can be |
104 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. | 105 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. |
105 base::ScopedPtrHashMap<base::trace_event::MemoryAllocatorDump*, | 106 std::unordered_map<base::trace_event::MemoryAllocatorDump*, |
106 scoped_ptr<WebMemoryAllocatorDumpImpl>> | 107 scoped_ptr<WebMemoryAllocatorDumpImpl>> |
107 memory_allocator_dumps_; | 108 memory_allocator_dumps_; |
108 | 109 |
109 // Stores SkTraceMemoryDump for the current ProcessMemoryDump. | 110 // Stores SkTraceMemoryDump for the current ProcessMemoryDump. |
110 ScopedVector<skia::SkiaTraceMemoryDumpImpl> sk_trace_dump_list_; | 111 std::vector<scoped_ptr<skia::SkiaTraceMemoryDumpImpl>> sk_trace_dump_list_; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); | 113 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); |
113 }; | 114 }; |
114 | 115 |
115 } // namespace content | 116 } // namespace blink |
116 | 117 |
117 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 118 #endif // WebProcessMemoryDumpImpl_h |
OLD | NEW |