Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: content/public/browser/background_tracing_config.h

Issue 1089253003: Re-land first pass BackgroundTracingManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split into multiple files in content/public/browser. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_CONFIG_H_
6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_CONFIG_H_
7
8 #include "base/memory/ref_counted_memory.h"
9 #include "base/trace_event/trace_event_impl.h"
10 #include "base/values.h"
11 #include "content/common/content_export.h"
12
13 namespace content {
14
15 // BackgroundTracingConfig is passed to the BackgroundTracingManager to
16 // setup the trigger rules used to enable/disable background tracing.
17 class CONTENT_EXPORT BackgroundTracingConfig
18 : public base::RefCountedThreadSafe<BackgroundTracingConfig> {
19 public:
20 enum Mode {
no sievers 2015/05/11 21:13:27 each interface/struct/enum should be in a separate
shatch 2015/05/12 21:00:05 Yeah I saw that rule but wasn't clear if that also
21 PREEMPTIVE_TRACING_MODE,
22 REACTIVE_TRACING_MODE,
23 };
24 enum CategoryPreset {
25 BENCHMARK,
26 BENCHMARK_DEEP,
27 };
28
29 Mode mode() const;
30
31 static BackgroundTracingConfig* FromDict(const base::DictionaryValue* dict);
32 void IntoDict(base::DictionaryValue* dict);
33
34 protected:
35 friend class base::RefCountedThreadSafe<BackgroundTracingConfig>;
36
37 BackgroundTracingConfig(Mode mode);
38 virtual ~BackgroundTracingConfig();
39
40 Mode mode_;
41 };
42
43 // BackgroundTracingPreemptiveConfig holds trigger rules for use during
44 // preemptive tracing. Tracing will be enabled immediately, and whenever
45 // a trigger occurs, the trace will be finalized.
46 class CONTENT_EXPORT BackgroundTracingPreemptiveConfig
47 : public BackgroundTracingConfig {
48 public:
49 BackgroundTracingPreemptiveConfig();
50
51 enum RuleType {
52 MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED,
53 MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE,
54 MONITOR_AND_DUMP_WHEN_BROWSER_STARTED,
55 };
56 struct HistogramTriggerInfo {
57 std::string histogram_name_to_trigger_on;
58 int histogram_bin_to_trigger_on;
59 };
60 struct NamedTriggerInfo {
61 std::string trigger_name;
62 };
63 struct MonitoringRule {
64 RuleType type;
65 HistogramTriggerInfo histogram_trigger_info;
66 NamedTriggerInfo named_trigger_info;
67 };
68
69 void AddHistogramTriggerRule(const std::string& histogram_name,
70 int histogram_bin);
71 void AddNamedTriggerRule(const std::string& trigger_name);
72
73 CategoryPreset category_preset() const;
74 const std::vector<MonitoringRule>& configs() const;
75
76 static BackgroundTracingPreemptiveConfig* FromDict(
77 const base::DictionaryValue* dict);
78 void AsDict(base::DictionaryValue* dict);
79
80 protected:
81 ~BackgroundTracingPreemptiveConfig() override;
82
83 std::vector<MonitoringRule> configs_;
84 CategoryPreset category_preset_;
85 };
86
87 // BackgroundTracingReactiveConfig holds trigger rules for use during
88 // reactive tracing. Tracing will be not be enabled immediately, rather
89 // the BackgroundTracingManager will wait for a trigger to occur, and
90 // enable tracing at that point. Tracing will be finalized later, either
91 // after some time has elapsed or the trigger occurs again.
92 class CONTENT_EXPORT BackgroundTracingReactiveConfig
93 : public BackgroundTracingConfig {
94 public:
95 BackgroundTracingReactiveConfig();
96
97 enum RuleType { TRACE_ON_TRIGGER_UNTIL_10S_OR_NEXT_TRIGGER_OR_FULL };
98 struct TracingRule {
99 RuleType type;
100 std::string trigger_name;
101 CategoryPreset category_preset;
102 };
103
104 void AddTracingRule(RuleType rule_type,
105 const char* trigger_name,
106 CategoryPreset category_preset);
107
108 static BackgroundTracingReactiveConfig* FromDict(
109 const base::DictionaryValue* dict);
110 void AsDict(base::DictionaryValue* dict);
111
112 protected:
113 ~BackgroundTracingReactiveConfig() override;
114
115 std::vector<TracingRule> configs;
116 };
117
118 } // namespace content
119
120 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698