• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TRACE_CONFIG_MEMORY_TEST_UTIL_H_
6 #define BASE_TRACE_EVENT_TRACE_CONFIG_MEMORY_TEST_UTIL_H_
7 
8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/memory_dump_manager.h"
10 
11 namespace base {
12 namespace trace_event {
13 
14 class TraceConfigMemoryTestUtil {
15  public:
GetTraceConfig_PeriodicTriggers(int light_period,int heavy_period)16   static std::string GetTraceConfig_PeriodicTriggers(int light_period,
17                                                      int heavy_period) {
18     return StringPrintf(
19         "{"
20           "\"enable_argument_filter\":false,"
21           "\"enable_sampling\":false,"
22           "\"enable_systrace\":false,"
23           "\"included_categories\":["
24             "\"%s\""
25           "],"
26           "\"memory_dump_config\":{"
27              "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
28              "\"heap_profiler_options\":{"
29                "\"breakdown_threshold_bytes\":2048"
30              "},"
31              "\"triggers\":["
32               "{"
33                 "\"mode\":\"light\","
34                 "\"periodic_interval_ms\":%d"
35               "},"
36               "{"
37                 "\"mode\":\"detailed\","
38                 "\"periodic_interval_ms\":%d"
39               "}"
40             "]"
41           "},"
42           "\"record_mode\":\"record-until-full\""
43         "}", MemoryDumpManager::kTraceCategory, light_period, heavy_period);
44   }
45 
GetTraceConfig_EmptyTriggers()46   static std::string GetTraceConfig_EmptyTriggers() {
47     return StringPrintf(
48         "{"
49           "\"enable_argument_filter\":false,"
50           "\"enable_sampling\":false,"
51           "\"enable_systrace\":false,"
52           "\"included_categories\":["
53             "\"%s\""
54           "],"
55           "\"memory_dump_config\":{"
56             "\"allowed_dump_modes\":[\"background\",\"light\",\"detailed\"],"
57             "\"triggers\":["
58             "]"
59           "},"
60           "\"record_mode\":\"record-until-full\""
61         "}", MemoryDumpManager::kTraceCategory);
62   }
63 
GetTraceConfig_NoTriggers()64   static std::string GetTraceConfig_NoTriggers() {
65     return StringPrintf(
66         "{"
67           "\"enable_argument_filter\":false,"
68           "\"enable_sampling\":false,"
69           "\"enable_systrace\":false,"
70           "\"included_categories\":["
71             "\"%s\""
72           "],"
73           "\"record_mode\":\"record-until-full\""
74         "}", MemoryDumpManager::kTraceCategory);
75   }
76 
GetTraceConfig_BackgroundTrigger(int period_ms)77   static std::string GetTraceConfig_BackgroundTrigger(int period_ms) {
78     return StringPrintf(
79         "{"
80           "\"enable_argument_filter\":false,"
81           "\"enable_sampling\":false,"
82           "\"enable_systrace\":false,"
83           "\"included_categories\":["
84             "\"%s\""
85           "],"
86           "\"memory_dump_config\":{"
87              "\"allowed_dump_modes\":[\"background\"],"
88              "\"triggers\":["
89               "{"
90                 "\"mode\":\"background\","
91                 "\"periodic_interval_ms\":%d"
92               "}"
93             "]"
94           "},"
95           "\"record_mode\":\"record-until-full\""
96         "}", MemoryDumpManager::kTraceCategory, period_ms);
97   }
98 };
99 
100 }  // namespace trace_event
101 }  // namespace base
102 
103 #endif  // BASE_TRACE_EVENT_TRACE_CONFIG_MEMORY_TEST_UTIL_H_
104