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