| 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 BlinkGCMemoryDumpProvider_h | 5 #ifndef BlinkGCMemoryDumpProvider_h |
| 6 #define BlinkGCMemoryDumpProvider_h | 6 #define BlinkGCMemoryDumpProvider_h |
| 7 | 7 |
| 8 #include "base/trace_event/memory_dump_provider.h" |
| 8 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
| 9 #include "platform/heap/BlinkGC.h" | 10 #include "platform/heap/BlinkGC.h" |
| 10 #include "public/platform/WebMemoryDumpProvider.h" | 11 #include "public/platform/WebMemoryDumpProvider.h" |
| 11 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
| 12 #include "wtf/OwnPtr.h" | |
| 13 #include "wtf/ThreadingPrimitives.h" | 13 #include "wtf/ThreadingPrimitives.h" |
| 14 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 namespace trace_event { | 17 namespace trace_event { |
| 18 | 18 |
| 19 class AllocationRegister; | 19 class AllocationRegister; |
| 20 class MemoryAllocatorDump; |
| 20 | 21 |
| 21 } // namespace trace_event | 22 } // namespace trace_event |
| 22 } // namespace base | 23 } // namespace base |
| 23 | 24 |
| 24 namespace blink { | 25 namespace blink { |
| 25 class WebMemoryAllocatorDump; | 26 class WebMemoryAllocatorDump; |
| 26 | 27 |
| 27 class PLATFORM_EXPORT BlinkGCMemoryDumpProvider final : public WebMemoryDumpProv
ider { | 28 class PLATFORM_EXPORT BlinkGCMemoryDumpProvider final : public base::trace_event
::MemoryDumpProvider { |
| 28 USING_FAST_MALLOC(BlinkGCMemoryDumpProvider); | 29 USING_FAST_MALLOC(BlinkGCMemoryDumpProvider); |
| 29 public: | 30 public: |
| 30 static BlinkGCMemoryDumpProvider* instance(); | 31 static BlinkGCMemoryDumpProvider* instance(); |
| 31 ~BlinkGCMemoryDumpProvider() override; | 32 ~BlinkGCMemoryDumpProvider() override; |
| 32 | 33 |
| 33 // WebMemoryDumpProvider implementation. | 34 // MemoryDumpProvider implementation. |
| 34 bool onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) overrid
e; | 35 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs&, base::trace_even
t::ProcessMemoryDump*) override; |
| 35 bool supportsHeapProfiling() override { return true; } | 36 void OnHeapProfilingEnabled(bool) override; |
| 36 void onHeapProfilingEnabled(bool) override; | |
| 37 | 37 |
| 38 // The returned WebMemoryAllocatorDump is owned by | 38 // The returned WebMemoryAllocatorDump is owned by |
| 39 // BlinkGCMemoryDumpProvider, and should not be retained (just used to | 39 // BlinkGCMemoryDumpProvider, and should not be retained (just used to |
| 40 // dump in the current call stack). | 40 // dump in the current call stack). |
| 41 WebMemoryAllocatorDump* createMemoryAllocatorDumpForCurrentGC(const String&
absoluteName); | 41 base::trace_event::MemoryAllocatorDump* createMemoryAllocatorDumpForCurrentG
C(const String& absoluteName); |
| 42 | 42 |
| 43 // This must be called before taking a new process-wide GC snapshot, to | 43 // This must be called before taking a new process-wide GC snapshot, to |
| 44 // clear the previous dumps. | 44 // clear the previous dumps. |
| 45 void clearProcessDumpForCurrentGC(); | 45 void clearProcessDumpForCurrentGC(); |
| 46 | 46 |
| 47 WebProcessMemoryDump* currentProcessMemoryDump() { return m_currentProcessMe
moryDump.get(); } | 47 base::trace_event::ProcessMemoryDump* currentProcessMemoryDump() { return m_
currentProcessMemoryDump.get(); } |
| 48 | 48 |
| 49 void insert(Address, size_t, const char*); | 49 void insert(Address, size_t, const char*); |
| 50 void remove(Address); | 50 void remove(Address); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 BlinkGCMemoryDumpProvider(); | 53 BlinkGCMemoryDumpProvider(); |
| 54 | 54 |
| 55 Mutex m_allocationRegisterMutex; | 55 Mutex m_allocationRegisterMutex; |
| 56 OwnPtr<base::trace_event::AllocationRegister> m_allocationRegister; | 56 std::unique_ptr<base::trace_event::AllocationRegister> m_allocationRegister; |
| 57 OwnPtr<WebProcessMemoryDump> m_currentProcessMemoryDump; | 57 std::unique_ptr<base::trace_event::ProcessMemoryDump> m_currentProcessMemory
Dump; |
| 58 bool m_isHeapProfilingEnabled; | 58 bool m_isHeapProfilingEnabled; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace blink | 61 } // namespace blink |
| 62 | 62 |
| 63 #endif | 63 #endif |
| OLD | NEW |