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

Side by Side Diff: base/trace_event/tracing_agent.h

Issue 1468173003: [Tracing Clock Sync] Add TracingAgent interface in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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 BASE_TRACE_EVENT_TRACING_AGENT_H_
6 #define BASE_TRACE_EVENT_TRACING_AGENT_H_
7
8 #include "base/base_export.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "base/values.h"
12
13 namespace base {
14
15 class TimeTicks;
16
17 namespace trace_event {
18
19 class TraceConfig;
20
21 // A tracing agent is the entity that records its own sort of trace. Each
22 // tracing method that produces its own trace log should implement this
23 // interface. And all tracing agents are and should only be controlled by the
24 // TracingController.
stevenjb 2015/12/14 18:22:40 s/the entity/an entity/ s/And all//All/ s/are and
Zhen Wang 2015/12/14 21:03:56 Done.
25 //
stevenjb 2015/12/14 18:22:39 No blank line in single comment block
Zhen Wang 2015/12/14 21:03:56 Done.
26 // Some existing examples include TracingControllerImpl for Chrome trace events,
27 // DebugDaemonClient for CrOs system trace, EtwSystemEventConsumer for Windows
28 // system trace and PowerTracingAgent for BattOr power trace.
29 class BASE_EXPORT TracingAgent {
30 public:
31 using StopAgentTracingCallback = base::Callback<void(
32 const std::string& agent_name,
33 const std::string& events_label,
34 const scoped_refptr<base::RefCountedString>& events_str_ptr)>;
35 using RecordClockSyncMarkerCallback = base::Callback<void(
36 int sync_id,
37 const TimeTicks& sync_ts,
38 const TimeTicks& sync_end_ts)>;
39
40 virtual ~TracingAgent() {}
stevenjb 2015/12/14 18:22:39 Since this is not a pure interface class (last two
Zhen Wang 2015/12/14 21:03:56 Done.
41
42 // Get the name of the tracing agent. Each tracing agent's name should be
stevenjb 2015/12/14 18:22:39 Gets
Zhen Wang 2015/12/14 21:03:57 Done.
43 // unique.
44 virtual std::string GetTracingAgentName() = 0;
45
46 // Get the trace event label of this tracing agent. The label will be used to
stevenjb 2015/12/14 18:22:40 Gets
Zhen Wang 2015/12/14 21:03:56 Done.
47 // label this agent's trace when all traces from different tracing agents are
48 // combined.
49 //
stevenjb 2015/12/14 18:22:40 Avoid blank lines in comment blocks unless they ar
Zhen Wang 2015/12/14 21:03:57 Done.
50 // Multiple tracing agents could have the same label. But the tracing agents
stevenjb 2015/12/14 18:22:39 s/But the/The/
Zhen Wang 2015/12/14 21:03:56 Done.
51 // using the same label should not be able to run at the same time. For
52 // example, ETW on Windows and CrOS system tracing both use
53 // "systemTraceEvents" as the label. And those two agents never run at the
stevenjb 2015/12/14 18:22:39 s/And those/Those/ (Last sentence isn't actually n
Zhen Wang 2015/12/14 21:03:56 Done.
54 // same time because they are for different platforms.
55 virtual std::string GetTraceEventLabel() = 0;
56
57 // Start tracing on the tracing agent with the trace configuration.
stevenjb 2015/12/14 18:22:40 s/Start/Starts/
Zhen Wang 2015/12/14 21:03:56 Done.
58 virtual bool StartAgentTracing(const TraceConfig& trace_config) = 0;
59
60 // Stop tracing on the tracing agent. The trace data will be passed back to
stevenjb 2015/12/14 18:22:40 s/Stop/Stops/
Zhen Wang 2015/12/14 21:03:57 Done.
61 // the TracingController via the callback.
62 virtual void StopAgentTracing(const StopAgentTracingCallback& callback) = 0;
63
64 // Check if the tracing agent supports explicit clock synchronization.
stevenjb 2015/12/14 18:22:40 s/Check/Checks/
Zhen Wang 2015/12/14 21:03:56 Done.
65 virtual bool SupportsExplicitClockSync();
66
67 // Record a clock sync marker issued by another tracing agent. This is only
stevenjb 2015/12/14 18:22:40 s/Record/Records/
Zhen Wang 2015/12/14 21:03:57 Done.
68 // used if the tracing agent supports explicit clock synchronization.
69 //
70 // Two things need to be done:
71 // 1. The issuer asks the receiver to record the clock sync marker.
72 // 2. The issuer records how long the receiver takes to do the recording.
73 //
74 // In Chrome, the receiver thread also runs in Chrome and it will talk to the
75 // real receiver entity, e.g., power monitor or Android device system, via
76 // different communication methods, e.g., through USB or file reading/writing.
77 // The 2nd thing measures that communication latency.
stevenjb 2015/12/14 18:22:40 s/thing/task/
Zhen Wang 2015/12/14 21:03:56 Done.
78 //
79 // Having a reliable timing measurement for the 2nd thing requires synchronous
stevenjb 2015/12/14 18:22:40 task
Zhen Wang 2015/12/14 21:03:56 Done.
80 // function call without any cross-thread or cross-process activity. However,
81 // tracing agents in Chrome run in their own threads. Therefore, the issuer
82 // needs to dedicate the 2nd thing to the receiver to take time measurements
stevenjb 2015/12/14 18:22:39 task
Zhen Wang 2015/12/14 21:03:57 Done.
83 // in the receiver thread, and the receiver thread needs to pass them back to
84 // the issuer in the callback.
85 //
86 // The assumption is that the receiver thread knows the issuer's clock, which
87 // is true in Chrome because all agent threads' clocks are Chrome clock.
88 virtual void RecordClockSyncMarker(
89 int sync_id,
90 const RecordClockSyncMarkerCallback& callback);
91 };
92
93 } // namespace trace_event
94 } // namespace base
95
96 #endif // BASE_TRACE_EVENT_TRACING_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698