Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / base / trace_event / java_heap_dump_provider_android.cc
blob2a84b81b8db1ffd13852e1a5c830390e075b5989
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
3 // found in the LICENSE file.
5 #include "base/trace_event/java_heap_dump_provider_android.h"
7 #include "base/android/java_runtime.h"
8 #include "base/trace_event/process_memory_dump.h"
10 namespace base {
11 namespace trace_event {
13 // static
14 JavaHeapDumpProvider* JavaHeapDumpProvider::GetInstance() {
15 return Singleton<JavaHeapDumpProvider,
16 LeakySingletonTraits<JavaHeapDumpProvider>>::get();
19 JavaHeapDumpProvider::JavaHeapDumpProvider() {
22 JavaHeapDumpProvider::~JavaHeapDumpProvider() {
25 // Called at trace dump point time. Creates a snapshot with the memory counters
26 // for the current process.
27 bool JavaHeapDumpProvider::OnMemoryDump(ProcessMemoryDump* pmd) {
28 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump("java_heap");
30 // These numbers come from java.lang.Runtime stats.
31 long total_heap_size = 0;
32 long free_heap_size = 0;
33 android::JavaRuntime::GetMemoryUsage(&total_heap_size, &free_heap_size);
34 dump->AddScalar(MemoryAllocatorDump::kNameOuterSize,
35 MemoryAllocatorDump::kUnitsBytes, total_heap_size);
36 dump->AddScalar(MemoryAllocatorDump::kNameInnerSize,
37 MemoryAllocatorDump::kUnitsBytes,
38 total_heap_size - free_heap_size);
39 return true;
42 } // namespace trace_event
43 } // namespace base