1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155

base / trace_event / trace_config_memory_test_util.h [blame]

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_TRACE_EVENT_TRACE_CONFIG_MEMORY_TEST_UTIL_H_
#define BASE_TRACE_EVENT_TRACE_CONFIG_MEMORY_TEST_UTIL_H_

#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_dump_manager.h"

namespace base {
namespace trace_event {

class TraceConfigMemoryTestUtil {
 public:
  static std::string GetTraceConfig_LegacyPeriodicTriggers(int light_period,
                                                           int heavy_period) {
    return StringPrintf(
        "{"
        "\"enable_argument_filter\":false,"
        "\"enable_package_name_filter\":false,"
        "\"enable_systrace\":false,"
        "\"excluded_categories\":["
        "\"*\""
        "],"
        "\"included_categories\":["
        "\"%s\""
        "],"
        "\"memory_dump_config\":{"
        "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
        "\"heap_profiler_options\":{"
        "\"breakdown_threshold_bytes\":2048"
        "},"
        "\"triggers\":["
        "{"
        "\"mode\":\"light\","
        "\"periodic_interval_ms\":%d"
        "},"
        "{"
        "\"mode\":\"detailed\","
        "\"periodic_interval_ms\":%d"
        "}"
        "]"
        "},"
        "\"record_mode\":\"record-until-full\""
        "}",
        MemoryDumpManager::kTraceCategory, light_period, heavy_period);
  }

  static std::string GetTraceConfig_PeriodicTriggers(int light_period,
                                                     int heavy_period) {
    return StringPrintf(
        "{"
        "\"enable_argument_filter\":false,"
        "\"enable_package_name_filter\":false,"
        "\"enable_systrace\":false,"
        "\"excluded_categories\":["
        "\"*\""
        "],"
        "\"included_categories\":["
        "\"%s\""
        "],"
        "\"memory_dump_config\":{"
        "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
        "\"heap_profiler_options\":{"
        "\"breakdown_threshold_bytes\":2048"
        "},"
        "\"triggers\":["
        "{"
        "\"min_time_between_dumps_ms\":%d,"
        "\"mode\":\"light\","
        "\"type\":\"periodic_interval\""
        "},"
        "{"
        "\"min_time_between_dumps_ms\":%d,"
        "\"mode\":\"detailed\","
        "\"type\":\"periodic_interval\""
        "}"
        "]"
        "},"
        "\"record_mode\":\"record-until-full\""
        "}",
        MemoryDumpManager::kTraceCategory, light_period, heavy_period);
  }

  static std::string GetTraceConfig_EmptyTriggers() {
    return StringPrintf(
        "{"
        "\"enable_argument_filter\":false,"
        "\"enable_package_name_filter\":false,"
        "\"enable_systrace\":false,"
        "\"excluded_categories\":["
        "\"*\""
        "],"
        "\"included_categories\":["
        "\"%s\""
        "],"
        "\"memory_dump_config\":{"
        "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
        "\"triggers\":["
        "]"
        "},"
        "\"record_mode\":\"record-until-full\""
        "}",
        MemoryDumpManager::kTraceCategory);
  }

  static std::string GetTraceConfig_NoTriggers() {
    return StringPrintf(
        "{"
        "\"enable_argument_filter\":false,"
        "\"enable_systrace\":false,"
        "\"excluded_categories\":["
        "\"*\""
        "],"
        "\"included_categories\":["
        "\"%s\""
        "],"
        "\"record_mode\":\"record-until-full\""
        "}",
        MemoryDumpManager::kTraceCategory);
  }

  static std::string GetTraceConfig_BackgroundTrigger(int period_ms) {
    return StringPrintf(
        "{"
        "\"enable_argument_filter\":false,"
        "\"enable_package_name_filter\":false,"
        "\"enable_systrace\":false,"
        "\"excluded_categories\":["
        "\"*\""
        "],"
        "\"included_categories\":["
        "\"%s\""
        "],"
        "\"memory_dump_config\":{"
        "\"allowed_dump_modes\":[\"background\"],"
        "\"triggers\":["
        "{"
        "\"min_time_between_dumps_ms\":%d,"
        "\"mode\":\"background\","
        "\"type\":\"periodic_interval\""
        "}"
        "]"
        "},"
        "\"record_mode\":\"record-until-full\""
        "}",
        MemoryDumpManager::kTraceCategory, period_ms);
  }
};

}  // namespace trace_event
}  // namespace base

#endif  // BASE_TRACE_EVENT_TRACE_CONFIG_MEMORY_TEST_UTIL_H_