| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #ifndef MemoryCacheDumpProvider_h |
| 6 #define MemoryCacheDumpProvider_h |
| 7 |
| 8 #include "base/trace_event/memory_dump_provider.h" |
| 9 #include "base/trace_event/process_memory_dump.h" |
| 10 #include "platform/PlatformExport.h" |
| 11 #include "platform/heap/Handle.h" |
| 12 #include "public/platform/WebProcessMemoryDump.h" |
| 13 #include "wtf/Allocator.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class PLATFORM_EXPORT MemoryCacheDumpClient : public GarbageCollectedMixin { |
| 18 public: |
| 19 virtual ~MemoryCacheDumpClient() { } |
| 20 virtual bool onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*)
= 0; |
| 21 |
| 22 DECLARE_VIRTUAL_TRACE(); |
| 23 }; |
| 24 |
| 25 // This class is wrapper around MemoryCache to take memory snapshots. It dumps |
| 26 // the stats of cache only after the cache is created. |
| 27 class PLATFORM_EXPORT MemoryCacheDumpProvider final : public base::trace_event::
MemoryDumpProvider { |
| 28 USING_FAST_MALLOC(MemoryCacheDumpProvider); |
| 29 public: |
| 30 // This class is singleton since there is a global MemoryCache object. |
| 31 static MemoryCacheDumpProvider* instance(); |
| 32 ~MemoryCacheDumpProvider() override; |
| 33 |
| 34 // base::trace_event::MemoryDumpProvider implementation. |
| 35 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs&, base::trace_even
t::ProcessMemoryDump*) override; |
| 36 |
| 37 void setMemoryCache(MemoryCacheDumpClient* client) |
| 38 { |
| 39 DCHECK(isMainThread()); |
| 40 m_client = client; |
| 41 } |
| 42 |
| 43 private: |
| 44 MemoryCacheDumpProvider(); |
| 45 |
| 46 WeakPersistent<MemoryCacheDumpClient> m_client; |
| 47 |
| 48 WTF_MAKE_NONCOPYABLE(MemoryCacheDumpProvider); |
| 49 }; |
| 50 |
| 51 } // namespace blink |
| 52 |
| 53 #endif // MemoryCacheDumpProvider_h |
| OLD | NEW |