OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_TRACE_EVENT_TRACING_AGENT_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACING_AGENT_H_ |
6 #define BASE_TRACE_EVENT_TRACING_AGENT_H_ | 6 #define BASE_TRACE_EVENT_TRACING_AGENT_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 class TimeTicks; | 15 class TimeTicks; |
16 | 16 |
17 namespace trace_event { | 17 namespace trace_event { |
18 | 18 |
19 class TraceConfig; | 19 class TraceConfig; |
20 | 20 |
21 // A tracing agent is an entity that records its own sort of trace. Each | 21 // A tracing agent is an entity that records its own sort of trace. Each |
22 // tracing method that produces its own trace log should implement this | 22 // tracing method that produces its own trace log should implement this |
23 // interface. All tracing agents must only be controlled by TracingController. | 23 // interface. All tracing agents must only be controlled by TracingController. |
24 // Some existing examples include TracingControllerImpl for Chrome trace events, | 24 // Some existing examples include TracingControllerImpl for Chrome trace events, |
25 // DebugDaemonClient for CrOs system trace, EtwSystemEventConsumer for Windows | 25 // DebugDaemonClient for CrOs system trace, EtwSystemEventConsumer for Windows |
26 // system trace and PowerTracingAgent for BattOr power trace. | 26 // system trace and PowerTracingAgent for BattOr power trace. |
27 class BASE_EXPORT TracingAgent { | 27 class BASE_EXPORT TracingAgent { |
28 public: | 28 public: |
| 29 using StartAgentTracingCallback = |
| 30 base::Callback<void(const std::string& agent_name, bool success)>; |
29 // Passing a null or empty events_str_ptr indicates that no trace data is | 31 // Passing a null or empty events_str_ptr indicates that no trace data is |
30 // available for the specified agent. | 32 // available for the specified agent. |
31 using StopAgentTracingCallback = base::Callback<void( | 33 using StopAgentTracingCallback = base::Callback<void( |
32 const std::string& agent_name, | 34 const std::string& agent_name, |
33 const std::string& events_label, | 35 const std::string& events_label, |
34 const scoped_refptr<base::RefCountedString>& events_str_ptr)>; | 36 const scoped_refptr<base::RefCountedString>& events_str_ptr)>; |
35 using RecordClockSyncMarkerCallback = base::Callback<void( | 37 using RecordClockSyncMarkerCallback = base::Callback<void( |
36 int sync_id, | 38 int sync_id, |
37 const TimeTicks& issue_ts, | 39 const TimeTicks& issue_ts, |
38 const TimeTicks& issue_end_ts)>; | 40 const TimeTicks& issue_end_ts)>; |
39 | 41 |
40 virtual ~TracingAgent(); | 42 virtual ~TracingAgent(); |
41 | 43 |
42 // Gets the name of the tracing agent. Each tracing agent's name should be | 44 // Gets the name of the tracing agent. Each tracing agent's name should be |
43 // unique. | 45 // unique. |
44 virtual std::string GetTracingAgentName() = 0; | 46 virtual std::string GetTracingAgentName() = 0; |
45 | 47 |
46 // Gets the trace event label of this tracing agent. The label will be used to | 48 // Gets the trace event label of this tracing agent. The label will be used to |
47 // label this agent's trace when all traces from different tracing agents are | 49 // label this agent's trace when all traces from different tracing agents are |
48 // combined. Multiple tracing agents could have the same label. The tracing | 50 // combined. Multiple tracing agents could have the same label. The tracing |
49 // agents using the same label should not be able to run at the same time. For | 51 // agents using the same label should not be able to run at the same time. For |
50 // example, ETW on Windows and CrOS system tracing both use | 52 // example, ETW on Windows and CrOS system tracing both use |
51 // "systemTraceEvents" as the label. Those two agents never run at the same | 53 // "systemTraceEvents" as the label. Those two agents never run at the same |
52 // time because they are for different platforms. | 54 // time because they are for different platforms. |
53 virtual std::string GetTraceEventLabel() = 0; | 55 virtual std::string GetTraceEventLabel() = 0; |
54 | 56 |
55 // Starts tracing on the tracing agent with the trace configuration. | 57 // Starts tracing on the tracing agent with the trace configuration. |
56 virtual bool StartAgentTracing(const TraceConfig& trace_config) = 0; | 58 virtual void StartAgentTracing(const TraceConfig& trace_config, |
| 59 const StartAgentTracingCallback& callback) = 0; |
57 | 60 |
58 // Stops tracing on the tracing agent. The trace data will be passed back to | 61 // Stops tracing on the tracing agent. The trace data will be passed back to |
59 // the TracingController via the callback. | 62 // the TracingController via the callback. |
60 virtual void StopAgentTracing(const StopAgentTracingCallback& callback) = 0; | 63 virtual void StopAgentTracing(const StopAgentTracingCallback& callback) = 0; |
61 | 64 |
62 // Checks if the tracing agent supports explicit clock synchronization. | 65 // Checks if the tracing agent supports explicit clock synchronization. |
63 virtual bool SupportsExplicitClockSync(); | 66 virtual bool SupportsExplicitClockSync(); |
64 | 67 |
65 // Records a clock sync marker issued by another tracing agent. This is only | 68 // Records a clock sync marker issued by another tracing agent. This is only |
66 // used if the tracing agent supports explicit clock synchronization. | 69 // used if the tracing agent supports explicit clock synchronization. |
(...skipping 18 matching lines...) Expand all Loading... |
85 // is true in Chrome because all agent threads' clocks are Chrome clock. | 88 // is true in Chrome because all agent threads' clocks are Chrome clock. |
86 virtual void RecordClockSyncMarker( | 89 virtual void RecordClockSyncMarker( |
87 int sync_id, | 90 int sync_id, |
88 const RecordClockSyncMarkerCallback& callback); | 91 const RecordClockSyncMarkerCallback& callback); |
89 }; | 92 }; |
90 | 93 |
91 } // namespace trace_event | 94 } // namespace trace_event |
92 } // namespace base | 95 } // namespace base |
93 | 96 |
94 #endif // BASE_TRACE_EVENT_TRACING_AGENT_H_ | 97 #endif // BASE_TRACE_EVENT_TRACING_AGENT_H_ |
OLD | NEW |