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

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

Issue 2694083005: memory-infra: Finish moving memory_infra from TracingController (Closed)
Patch Set: style: auto must not deduce to raw pointer Created 3 years, 9 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
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 29 matching lines...) Expand all
40 virtual void ReceiveTraceFinalContents( 40 virtual void ReceiveTraceFinalContents(
41 std::unique_ptr<const base::DictionaryValue> metadata) {} 41 std::unique_ptr<const base::DictionaryValue> metadata) {}
42 42
43 protected: 43 protected:
44 friend class base::RefCountedThreadSafe<TraceDataEndpoint>; 44 friend class base::RefCountedThreadSafe<TraceDataEndpoint>;
45 virtual ~TraceDataEndpoint() {} 45 virtual ~TraceDataEndpoint() {}
46 }; 46 };
47 47
48 class TracingControllerImpl 48 class TracingControllerImpl
49 : public TracingController, 49 : public TracingController,
50 public base::trace_event::MemoryDumpManagerDelegate,
51 public base::trace_event::TracingAgent { 50 public base::trace_event::TracingAgent {
52 public: 51 public:
53 // Create an endpoint that may be supplied to any TraceDataSink to 52 // Create an endpoint that may be supplied to any TraceDataSink to
54 // dump the trace data to a callback. 53 // dump the trace data to a callback.
55 CONTENT_EXPORT static scoped_refptr<TraceDataEndpoint> CreateCallbackEndpoint( 54 CONTENT_EXPORT static scoped_refptr<TraceDataEndpoint> CreateCallbackEndpoint(
56 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, 55 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>,
57 base::RefCountedString*)>& callback); 56 base::RefCountedString*)>& callback);
58 57
59 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateCompressedStringSink( 58 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateCompressedStringSink(
60 scoped_refptr<TraceDataEndpoint> endpoint); 59 scoped_refptr<TraceDataEndpoint> endpoint);
(...skipping 20 matching lines...) Expand all
81 std::string GetTracingAgentName() override; 80 std::string GetTracingAgentName() override;
82 std::string GetTraceEventLabel() override; 81 std::string GetTraceEventLabel() override;
83 void StartAgentTracing(const base::trace_event::TraceConfig& trace_config, 82 void StartAgentTracing(const base::trace_event::TraceConfig& trace_config,
84 const StartAgentTracingCallback& callback) override; 83 const StartAgentTracingCallback& callback) override;
85 void StopAgentTracing(const StopAgentTracingCallback& callback) override; 84 void StopAgentTracing(const StopAgentTracingCallback& callback) override;
86 bool SupportsExplicitClockSync() override; 85 bool SupportsExplicitClockSync() override;
87 void RecordClockSyncMarker( 86 void RecordClockSyncMarker(
88 const std::string& sync_id, 87 const std::string& sync_id,
89 const RecordClockSyncMarkerCallback& callback) override; 88 const RecordClockSyncMarkerCallback& callback) override;
90 89
91 // base::trace_event::MemoryDumpManagerDelegate implementation.
92 void RequestGlobalMemoryDump(
93 const base::trace_event::MemoryDumpRequestArgs& args,
94 const base::trace_event::MemoryDumpCallback& callback) override;
95 uint64_t GetTracingProcessId() const override;
96
97 class TraceMessageFilterObserver { 90 class TraceMessageFilterObserver {
98 public: 91 public:
99 virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0; 92 virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0;
100 virtual void OnTraceMessageFilterRemoved(TraceMessageFilter* filter) = 0; 93 virtual void OnTraceMessageFilterRemoved(TraceMessageFilter* filter) = 0;
101 }; 94 };
102 void AddTraceMessageFilterObserver(TraceMessageFilterObserver* observer); 95 void AddTraceMessageFilterObserver(TraceMessageFilterObserver* observer);
103 void RemoveTraceMessageFilterObserver(TraceMessageFilterObserver* observer); 96 void RemoveTraceMessageFilterObserver(TraceMessageFilterObserver* observer);
104 97
105 private: 98 private:
106 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; 99 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>;
107 friend class TraceMessageFilter; 100 friend class TraceMessageFilter;
108 101
109 // The arguments and callback for an queued global memory dump request.
110 struct QueuedMemoryDumpRequest {
111 QueuedMemoryDumpRequest(
112 const base::trace_event::MemoryDumpRequestArgs& args,
113 const base::trace_event::MemoryDumpCallback& callback);
114 ~QueuedMemoryDumpRequest();
115 const base::trace_event::MemoryDumpRequestArgs args;
116 const base::trace_event::MemoryDumpCallback callback;
117 };
118
119 TracingControllerImpl(); 102 TracingControllerImpl();
120 ~TracingControllerImpl() override; 103 ~TracingControllerImpl() override;
121 104
122 bool can_start_tracing() const { 105 bool can_start_tracing() const {
123 return !is_tracing_; 106 return !is_tracing_;
124 } 107 }
125 108
126 bool can_stop_tracing() const { 109 bool can_stop_tracing() const {
127 return is_tracing_ && !trace_data_sink_.get(); 110 return is_tracing_ && !trace_data_sink_.get();
128 } 111 }
129 112
130 bool can_start_monitoring() const { 113 bool can_start_monitoring() const {
131 return !is_monitoring_; 114 return !is_monitoring_;
132 } 115 }
133 116
134 bool can_stop_monitoring() const { 117 bool can_stop_monitoring() const {
135 return is_monitoring_ && !monitoring_data_sink_.get(); 118 return is_monitoring_ && !monitoring_data_sink_.get();
136 } 119 }
137 120
138 bool can_get_trace_buffer_usage() const { 121 bool can_get_trace_buffer_usage() const {
139 return pending_trace_buffer_usage_callback_.is_null(); 122 return pending_trace_buffer_usage_callback_.is_null();
140 } 123 }
141 124
142 void PerformNextQueuedGlobalMemoryDump();
143
144 // Methods for use by TraceMessageFilter. 125 // Methods for use by TraceMessageFilter.
145 void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter); 126 void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter);
146 void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter); 127 void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter);
147 128
148 void OnTraceDataCollected( 129 void OnTraceDataCollected(
149 const scoped_refptr<base::RefCountedString>& events_str_ptr); 130 const scoped_refptr<base::RefCountedString>& events_str_ptr);
150 131
151 // Callback of TraceLog::Flush() for the local trace. 132 // Callback of TraceLog::Flush() for the local trace.
152 void OnLocalTraceDataCollected( 133 void OnLocalTraceDataCollected(
153 const scoped_refptr<base::RefCountedString>& events_str_ptr, 134 const scoped_refptr<base::RefCountedString>& events_str_ptr,
154 bool has_more_events); 135 bool has_more_events);
155 136
156 // Adds the tracing agent with the specified agent name to the list of 137 // Adds the tracing agent with the specified agent name to the list of
157 // additional tracing agents. 138 // additional tracing agents.
158 void AddTracingAgent(const std::string& agent_name); 139 void AddTracingAgent(const std::string& agent_name);
159 140
160 void OnStartAgentTracingAcked(const std::string& agent_name, bool success); 141 void OnStartAgentTracingAcked(const std::string& agent_name, bool success);
161 142
162 void OnStopTracingAcked( 143 void OnStopTracingAcked(
163 TraceMessageFilter* trace_message_filter, 144 TraceMessageFilter* trace_message_filter,
164 const std::vector<std::string>& known_category_groups); 145 const std::vector<std::string>& known_category_groups);
165 146
166 void OnEndAgentTracingAcked( 147 void OnEndAgentTracingAcked(
167 const std::string& agent_name, 148 const std::string& agent_name,
168 const std::string& events_label, 149 const std::string& events_label,
169 const scoped_refptr<base::RefCountedString>& events_str_ptr); 150 const scoped_refptr<base::RefCountedString>& events_str_ptr);
170 151
171 void OnTraceLogStatusReply(TraceMessageFilter* trace_message_filter, 152 void OnTraceLogStatusReply(TraceMessageFilter* trace_message_filter,
172 const base::trace_event::TraceLogStatus& status); 153 const base::trace_event::TraceLogStatus& status);
173 void OnProcessMemoryDumpResponse(TraceMessageFilter* trace_message_filter,
174 uint64_t dump_guid,
175 bool success);
176
177 // Callback of MemoryDumpManager::CreateProcessDump().
178 void OnBrowserProcessMemoryDumpDone(uint64_t dump_guid, bool success);
179
180 void FinalizeGlobalMemoryDumpIfAllProcessesReplied();
181 154
182 void SetEnabledOnFileThread( 155 void SetEnabledOnFileThread(
183 const base::trace_event::TraceConfig& trace_config, 156 const base::trace_event::TraceConfig& trace_config,
184 int mode, 157 int mode,
185 const base::Closure& callback); 158 const base::Closure& callback);
186 void SetDisabledOnFileThread(const base::Closure& callback); 159 void SetDisabledOnFileThread(const base::Closure& callback);
187 void OnAllTracingAgentsStarted(); 160 void OnAllTracingAgentsStarted();
188 void StopTracingAfterClockSync(); 161 void StopTracingAfterClockSync();
189 void OnStopTracingDone(); 162 void OnStopTracingDone();
190 163
(...skipping 20 matching lines...) Expand all
211 // Pending acks for StopTracing. 184 // Pending acks for StopTracing.
212 int pending_stop_tracing_ack_count_; 185 int pending_stop_tracing_ack_count_;
213 TraceMessageFilterSet pending_stop_tracing_filters_; 186 TraceMessageFilterSet pending_stop_tracing_filters_;
214 187
215 // Pending acks for GetTraceLogStatus. 188 // Pending acks for GetTraceLogStatus.
216 int pending_trace_log_status_ack_count_; 189 int pending_trace_log_status_ack_count_;
217 TraceMessageFilterSet pending_trace_log_status_filters_; 190 TraceMessageFilterSet pending_trace_log_status_filters_;
218 float maximum_trace_buffer_usage_; 191 float maximum_trace_buffer_usage_;
219 size_t approximate_event_count_; 192 size_t approximate_event_count_;
220 193
221 // Pending acks for memory RequestGlobalDumpPoint.
222 int pending_memory_dump_ack_count_;
223 int failed_memory_dump_count_;
224 TraceMessageFilterSet pending_memory_dump_filters_;
225 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_;
226
227 std::vector<base::trace_event::TracingAgent*> additional_tracing_agents_; 194 std::vector<base::trace_event::TracingAgent*> additional_tracing_agents_;
228 int pending_clock_sync_ack_count_; 195 int pending_clock_sync_ack_count_;
229 base::OneShotTimer clock_sync_timer_; 196 base::OneShotTimer clock_sync_timer_;
230 197
231 bool is_tracing_; 198 bool is_tracing_;
232 bool is_monitoring_; 199 bool is_monitoring_;
233 200
234 GetCategoriesDoneCallback pending_get_categories_done_callback_; 201 GetCategoriesDoneCallback pending_get_categories_done_callback_;
235 GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_; 202 GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_;
236 203
237 base::ObserverList<TraceMessageFilterObserver> 204 base::ObserverList<TraceMessageFilterObserver>
238 trace_message_filter_observers_; 205 trace_message_filter_observers_;
239 206
240 std::set<std::string> known_category_groups_; 207 std::set<std::string> known_category_groups_;
241 std::set<TracingUI*> tracing_uis_; 208 std::set<TracingUI*> tracing_uis_;
242 scoped_refptr<TraceDataSink> trace_data_sink_; 209 scoped_refptr<TraceDataSink> trace_data_sink_;
243 scoped_refptr<TraceDataSink> monitoring_data_sink_; 210 scoped_refptr<TraceDataSink> monitoring_data_sink_;
244 std::unique_ptr<base::DictionaryValue> metadata_; 211 std::unique_ptr<base::DictionaryValue> metadata_;
245 212
246 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); 213 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
247 }; 214 };
248 215
249 } // namespace content 216 } // namespace content
250 217
251 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 218 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/tracing/trace_message_filter.cc ('k') | content/browser/tracing/tracing_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698