Chromium Code Reviews| Index: base/trace_event/java_heap_dump_provider_android.cc |
| diff --git a/base/trace_event/java_heap_dump_provider_android.cc b/base/trace_event/java_heap_dump_provider_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3517f76b8039cfa21b0eabbaae3ce34a8eb7758f |
| --- /dev/null |
| +++ b/base/trace_event/java_heap_dump_provider_android.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/trace_event/java_heap_dump_provider_android.h" |
| + |
| +#include "base/android/java_runtime.h" |
| +#include "base/trace_event/process_memory_dump.h" |
| + |
| +namespace base { |
| +namespace trace_event { |
| + |
| +namespace { |
| + |
| +const char kDumperFriendlyName[] = "AndroidJavaHeap"; |
|
Primiano Tucci (use gerrit)
2015/04/21 18:36:01
just "Java Heap"
ssid
2015/04/22 10:40:11
Done.
|
| +const char kDumperName[] = "android_java_heap"; |
|
Primiano Tucci (use gerrit)
2015/04/21 18:36:01
"java_heap"
ssid
2015/04/22 10:40:11
Done.
|
| + |
| +} // namespace |
| + |
| +// static |
| +AndrdoiJavaHeapDumpProvider* AndrdoiJavaHeapDumpProvider::GetInstance() { |
|
Primiano Tucci (use gerrit)
2015/04/21 18:36:01
Just call it JavaHeapDumpProvider, remove android
ssid
2015/04/22 10:40:11
Done.
|
| + return Singleton<AndrdoiJavaHeapDumpProvider, |
| + LeakySingletonTraits<AndrdoiJavaHeapDumpProvider>>::get(); |
| +} |
| + |
| +AndrdoiJavaHeapDumpProvider::AndrdoiJavaHeapDumpProvider() { |
| +} |
| + |
| +AndrdoiJavaHeapDumpProvider::~AndrdoiJavaHeapDumpProvider() { |
| +} |
| + |
| +// Called at trace dump point time. Creates a snapshot with the memory counters |
| +// for the current process. |
| +bool AndrdoiJavaHeapDumpProvider::DumpInto(ProcessMemoryDump* pmd) { |
| + MemoryAllocatorDump* dump = |
| + pmd->CreateAllocatorDump(kDumperName, MemoryAllocatorDump::kRootHeap); |
| + |
| + // The total size used by java heap and available memory out of the total that |
|
Primiano Tucci (use gerrit)
2015/04/21 18:36:01
I'd probably just say:
"These numbers come from ja
ssid
2015/04/22 10:40:11
Done.
|
| + // can be allocated for objects are obtained from java.lang.Runtime object. |
| + long total_heap_memory, free_heap_memory; |
|
Primiano Tucci (use gerrit)
2015/04/21 18:36:01
remove "memory", as should be pretty clear.
just t
Primiano Tucci (use gerrit)
2015/04/21 18:36:01
Initialize them to zero.
Also I think that our cod
ssid
2015/04/22 10:40:11
Done.
|
| + android::JavaRuntime::GetMemoryUsage(&total_heap_memory, &free_heap_memory); |
| + dump->set_physical_size_in_bytes(total_heap_memory); |
| + dump->set_allocated_objects_count(0); |
| + dump->set_allocated_objects_size_in_bytes(total_heap_memory - |
| + free_heap_memory); |
| + return true; |
| +} |
| + |
| +const char* AndrdoiJavaHeapDumpProvider::GetFriendlyName() const { |
| + return kDumperFriendlyName; |
| +} |
| + |
| +} // namespace trace_event |
| +} // namespace base |