| 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 #include "platform/heap/BlinkGCMemoryDumpProvider.h" | 5 #include "platform/heap/BlinkGCMemoryDumpProvider.h" | 
| 6 | 6 | 
| 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 
| 8 #include "base/trace_event/heap_profiler_allocation_register.h" | 8 #include "base/trace_event/heap_profiler_allocation_register.h" | 
| 9 #include "base/trace_event/trace_event_memory_overhead.h" | 9 #include "base/trace_event/trace_event_memory_overhead.h" | 
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" | 
|  | 11 #include "platform/web_process_memory_dump_impl.h" | 
| 11 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" | 
| 12 #include "public/platform/WebMemoryAllocatorDump.h" | 13 #include "public/platform/WebMemoryAllocatorDump.h" | 
| 13 #include "public/platform/WebProcessMemoryDump.h" |  | 
| 14 #include "wtf/StdLibExtras.h" | 14 #include "wtf/StdLibExtras.h" | 
| 15 #include "wtf/Threading.h" | 15 #include "wtf/Threading.h" | 
| 16 | 16 | 
| 17 namespace blink { | 17 namespace blink { | 
| 18 namespace { | 18 namespace { | 
| 19 | 19 | 
| 20 void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump) | 20 void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump) | 
| 21 { | 21 { | 
| 22     String dumpName = String::format("blink_gc"); | 22     String dumpName = String::format("blink_gc"); | 
| 23     WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum
     p(dumpName); | 23     WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum
     p(dumpName); | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102 { | 102 { | 
| 103     return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName); | 103     return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName); | 
| 104 } | 104 } | 
| 105 | 105 | 
| 106 void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC() | 106 void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC() | 
| 107 { | 107 { | 
| 108     m_currentProcessMemoryDump->clear(); | 108     m_currentProcessMemoryDump->clear(); | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider() | 111 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider() | 
| 112     : m_currentProcessMemoryDump(adoptPtr(Platform::current()->createProcessMemo
     ryDump())) | 112     : m_currentProcessMemoryDump(adoptPtr(new WebProcessMemoryDumpImpl())) | 
| 113     , m_isHeapProfilingEnabled(false) | 113     , m_isHeapProfilingEnabled(false) | 
| 114 { | 114 { | 
| 115 } | 115 } | 
| 116 | 116 | 
| 117 void BlinkGCMemoryDumpProvider::insert(Address address, size_t size, const char*
      typeName) | 117 void BlinkGCMemoryDumpProvider::insert(Address address, size_t size, const char*
      typeName) | 
| 118 { | 118 { | 
| 119     base::trace_event::AllocationContext context = base::trace_event::Allocation
     ContextTracker::GetContextSnapshot(); | 119     base::trace_event::AllocationContext context = base::trace_event::Allocation
     ContextTracker::GetContextSnapshot(); | 
| 120     context.type_name = typeName; | 120     context.type_name = typeName; | 
| 121     MutexLocker locker(m_allocationRegisterMutex); | 121     MutexLocker locker(m_allocationRegisterMutex); | 
| 122     if (m_allocationRegister) | 122     if (m_allocationRegister) | 
| 123         m_allocationRegister->Insert(address, size, context); | 123         m_allocationRegister->Insert(address, size, context); | 
| 124 } | 124 } | 
| 125 | 125 | 
| 126 void BlinkGCMemoryDumpProvider::remove(Address address) | 126 void BlinkGCMemoryDumpProvider::remove(Address address) | 
| 127 { | 127 { | 
| 128     MutexLocker locker(m_allocationRegisterMutex); | 128     MutexLocker locker(m_allocationRegisterMutex); | 
| 129     if (m_allocationRegister) | 129     if (m_allocationRegister) | 
| 130         m_allocationRegister->Remove(address); | 130         m_allocationRegister->Remove(address); | 
| 131 } | 131 } | 
| 132 | 132 | 
| 133 } // namespace blink | 133 } // namespace blink | 
| OLD | NEW | 
|---|