| OLD | NEW |
| 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 |
| 11 #include <list> |
| 11 #include <set> | 12 #include <set> |
| 12 #include <string> | 13 #include <string> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "base/trace_event/memory_dump_manager.h" | 19 #include "base/trace_event/memory_dump_manager.h" |
| 19 #include "base/trace_event/tracing_agent.h" | 20 #include "base/trace_event/tracing_agent.h" |
| 20 #include "content/public/browser/tracing_controller.h" | 21 #include "content/public/browser/tracing_controller.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0; | 75 virtual void OnTraceMessageFilterAdded(TraceMessageFilter* filter) = 0; |
| 75 virtual void OnTraceMessageFilterRemoved(TraceMessageFilter* filter) = 0; | 76 virtual void OnTraceMessageFilterRemoved(TraceMessageFilter* filter) = 0; |
| 76 }; | 77 }; |
| 77 void AddTraceMessageFilterObserver(TraceMessageFilterObserver* observer); | 78 void AddTraceMessageFilterObserver(TraceMessageFilterObserver* observer); |
| 78 void RemoveTraceMessageFilterObserver(TraceMessageFilterObserver* observer); | 79 void RemoveTraceMessageFilterObserver(TraceMessageFilterObserver* observer); |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; | 82 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; |
| 82 friend class TraceMessageFilter; | 83 friend class TraceMessageFilter; |
| 83 | 84 |
| 85 // The arguments and callback for an queued global memory dump request. |
| 86 struct QueuedMemoryDumpRequest { |
| 87 QueuedMemoryDumpRequest( |
| 88 const base::trace_event::MemoryDumpRequestArgs& args, |
| 89 const base::trace_event::MemoryDumpCallback& callback); |
| 90 ~QueuedMemoryDumpRequest(); |
| 91 const base::trace_event::MemoryDumpRequestArgs args; |
| 92 const base::trace_event::MemoryDumpCallback callback; |
| 93 }; |
| 94 |
| 84 TracingControllerImpl(); | 95 TracingControllerImpl(); |
| 85 ~TracingControllerImpl() override; | 96 ~TracingControllerImpl() override; |
| 86 | 97 |
| 87 bool can_start_tracing() const { | 98 bool can_start_tracing() const { |
| 88 return !is_tracing_; | 99 return !is_tracing_; |
| 89 } | 100 } |
| 90 | 101 |
| 91 bool can_stop_tracing() const { | 102 bool can_stop_tracing() const { |
| 92 return is_tracing_ && !trace_data_sink_.get(); | 103 return is_tracing_ && !trace_data_sink_.get(); |
| 93 } | 104 } |
| 94 | 105 |
| 95 bool can_start_monitoring() const { | 106 bool can_start_monitoring() const { |
| 96 return !is_monitoring_; | 107 return !is_monitoring_; |
| 97 } | 108 } |
| 98 | 109 |
| 99 bool can_stop_monitoring() const { | 110 bool can_stop_monitoring() const { |
| 100 return is_monitoring_ && !monitoring_data_sink_.get(); | 111 return is_monitoring_ && !monitoring_data_sink_.get(); |
| 101 } | 112 } |
| 102 | 113 |
| 103 bool can_get_trace_buffer_usage() const { | 114 bool can_get_trace_buffer_usage() const { |
| 104 return pending_trace_buffer_usage_callback_.is_null(); | 115 return pending_trace_buffer_usage_callback_.is_null(); |
| 105 } | 116 } |
| 106 | 117 |
| 107 bool can_cancel_watch_event() const { | 118 bool can_cancel_watch_event() const { |
| 108 return !watch_event_callback_.is_null(); | 119 return !watch_event_callback_.is_null(); |
| 109 } | 120 } |
| 110 | 121 |
| 122 void PerformNextQueuedGlobalMemoryDump(); |
| 123 |
| 111 // Methods for use by TraceMessageFilter. | 124 // Methods for use by TraceMessageFilter. |
| 112 void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter); | 125 void AddTraceMessageFilter(TraceMessageFilter* trace_message_filter); |
| 113 void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter); | 126 void RemoveTraceMessageFilter(TraceMessageFilter* trace_message_filter); |
| 114 | 127 |
| 115 void OnTraceDataCollected( | 128 void OnTraceDataCollected( |
| 116 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 129 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
| 117 | 130 |
| 118 // Callback of TraceLog::Flush() for the local trace. | 131 // Callback of TraceLog::Flush() for the local trace. |
| 119 void OnLocalTraceDataCollected( | 132 void OnLocalTraceDataCollected( |
| 120 const scoped_refptr<base::RefCountedString>& events_str_ptr, | 133 const scoped_refptr<base::RefCountedString>& events_str_ptr, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // Pending acks for GetTraceLogStatus. | 193 // Pending acks for GetTraceLogStatus. |
| 181 int pending_trace_log_status_ack_count_; | 194 int pending_trace_log_status_ack_count_; |
| 182 TraceMessageFilterSet pending_trace_log_status_filters_; | 195 TraceMessageFilterSet pending_trace_log_status_filters_; |
| 183 float maximum_trace_buffer_usage_; | 196 float maximum_trace_buffer_usage_; |
| 184 size_t approximate_event_count_; | 197 size_t approximate_event_count_; |
| 185 | 198 |
| 186 // Pending acks for memory RequestGlobalDumpPoint. | 199 // Pending acks for memory RequestGlobalDumpPoint. |
| 187 int pending_memory_dump_ack_count_; | 200 int pending_memory_dump_ack_count_; |
| 188 int failed_memory_dump_count_; | 201 int failed_memory_dump_count_; |
| 189 TraceMessageFilterSet pending_memory_dump_filters_; | 202 TraceMessageFilterSet pending_memory_dump_filters_; |
| 190 uint64_t pending_memory_dump_guid_; | 203 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_; |
| 191 base::trace_event::MemoryDumpCallback pending_memory_dump_callback_; | |
| 192 | 204 |
| 193 std::vector<base::trace_event::TracingAgent*> additional_tracing_agents_; | 205 std::vector<base::trace_event::TracingAgent*> additional_tracing_agents_; |
| 194 int pending_clock_sync_ack_count_; | 206 int pending_clock_sync_ack_count_; |
| 195 base::OneShotTimer clock_sync_timer_; | 207 base::OneShotTimer clock_sync_timer_; |
| 196 | 208 |
| 197 bool is_tracing_; | 209 bool is_tracing_; |
| 198 bool is_monitoring_; | 210 bool is_monitoring_; |
| 199 | 211 |
| 200 GetCategoriesDoneCallback pending_get_categories_done_callback_; | 212 GetCategoriesDoneCallback pending_get_categories_done_callback_; |
| 201 GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_; | 213 GetTraceBufferUsageCallback pending_trace_buffer_usage_callback_; |
| 202 | 214 |
| 203 std::string watch_category_name_; | 215 std::string watch_category_name_; |
| 204 std::string watch_event_name_; | 216 std::string watch_event_name_; |
| 205 WatchEventCallback watch_event_callback_; | 217 WatchEventCallback watch_event_callback_; |
| 206 | 218 |
| 207 base::ObserverList<TraceMessageFilterObserver> | 219 base::ObserverList<TraceMessageFilterObserver> |
| 208 trace_message_filter_observers_; | 220 trace_message_filter_observers_; |
| 209 | 221 |
| 210 std::set<std::string> known_category_groups_; | 222 std::set<std::string> known_category_groups_; |
| 211 std::set<TracingUI*> tracing_uis_; | 223 std::set<TracingUI*> tracing_uis_; |
| 212 scoped_refptr<TraceDataSink> trace_data_sink_; | 224 scoped_refptr<TraceDataSink> trace_data_sink_; |
| 213 scoped_refptr<TraceDataSink> monitoring_data_sink_; | 225 scoped_refptr<TraceDataSink> monitoring_data_sink_; |
| 214 | 226 |
| 215 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); | 227 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); |
| 216 }; | 228 }; |
| 217 | 229 |
| 218 } // namespace content | 230 } // namespace content |
| 219 | 231 |
| 220 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ | 232 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ |
| OLD | NEW |