Chromium Code Reviews| 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 "config.h" | 5 #include "config.h" |
| 6 #include "Source/platform/heap/BlinkGCMemoryDumpProvider.h" | 6 #include "Source/platform/heap/BlinkGCMemoryDumpProvider.h" |
| 7 | 7 |
| 8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 #include "public/platform/Platform.h" | |
| 9 #include "public/platform/WebMemoryAllocatorDump.h" | 10 #include "public/platform/WebMemoryAllocatorDump.h" |
| 10 #include "public/platform/WebProcessMemoryDump.h" | 11 #include "public/platform/WebProcessMemoryDump.h" |
| 11 #include "wtf/StdLibExtras.h" | 12 #include "wtf/StdLibExtras.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 BlinkGCMemoryDumpProvider* BlinkGCMemoryDumpProvider::instance() | 16 BlinkGCMemoryDumpProvider* BlinkGCMemoryDumpProvider::instance() |
| 16 { | 17 { |
| 17 DEFINE_STATIC_LOCAL(BlinkGCMemoryDumpProvider, instance, ()); | 18 DEFINE_STATIC_LOCAL(BlinkGCMemoryDumpProvider, instance, ()); |
| 18 return &instance; | 19 return &instance; |
| 19 } | 20 } |
| 20 | 21 |
| 21 bool BlinkGCMemoryDumpProvider::onMemoryDump(blink::WebProcessMemoryDump* memory Dump) | |
| 22 { | |
| 23 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum p("blink_gc"); | |
| 24 allocatorDump->AddScalar("inner_size", "bytes", Heap::allocatedObjectSize()) ; | |
| 25 allocatorDump->AddScalar("outer_size", "bytes", Heap::allocatedSpace()); | |
| 26 allocatorDump->AddScalar("estimated_live_object_size", "bytes", Heap::estima tedLiveObjectSize()); | |
| 27 return true; | |
| 28 } | |
| 29 | |
| 30 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider() | |
| 31 { | |
| 32 } | |
| 33 | |
| 34 BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider() | 22 BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider() |
| 35 { | 23 { |
| 36 } | 24 } |
| 37 | 25 |
| 26 bool BlinkGCMemoryDumpProvider::onMemoryDump(WebProcessMemoryDump* memoryDump) | |
| 27 { | |
| 28 // The current heap statistics are added to the memory dump. | |
| 29 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum p("blink_gc"); | |
|
Primiano Tucci (use gerrit)
2015/05/22 19:45:57
No need to do in this CL, but I think that, for th
ssid
2015/05/26 11:08:43
Done.
| |
| 30 allocatorDump->AddScalar("inner_size", "bytes", Heap::allocatedObjectSize()) ; | |
| 31 allocatorDump->AddScalar("outer_size", "bytes", Heap::allocatedSpace()); | |
| 32 allocatorDump->AddScalar("estimated_live_object_size", "bytes", Heap::estima tedLiveObjectSize()); | |
| 33 | |
| 34 // If available, the last GC memory statistics are added. | |
| 35 if (m_lastProcessMemoryDump.get()) | |
|
Primiano Tucci (use gerrit)
2015/05/22 19:45:57
nit: OwnPtr, like scoped_ptr, has the implicit-con
ssid
2015/05/26 11:08:42
Done.
| |
| 36 memoryDump->takeAllDumpsFrom(m_lastProcessMemoryDump.get()); | |
| 37 | |
| 38 // TODO(ssid): This should return false in the unlikely case that we didn't | |
| 39 // see a GC yet, which in turn will cause the dump to be invalidated. But, | |
| 40 // right now returning false will stop the manager from getting more dumps | |
| 41 // from this provider. So, always returns true while crbug.com/490783 gets | |
| 42 // fixed. | |
| 43 | |
| 44 return true; | |
| 45 } | |
| 46 | |
| 47 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider() | |
|
Primiano Tucci (use gerrit)
2015/05/22 19:45:57
micro-nit: I think it was right to keep this on th
ssid
2015/05/26 11:08:42
Keeping it in decl order.
| |
| 48 : m_lastProcessMemoryDump(adoptPtr(Platform::current()->createProcessMemoryD ump())) | |
| 49 { | |
| 50 } | |
| 51 | |
| 52 WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForL astGC(const String& absoluteName) | |
| 53 { | |
| 54 return m_lastProcessMemoryDump->createMemoryAllocatorDump(absoluteName); | |
| 55 } | |
| 56 | |
| 57 void BlinkGCMemoryDumpProvider::clearLastProcessMemoryDump() | |
|
Primiano Tucci (use gerrit)
2015/05/22 19:45:57
Nit: +GC (i.e. clearLastGC...)
ssid
2015/05/26 11:08:42
Done.
| |
| 58 { | |
| 59 // TODO(ssid): Once the api for clearing dump is available, use that | |
| 60 // instead of this method here (crbug.com/491248). | |
| 61 m_lastProcessMemoryDump = adoptPtr(Platform::current()->createProcessMemoryD ump()); | |
| 62 } | |
| 63 | |
| 38 } // namespace blink | 64 } // namespace blink |
| OLD | NEW |