1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "third_party/blink/renderer/platform/instrumentation/instance_counters_memory_dump_provider.h" 6 7 #include "base/trace_event/process_memory_dump.h" 8 #include "third_party/blink/renderer/platform/instrumentation/instance_counters.h" 9 #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" 10 11 namespace blink { 12 13 InstanceCountersMemoryDumpProvider* Instance()14InstanceCountersMemoryDumpProvider::Instance() { 15 DEFINE_STATIC_LOCAL(InstanceCountersMemoryDumpProvider, instance, ()); 16 return &instance; 17 } 18 OnMemoryDump(const base::trace_event::MemoryDumpArgs & args,base::trace_event::ProcessMemoryDump * memory_dump)19bool InstanceCountersMemoryDumpProvider::OnMemoryDump( 20 const base::trace_event::MemoryDumpArgs& args, 21 base::trace_event::ProcessMemoryDump* memory_dump) { 22 using base::trace_event::MemoryAllocatorDump; 23 #define DUMP_COUNTER(CounterType) \ 24 memory_dump->CreateAllocatorDump("blink_objects/" #CounterType) \ 25 ->AddScalar("object_count", MemoryAllocatorDump::kUnitsObjects, \ 26 InstanceCounters::CounterValue( \ 27 InstanceCounters::k##CounterType##Counter)); 28 INSTANCE_COUNTERS_LIST(DUMP_COUNTER) 29 return true; 30 } 31 32 } // namespace blink 33