Chromium Code Reviews| 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 #include "wtf/Vector.h" | |
| 16 | 15 |
| 17 namespace base { | 16 namespace base { |
| 18 class DiscardableMemory; | 17 class DiscardableMemory; |
| 19 namespace trace_event { | 18 namespace trace_event { |
| 20 class MemoryAllocatorDump; | 19 class MemoryAllocatorDump; |
| 21 class ProcessMemoryDump; | 20 class ProcessMemoryDump; |
| 22 } // namespace base | 21 } // namespace base |
| 23 } // namespace trace_event | 22 } // namespace trace_event |
| 24 | 23 |
| 25 namespace skia { | 24 namespace skia { |
| 26 class SkiaTraceMemoryDumpImpl; | 25 class SkiaTraceMemoryDumpImpl; |
| 27 } // namespace skia | 26 } // namespace skia |
| 28 | 27 |
| 29 namespace content { | 28 namespace blink { |
| 30 | 29 |
| 31 class WebMemoryAllocatorDumpImpl; | 30 class WebMemoryAllocatorDumpImpl; |
| 32 | 31 |
| 33 // Implements the blink::WebProcessMemoryDump interface by means of proxying the | 32 // Implements the blink::WebProcessMemoryDump interface by means of proxying the |
| 34 // calls to createMemoryAllocatorDump() to the underlying | 33 // calls to createMemoryAllocatorDump() to the underlying |
| 35 // base::trace_event::ProcessMemoryDump instance. | 34 // base::trace_event::ProcessMemoryDump instance. |
| 36 class CONTENT_EXPORT WebProcessMemoryDumpImpl final | 35 class BLINK_EXPORT WebProcessMemoryDumpImpl final |
| 37 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { | 36 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump) { |
| 38 public: | 37 public: |
| 39 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying | 38 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying |
| 40 // ProcessMemoryDump. | 39 // ProcessMemoryDump. |
| 41 WebProcessMemoryDumpImpl(); | 40 WebProcessMemoryDumpImpl(); |
| 42 | 41 |
| 43 // Wraps (without owning) an existing ProcessMemoryDump. | 42 // Wraps (without owning) an existing ProcessMemoryDump. |
| 44 explicit WebProcessMemoryDumpImpl( | 43 explicit WebProcessMemoryDumpImpl( |
| 45 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, | 44 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
| 46 base::trace_event::ProcessMemoryDump* process_memory_dump); | 45 base::trace_event::ProcessMemoryDump* process_memory_dump); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 base::trace_event::TraceEventMemoryOverhead& overhead, | 80 base::trace_event::TraceEventMemoryOverhead& overhead, |
| 82 const char* allocator_name) override; | 81 const char* allocator_name) override; |
| 83 | 82 |
| 84 private: | 83 private: |
| 85 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest, IntegrationTest); | 84 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest, IntegrationTest); |
| 86 | 85 |
| 87 blink::WebMemoryAllocatorDump* createWebMemoryAllocatorDump( | 86 blink::WebMemoryAllocatorDump* createWebMemoryAllocatorDump( |
| 88 base::trace_event::MemoryAllocatorDump* memory_allocator_dump); | 87 base::trace_event::MemoryAllocatorDump* memory_allocator_dump); |
| 89 | 88 |
| 90 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor). | 89 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor). |
| 91 scoped_ptr<base::trace_event::ProcessMemoryDump> owned_process_memory_dump_; | 90 WTF::OwnPtr<base::trace_event::ProcessMemoryDump> owned_process_memory_dump_; |
|
haraken
2016/02/15 09:40:49
It looks strange to use WTF::OwnPtr for Chromium c
hajimehoshi
2016/02/18 11:21:53
You mean we should use smart pointers in base for
| |
| 92 | 91 |
| 93 // The underlying ProcessMemoryDump instance to which the | 92 // The underlying ProcessMemoryDump instance to which the |
| 94 // createMemoryAllocatorDump() calls will be proxied to. | 93 // createMemoryAllocatorDump() calls will be proxied to. |
| 95 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. | 94 base::trace_event::ProcessMemoryDump* process_memory_dump_; // Not owned. |
| 96 | 95 |
| 97 // TODO(ssid): Remove it once this information is added to ProcessMemoryDump. | 96 // TODO(ssid): Remove it once this information is added to ProcessMemoryDump. |
| 98 base::trace_event::MemoryDumpLevelOfDetail level_of_detail_; | 97 base::trace_event::MemoryDumpLevelOfDetail level_of_detail_; |
| 99 | 98 |
| 100 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. | 99 // Reverse index of MemoryAllocatorDump -> WebMemoryAllocatorDumpImpl wrapper. |
| 101 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer | 100 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer |
| 102 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call. | 101 // 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 | 102 // Those pointers are valid only within the scope of the call and can be |
| 104 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. | 103 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed. |
| 105 base::ScopedPtrHashMap<base::trace_event::MemoryAllocatorDump*, | 104 WTF::HashMap<base::trace_event::MemoryAllocatorDump*, |
| 106 scoped_ptr<WebMemoryAllocatorDumpImpl>> | 105 OwnPtr<WebMemoryAllocatorDumpImpl>> |
| 107 memory_allocator_dumps_; | 106 memory_allocator_dumps_; |
| 108 | 107 |
| 109 // Stores SkTraceMemoryDump for the current ProcessMemoryDump. | 108 // Stores SkTraceMemoryDump for the current ProcessMemoryDump. |
| 110 ScopedVector<skia::SkiaTraceMemoryDumpImpl> sk_trace_dump_list_; | 109 WTF::Vector<WTF::OwnPtr<skia::SkiaTraceMemoryDumpImpl>> sk_trace_dump_list_; |
|
hajimehoshi
2016/02/18 11:21:53
On the other hand, ScopedVector is not permitted i
| |
| 111 | 110 |
| 112 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); | 111 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl); |
| 113 }; | 112 }; |
| 114 | 113 |
| 115 } // namespace content | 114 } // namespace blink |
| 116 | 115 |
| 117 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_ | 116 #endif // WebProcessMemoryDumpImpl_h |
| OLD | NEW |