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

Side by Side Diff: content/browser/tracing/tracing_controller_impl.h

Issue 1468173003: [Tracing Clock Sync] Add TracingAgent interface in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fix 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
6 #define CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 6 #define CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/trace_event/memory_dump_manager.h" 13 #include "base/trace_event/memory_dump_manager.h"
14 #include "base/trace_event/tracing_agent.h"
14 #include "content/public/browser/tracing_controller.h" 15 #include "content/public/browser/tracing_controller.h"
15 16
16 namespace base { 17 namespace base {
17 class RefCountedString; 18 class RefCountedString;
18 class RefCountedMemory; 19 class RefCountedMemory;
19 } 20 }
20 21
21 namespace content { 22 namespace content {
22 23
23 class TraceMessageFilter; 24 class TraceMessageFilter;
24 class TracingUI; 25 class TracingUI;
25 26
26 class TracingControllerImpl 27 class TracingControllerImpl
27 : public TracingController, 28 : public TracingController,
28 public base::trace_event::MemoryDumpManagerDelegate { 29 public base::trace_event::MemoryDumpManagerDelegate,
30 public base::trace_event::TracingAgent {
29 public: 31 public:
30 static TracingControllerImpl* GetInstance(); 32 static TracingControllerImpl* GetInstance();
31 33
32 // TracingController implementation. 34 // TracingController implementation.
33 bool GetCategories(const GetCategoriesDoneCallback& callback) override; 35 bool GetCategories(const GetCategoriesDoneCallback& callback) override;
34 bool StartTracing(const base::trace_event::TraceConfig& trace_config, 36 bool StartTracing(const base::trace_event::TraceConfig& trace_config,
35 const StartTracingDoneCallback& callback) override; 37 const StartTracingDoneCallback& callback) override;
36 bool StopTracing(const scoped_refptr<TraceDataSink>& sink) override; 38 bool StopTracing(const scoped_refptr<TraceDataSink>& sink) override;
37 bool StartMonitoring( 39 bool StartMonitoring(
38 const base::trace_event::TraceConfig& trace_config, 40 const base::trace_event::TraceConfig& trace_config,
39 const StartMonitoringDoneCallback& callback) override; 41 const StartMonitoringDoneCallback& callback) override;
40 bool StopMonitoring( 42 bool StopMonitoring(
41 const StopMonitoringDoneCallback& callback) override; 43 const StopMonitoringDoneCallback& callback) override;
42 void GetMonitoringStatus( 44 void GetMonitoringStatus(
43 bool* out_enabled, 45 bool* out_enabled,
44 base::trace_event::TraceConfig* out_trace_config) override; 46 base::trace_event::TraceConfig* out_trace_config) override;
45 bool CaptureMonitoringSnapshot( 47 bool CaptureMonitoringSnapshot(
46 const scoped_refptr<TraceDataSink>& sink) override; 48 const scoped_refptr<TraceDataSink>& sink) override;
47 bool GetTraceBufferUsage( 49 bool GetTraceBufferUsage(
48 const GetTraceBufferUsageCallback& callback) override; 50 const GetTraceBufferUsageCallback& callback) override;
49 bool SetWatchEvent(const std::string& category_name, 51 bool SetWatchEvent(const std::string& category_name,
50 const std::string& event_name, 52 const std::string& event_name,
51 const WatchEventCallback& callback) override; 53 const WatchEventCallback& callback) override;
52 bool CancelWatchEvent() override; 54 bool CancelWatchEvent() override;
53 bool IsTracing() const override; 55 bool IsTracing() const override;
54 56
55 void RegisterTracingUI(TracingUI* tracing_ui); 57 void RegisterTracingUI(TracingUI* tracing_ui);
56 void UnregisterTracingUI(TracingUI* tracing_ui); 58 void UnregisterTracingUI(TracingUI* tracing_ui);
57 59
60 // base::trace_event::TracingAgent implementation.
61 std::string GetTracingAgentName() override;
62 std::string GetTraceEventLabel() override;
63 bool StartAgentTracing(
64 const base::trace_event::TraceConfig& trace_config) override;
65 void StopAgentTracing(const StopAgentTracingCallback& callback) override;
66 bool SupportsExplicitClockSync() override;
67 void RecordClockSyncMarker(
68 int sync_id,
69 const RecordClockSyncMarkerCallback& callback) override;
70
58 // base::trace_event::MemoryDumpManagerDelegate implementation. 71 // base::trace_event::MemoryDumpManagerDelegate implementation.
59 void RequestGlobalMemoryDump( 72 void RequestGlobalMemoryDump(
60 const base::trace_event::MemoryDumpRequestArgs& args, 73 const base::trace_event::MemoryDumpRequestArgs& args,
61 const base::trace_event::MemoryDumpCallback& callback) override; 74 const base::trace_event::MemoryDumpCallback& callback) override;
62 uint64 GetTracingProcessId() const override; 75 uint64 GetTracingProcessId() const override;
63 76
64 class TraceMessageFilterObserver { 77 class TraceMessageFilterObserver {
65 public: 78 public:
66 virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0; 79 virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0;
67 virtual void OnTraceMessageFilterRemoved(TraceMessageFilter* filter) = 0; 80 virtual void OnTraceMessageFilterRemoved(TraceMessageFilter* filter) = 0;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bool has_more_events); 128 bool has_more_events);
116 // Callback of TraceLog::FlushMonitoring() for the local trace. 129 // Callback of TraceLog::FlushMonitoring() for the local trace.
117 void OnLocalMonitoringTraceDataCollected( 130 void OnLocalMonitoringTraceDataCollected(
118 const scoped_refptr<base::RefCountedString>& events_str_ptr, 131 const scoped_refptr<base::RefCountedString>& events_str_ptr,
119 bool has_more_events); 132 bool has_more_events);
120 133
121 void OnStopTracingAcked( 134 void OnStopTracingAcked(
122 TraceMessageFilter* trace_message_filter, 135 TraceMessageFilter* trace_message_filter,
123 const std::vector<std::string>& known_category_groups); 136 const std::vector<std::string>& known_category_groups);
124 137
125 #if defined(OS_CHROMEOS) || defined(OS_WIN) 138 void OnEndAgentTracingAcked(
126 void OnEndSystemTracingAcked( 139 const std::string& agent_name,
127 const scoped_refptr<base::RefCountedString>& events_str_ptr); 140 const std::string& events_label,
128 #endif
129
130 void OnEndPowerTracingAcked(
131 const scoped_refptr<base::RefCountedString>& events_str_ptr); 141 const scoped_refptr<base::RefCountedString>& events_str_ptr);
132 142
133 void OnCaptureMonitoringSnapshotAcked( 143 void OnCaptureMonitoringSnapshotAcked(
134 TraceMessageFilter* trace_message_filter); 144 TraceMessageFilter* trace_message_filter);
135 145
136 void OnTraceLogStatusReply(TraceMessageFilter* trace_message_filter, 146 void OnTraceLogStatusReply(TraceMessageFilter* trace_message_filter,
137 const base::trace_event::TraceLogStatus& status); 147 const base::trace_event::TraceLogStatus& status);
138 void OnProcessMemoryDumpResponse(TraceMessageFilter* trace_message_filter, 148 void OnProcessMemoryDumpResponse(TraceMessageFilter* trace_message_filter,
139 uint64 dump_guid, 149 uint64 dump_guid,
140 bool success); 150 bool success);
141 151
142 // Callback of MemoryDumpManager::CreateProcessDump(). 152 // Callback of MemoryDumpManager::CreateProcessDump().
143 void OnBrowserProcessMemoryDumpDone(uint64 dump_guid, bool success); 153 void OnBrowserProcessMemoryDumpDone(uint64 dump_guid, bool success);
144 154
145 void FinalizeGlobalMemoryDumpIfAllProcessesReplied(); 155 void FinalizeGlobalMemoryDumpIfAllProcessesReplied();
146 156
147 void OnWatchEventMatched(); 157 void OnWatchEventMatched();
148 158
149 void SetEnabledOnFileThread( 159 void SetEnabledOnFileThread(
150 const base::trace_event::TraceConfig& trace_config, 160 const base::trace_event::TraceConfig& trace_config,
151 int mode, 161 int mode,
152 const base::Closure& callback); 162 const base::Closure& callback);
153 void SetDisabledOnFileThread(const base::Closure& callback); 163 void SetDisabledOnFileThread(const base::Closure& callback);
154 void OnStartTracingDone( 164 void OnStartAgentTracingDone(
155 const base::trace_event::TraceConfig& trace_config, 165 const base::trace_event::TraceConfig& trace_config,
156 const StartTracingDoneCallback& callback); 166 const StartTracingDoneCallback& callback);
157 void OnStopTracingDone(); 167 void OnStopTracingDone();
158 void OnStartMonitoringDone( 168 void OnStartMonitoringDone(
159 const base::trace_event::TraceConfig& trace_config, 169 const base::trace_event::TraceConfig& trace_config,
160 const StartMonitoringDoneCallback& callback); 170 const StartMonitoringDoneCallback& callback);
161 void OnStopMonitoringDone(const StopMonitoringDoneCallback& callback); 171 void OnStopMonitoringDone(const StopMonitoringDoneCallback& callback);
162 172
163 void OnMonitoringStateChanged(bool is_monitoring); 173 void OnMonitoringStateChanged(bool is_monitoring);
164 174
175 // Issue clock sync markers to the tracing agents.
176 void IssueClockSyncMarker();
177
165 typedef std::set<scoped_refptr<TraceMessageFilter>> TraceMessageFilterSet; 178 typedef std::set<scoped_refptr<TraceMessageFilter>> TraceMessageFilterSet;
166 TraceMessageFilterSet trace_message_filters_; 179 TraceMessageFilterSet trace_message_filters_;
167 180
168 // Pending acks for StopTracing. 181 // Pending acks for StopTracing.
169 int pending_stop_tracing_ack_count_; 182 int pending_stop_tracing_ack_count_;
170 TraceMessageFilterSet pending_stop_tracing_filters_; 183 TraceMessageFilterSet pending_stop_tracing_filters_;
171 184
172 // Pending acks for CaptureMonitoringSnapshot. 185 // Pending acks for CaptureMonitoringSnapshot.
173 int pending_capture_monitoring_snapshot_ack_count_; 186 int pending_capture_monitoring_snapshot_ack_count_;
174 TraceMessageFilterSet pending_capture_monitoring_filters_; 187 TraceMessageFilterSet pending_capture_monitoring_filters_;
175 188
176 // Pending acks for GetTraceLogStatus. 189 // Pending acks for GetTraceLogStatus.
177 int pending_trace_log_status_ack_count_; 190 int pending_trace_log_status_ack_count_;
178 TraceMessageFilterSet pending_trace_log_status_filters_; 191 TraceMessageFilterSet pending_trace_log_status_filters_;
179 float maximum_trace_buffer_usage_; 192 float maximum_trace_buffer_usage_;
180 size_t approximate_event_count_; 193 size_t approximate_event_count_;
181 194
182 // Pending acks for memory RequestGlobalDumpPoint. 195 // Pending acks for memory RequestGlobalDumpPoint.
183 int pending_memory_dump_ack_count_; 196 int pending_memory_dump_ack_count_;
184 int failed_memory_dump_count_; 197 int failed_memory_dump_count_;
185 TraceMessageFilterSet pending_memory_dump_filters_; 198 TraceMessageFilterSet pending_memory_dump_filters_;
186 uint64 pending_memory_dump_guid_; 199 uint64 pending_memory_dump_guid_;
187 base::trace_event::MemoryDumpCallback pending_memory_dump_callback_; 200 base::trace_event::MemoryDumpCallback pending_memory_dump_callback_;
188 201
189 #if defined(OS_CHROMEOS) || defined(OS_WIN) 202 StartTracingDoneCallback start_tracing_done_callback_;
190 bool is_system_tracing_; 203 std::vector<base::trace_event::TracingAgent*> additional_tracing_agents_;
191 #endif 204
192 bool is_tracing_; 205 bool is_tracing_;
193 bool is_monitoring_; 206 bool is_monitoring_;
194 bool is_power_tracing_;
195 207
196 GetCategoriesDoneCallback pending_get_categories_done_callback_; 208 GetCategoriesDoneCallback pending_get_categories_done_callback_;
197 GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_; 209 GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_;
198 210
199 std::string watch_category_name_; 211 std::string watch_category_name_;
200 std::string watch_event_name_; 212 std::string watch_event_name_;
201 WatchEventCallback watch_event_callback_; 213 WatchEventCallback watch_event_callback_;
202 214
203 base::ObserverList<TraceMessageFilterObserver> 215 base::ObserverList<TraceMessageFilterObserver>
204 trace_message_filter_observers_; 216 trace_message_filter_observers_;
205 217
206 std::set<std::string> known_category_groups_; 218 std::set<std::string> known_category_groups_;
207 std::set<TracingUI*> tracing_uis_; 219 std::set<TracingUI*> tracing_uis_;
208 scoped_refptr<TraceDataSink> trace_data_sink_; 220 scoped_refptr<TraceDataSink> trace_data_sink_;
209 scoped_refptr<TraceDataSink> monitoring_data_sink_; 221 scoped_refptr<TraceDataSink> monitoring_data_sink_;
210 222
211 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); 223 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
212 }; 224 };
213 225
214 } // namespace content 226 } // namespace content
215 227
216 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 228 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/tracing/power_tracing_agent.cc ('k') | content/browser/tracing/tracing_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698