OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 5 |
6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 // meaningful if |IsEnabled()| is true. | 201 // meaningful if |IsEnabled()| is true. |
202 void GetEnabledTraceCategories(std::vector<std::string>* included_out, | 202 void GetEnabledTraceCategories(std::vector<std::string>* included_out, |
203 std::vector<std::string>* excluded_out); | 203 std::vector<std::string>* excluded_out); |
204 | 204 |
205 // Disable tracing for all categories. | 205 // Disable tracing for all categories. |
206 void SetDisabled(); | 206 void SetDisabled(); |
207 // Helper method to enable/disable tracing for all categories. | 207 // Helper method to enable/disable tracing for all categories. |
208 void SetEnabled(bool enabled); | 208 void SetEnabled(bool enabled); |
209 bool IsEnabled() { return !!enable_count_; } | 209 bool IsEnabled() { return !!enable_count_; } |
210 | 210 |
211 void SetContinuousTracing(bool continuous_tracing) { | |
nduca
2013/02/12 19:42:22
I like it, but can we make it a mode and a require
dsinclair
2013/02/25 19:04:34
Done.
| |
212 continuous_tracing_ = continuous_tracing; | |
213 } | |
214 bool GetContinuousTracing() { return continuous_tracing_; } | |
215 | |
211 #if defined(OS_ANDROID) | 216 #if defined(OS_ANDROID) |
212 static void InitATrace(); | 217 static void InitATrace(); |
213 #endif | 218 #endif |
214 | 219 |
215 // Enabled state listeners give a callback when tracing is enabled or | 220 // Enabled state listeners give a callback when tracing is enabled or |
216 // disabled. This can be used to tie into other library's tracing systems | 221 // disabled. This can be used to tie into other library's tracing systems |
217 // on-demand. | 222 // on-demand. |
218 class EnabledStateChangedObserver { | 223 class EnabledStateChangedObserver { |
219 public: | 224 public: |
220 virtual ~EnabledStateChangedObserver() { } | 225 virtual ~EnabledStateChangedObserver() { } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 void SendToATrace(char phase, | 362 void SendToATrace(char phase, |
358 const char* category, | 363 const char* category, |
359 const char* name, | 364 const char* name, |
360 int num_args, | 365 int num_args, |
361 const char** arg_names, | 366 const char** arg_names, |
362 const unsigned char* arg_types, | 367 const unsigned char* arg_types, |
363 const unsigned long long* arg_values); | 368 const unsigned long long* arg_values); |
364 static void ApplyATraceEnabledFlag(unsigned char* category_enabled); | 369 static void ApplyATraceEnabledFlag(unsigned char* category_enabled); |
365 #endif | 370 #endif |
366 | 371 |
372 void AddEvent(const TraceEvent& event); | |
373 | |
367 // TODO(nduca): switch to per-thread trace buffers to reduce thread | 374 // TODO(nduca): switch to per-thread trace buffers to reduce thread |
368 // synchronization. | 375 // synchronization. |
369 // This lock protects TraceLog member accesses from arbitrary threads. | 376 // This lock protects TraceLog member accesses from arbitrary threads. |
370 Lock lock_; | 377 Lock lock_; |
371 int enable_count_; | 378 int enable_count_; |
372 NotificationCallback notification_callback_; | 379 NotificationCallback notification_callback_; |
373 std::vector<TraceEvent> logged_events_; | 380 std::vector<TraceEvent> logged_events_; |
381 bool continuous_tracing_; | |
nduca
2013/02/12 19:42:22
Hm... can you factor out logged_events and logged_
dsinclair
2013/02/15 19:38:55
Done.
| |
382 uint32 logged_events_newest_; | |
383 uint32 logged_events_oldest_; | |
374 std::vector<std::string> included_categories_; | 384 std::vector<std::string> included_categories_; |
375 std::vector<std::string> excluded_categories_; | 385 std::vector<std::string> excluded_categories_; |
376 bool dispatching_to_observer_list_; | 386 bool dispatching_to_observer_list_; |
377 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; | 387 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; |
378 | 388 |
379 base::hash_map<int, std::string> thread_names_; | 389 base::hash_map<int, std::string> thread_names_; |
380 | 390 |
381 // XORed with TraceID to make it unlikely to collide with other processes. | 391 // XORed with TraceID to make it unlikely to collide with other processes. |
382 unsigned long long process_id_hash_; | 392 unsigned long long process_id_hash_; |
383 | 393 |
384 int process_id_; | 394 int process_id_; |
385 | 395 |
386 TimeDelta time_offset_; | 396 TimeDelta time_offset_; |
387 | 397 |
388 // Allow tests to wake up when certain events occur. | 398 // Allow tests to wake up when certain events occur. |
389 const unsigned char* watch_category_; | 399 const unsigned char* watch_category_; |
390 std::string watch_event_name_; | 400 std::string watch_event_name_; |
391 | 401 |
392 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 402 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
393 }; | 403 }; |
394 | 404 |
395 } // namespace debug | 405 } // namespace debug |
396 } // namespace base | 406 } // namespace base |
397 | 407 |
398 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 408 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
OLD | NEW |