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_MEMORY_DUMP_REQUEST_ARGS_H_
      6 #define BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_
      7 
      8 // This file defines the types and structs used to issue memory dump requests.
      9 // These are also used in the IPCs for coordinating inter-process memory dumps.
     10 
     11 #include <stdint.h>
     12 #include <string>
     13 
     14 #include "base/base_export.h"
     15 #include "base/callback.h"
     16 
     17 namespace base {
     18 namespace trace_event {
     19 
     20 // Captures the reason why a memory dump is being requested. This is to allow
     21 // selective enabling of dumps, filtering and post-processing.
     22 enum class MemoryDumpType {
     23   TASK_BEGIN,         // Dumping memory at the beginning of a message-loop task.
     24   TASK_END,           // Dumping memory at the ending of a message-loop task.
     25   PERIODIC_INTERVAL,  // Dumping memory at periodic intervals.
     26   EXPLICITLY_TRIGGERED,  // Non maskable dump request.
     27   LAST = EXPLICITLY_TRIGGERED // For IPC macros.
     28 };
     29 
     30 // Tells the MemoryDumpProvider(s) how much detailed their dumps should be.
     31 // MemoryDumpProvider instances must guarantee that level of detail does not
     32 // affect the total size reported in the root node, but only the granularity of
     33 // the child MemoryAllocatorDump(s).
     34 enum class MemoryDumpLevelOfDetail {
     35   LIGHT,           // Few entries, typically a fixed number, per dump.
     36   DETAILED,        // Unrestricted amount of entries per dump.
     37   LAST = DETAILED  // For IPC Macros.
     38 };
     39 
     40 // Initial request arguments for a global memory dump. (see
     41 // MemoryDumpManager::RequestGlobalMemoryDump()).
     42 struct BASE_EXPORT MemoryDumpRequestArgs {
     43   // Globally unique identifier. In multi-process dumps, all processes issue a
     44   // local dump with the same guid. This allows the trace importers to
     45   // reconstruct the global dump.
     46   uint64_t dump_guid;
     47 
     48   MemoryDumpType dump_type;
     49   MemoryDumpLevelOfDetail level_of_detail;
     50 };
     51 
     52 using MemoryDumpCallback = Callback<void(uint64_t dump_guid, bool success)>;
     53 
     54 BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type);
     55 
     56 BASE_EXPORT const char* MemoryDumpLevelOfDetailToString(
     57     const MemoryDumpLevelOfDetail& level_of_detail);
     58 
     59 BASE_EXPORT MemoryDumpLevelOfDetail
     60 StringToMemoryDumpLevelOfDetail(const std::string& str);
     61 
     62 }  // namespace trace_event
     63 }  // namespace base
     64 
     65 #endif  // BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_
     66