Home | History | Annotate | Download | only in trace_event
      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 BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
      6 #define BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
      7 
      8 #include <istream>
      9 
     10 #include "base/macros.h"
     11 #include "base/memory/singleton.h"
     12 #include "base/trace_event/memory_dump_provider.h"
     13 #include "build/build_config.h"
     14 
     15 #if defined(OS_LINUX) || defined(OS_ANDROID) || \
     16     (defined(OS_MACOSX) && !defined(OS_IOS))
     17 #define MALLOC_MEMORY_TRACING_SUPPORTED
     18 #endif
     19 
     20 namespace base {
     21 namespace trace_event {
     22 
     23 // Dump provider which collects process-wide memory stats.
     24 class BASE_EXPORT MallocDumpProvider : public MemoryDumpProvider {
     25  public:
     26   // Name of the allocated_objects dump. Use this to declare suballocator dumps
     27   // from other dump providers.
     28   static const char kAllocatedObjects[];
     29 
     30   static MallocDumpProvider* GetInstance();
     31 
     32   // MemoryDumpProvider implementation.
     33   bool OnMemoryDump(const MemoryDumpArgs& args,
     34                     ProcessMemoryDump* pmd) override;
     35 
     36  private:
     37   friend struct DefaultSingletonTraits<MallocDumpProvider>;
     38 
     39   MallocDumpProvider();
     40   ~MallocDumpProvider() override;
     41 
     42   DISALLOW_COPY_AND_ASSIGN(MallocDumpProvider);
     43 };
     44 
     45 }  // namespace trace_event
     46 }  // namespace base
     47 
     48 #endif  // BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
     49