OLD | NEW |
---|---|
(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_MANAGER_H_ | |
6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | |
7 | |
8 #include "base/memory/ref_counted_memory.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/trace_event/trace_event_impl.h" | |
12 #include "base/values.h" | |
13 #include "content/common/content_export.h" | |
14 | |
15 namespace content { | |
16 | |
17 class BackgroundTracingConfig : | |
18 public base::RefCountedThreadSafe<BackgroundTracingConfig> { | |
19 public: | |
20 enum Mode { | |
21 PREEMPTIVE_TRACING_MODE, | |
22 REACTIVE_TRACING_MODE, | |
23 }; | |
24 | |
25 enum CategoryPreset { | |
26 BENCHMARK, | |
27 BENCHMARK_DEEP, | |
28 }; | |
29 | |
30 BackgroundTracingConfig(Mode); | |
31 | |
32 Mode mode; | |
oystein (OOO til 10th of July)
2015/05/05 19:28:31
private or in the impl maybe?
| |
33 | |
34 static bool FromDict(const base::DictionaryValue*); | |
35 void IntoDict(base::DictionaryValue*); | |
oystein (OOO til 10th of July)
2015/05/05 19:28:31
Are these the to/from JSON things? I don't remembe
shatch
2015/05/05 20:20:23
Yep
| |
36 | |
37 protected: | |
38 friend class base::RefCountedThreadSafe<BackgroundTracingConfig>; | |
39 virtual ~BackgroundTracingConfig(); | |
40 }; | |
41 | |
42 class BackgroundTracingPreemptiveConfig : | |
43 public BackgroundTracingConfig { | |
44 public: | |
45 BackgroundTracingPreemptiveConfig(); | |
46 | |
47 enum RuleType { | |
48 MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED, | |
49 MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE, | |
50 MONITOR_AND_DUMP_WHEN_BROWSER_STARTED, | |
51 }; | |
52 struct HistogramTriggerInfo { | |
53 std::string histogram_name_to_trigger_on; | |
54 int histogram_bin_to_trigger_on; | |
55 }; | |
56 struct NamedTriggerInfo { | |
57 std::string trigger_name; | |
58 }; | |
59 struct MonitoringRule { | |
60 RuleType type; | |
61 HistogramTriggerInfo histogram_trigger_info; | |
62 NamedTriggerInfo named_trigger_info; | |
63 }; | |
64 std::vector<MonitoringRule> configs; | |
shatch
2015/05/05 18:50:21
Anybody got any thoughts on these configs?
oystein (OOO til 10th of July)
2015/05/05 19:28:31
Hmm. Maybe this should just be how it's stored int
shatch
2015/05/05 20:20:23
so something like:
class BackgroundTracingPreempt
oystein (OOO til 10th of July)
2015/05/05 20:40:10
I was thinking more that the config class which ge
| |
65 CategoryPreset category_preset; | |
66 | |
67 static bool FromDict(const base::DictionaryValue*); | |
68 void IntoDict(base::DictionaryValue*); | |
69 | |
70 protected: | |
71 ~BackgroundTracingPreemptiveConfig() override; | |
72 }; | |
73 | |
74 class BackgroundTracingReactiveConfig : | |
75 public BackgroundTracingConfig { | |
76 public: | |
77 BackgroundTracingReactiveConfig(); | |
78 | |
79 enum RuleType { | |
80 TRACE_ON_TRIGGER_UNTIL_10S_OR_NEXT_TRIGGER_OR_FULL | |
81 }; | |
82 struct TracingRule { | |
83 RuleType type; | |
84 std::string trigger_name; | |
85 CategoryPreset category_preset; | |
86 }; | |
87 std::vector<TracingRule> configs; | |
88 | |
89 static bool FromDict(const base::DictionaryValue*); | |
90 void IntoDict(base::DictionaryValue*); | |
91 | |
92 protected: | |
93 ~BackgroundTracingReactiveConfig() override; | |
94 }; | |
95 | |
96 | |
97 // BackgroundTracingManager is used on the browser process to trigger the | |
98 // collection of trace data and upload the results. Only the browser UI thread | |
99 // is allowed to interact with the BackgroundTracingManager. All callbacks are | |
100 // called on the UI thread. | |
101 class BackgroundTracingManager { | |
102 public: | |
103 CONTENT_EXPORT static BackgroundTracingManager* GetInstance(); | |
104 | |
105 // Interface for trace data consumer. An implemnentation of this interface | |
106 // is passed to SetActiveScenario() and receives the trace data. | |
107 // This may happen on any thread. | |
108 class UploadSink : | |
shatch
2015/05/05 18:50:21
I moved this in here, should we just leave it out
oystein (OOO til 10th of July)
2015/05/05 19:28:31
Or maybe even just TracingUploadSink; they aren't
shatch
2015/05/05 20:20:23
I guess, but who else might use it? Kinda feels we
oystein (OOO til 10th of July)
2015/05/05 20:40:10
True enough.
| |
109 public base::RefCountedThreadSafe<UploadSink> { | |
110 public: | |
111 virtual void Upload(const std::string&, base::Callback<void()>) = 0; | |
112 virtual bool RequiresAnonymizedData() const = 0; | |
113 | |
114 protected: | |
115 friend class base::RefCountedThreadSafe<UploadSink>; | |
116 virtual ~UploadSink() {} | |
117 }; | |
118 | |
119 virtual bool SetActiveScenario( | |
120 scoped_refptr<BackgroundTracingConfig>, | |
121 scoped_refptr<UploadSink>) = 0; | |
122 | |
123 typedef base::Callback<void()> IdleCallback; | |
124 virtual void WhenIdle(IdleCallback idle_callback) = 0; | |
125 | |
126 typedef base::Callback<void(bool)> StartedFinalizingCallback; | |
127 typedef size_t TriggerHandle; | |
128 | |
129 virtual void DidTriggerHappen(TriggerHandle, StartedFinalizingCallback) = 0; | |
130 virtual TriggerHandle RegisterTriggerType(const char* trigger_name) = 0; | |
131 virtual void GetTriggerNameList(std::vector<std::string>& trigger_names) = 0; | |
132 virtual void InvalidateTriggerHandlesForTesting() = 0; | |
133 | |
134 protected: | |
135 virtual ~BackgroundTracingManager() {} | |
136 }; | |
137 | |
138 } // namespace content | |
139 | |
140 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | |
OLD | NEW |