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 <stack> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
14 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
15 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
18 #include "base/synchronization/condition_variable.h" | 19 #include "base/synchronization/condition_variable.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Options determines how the trace buffer stores data. | 272 // Options determines how the trace buffer stores data. |
272 enum Options { | 273 enum Options { |
273 // Record until the trace buffer is full. | 274 // Record until the trace buffer is full. |
274 RECORD_UNTIL_FULL = 1 << 0, | 275 RECORD_UNTIL_FULL = 1 << 0, |
275 | 276 |
276 // Record until the user ends the trace. The trace buffer is a fixed size | 277 // Record until the user ends the trace. The trace buffer is a fixed size |
277 // and we use it as a ring buffer during recording. | 278 // and we use it as a ring buffer during recording. |
278 RECORD_CONTINUOUSLY = 1 << 1, | 279 RECORD_CONTINUOUSLY = 1 << 1, |
279 | 280 |
280 // Enable the sampling profiler. | 281 // Enable the sampling profiler. |
281 ENABLE_SAMPLING = 1 << 2 | 282 ENABLE_SAMPLING = 1 << 2, |
| 283 |
| 284 // Echo to stderr. |
| 285 ECHO_TO_STDERR = 1 << 3 |
282 }; | 286 }; |
283 | 287 |
284 static TraceLog* GetInstance(); | 288 static TraceLog* GetInstance(); |
285 | 289 |
286 // Convert the given string to trace options. Defaults to RECORD_UNTIL_FULL if | 290 // Convert the given string to trace options. Defaults to RECORD_UNTIL_FULL if |
287 // the string does not provide valid options. | 291 // the string does not provide valid options. |
288 static Options TraceOptionsFromString(const std::string& str); | 292 static Options TraceOptionsFromString(const std::string& str); |
289 | 293 |
290 // Get set of known category groups. This can change as new code paths are | 294 // Get set of known category groups. This can change as new code paths are |
291 // reached. The known category groups are inserted into |category_groups|. | 295 // reached. The known category groups are inserted into |category_groups|. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // This lock protects TraceLog member accesses from arbitrary threads. | 512 // This lock protects TraceLog member accesses from arbitrary threads. |
509 Lock lock_; | 513 Lock lock_; |
510 int enable_count_; | 514 int enable_count_; |
511 NotificationCallback notification_callback_; | 515 NotificationCallback notification_callback_; |
512 scoped_ptr<TraceBuffer> logged_events_; | 516 scoped_ptr<TraceBuffer> logged_events_; |
513 EventCallback event_callback_; | 517 EventCallback event_callback_; |
514 bool dispatching_to_observer_list_; | 518 bool dispatching_to_observer_list_; |
515 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; | 519 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; |
516 | 520 |
517 base::hash_map<int, std::string> thread_names_; | 521 base::hash_map<int, std::string> thread_names_; |
| 522 base::hash_map<int, std::stack<TimeTicks> > thread_event_start_times_; |
| 523 base::hash_map<std::string, int> thread_colors_; |
518 | 524 |
519 // XORed with TraceID to make it unlikely to collide with other processes. | 525 // XORed with TraceID to make it unlikely to collide with other processes. |
520 unsigned long long process_id_hash_; | 526 unsigned long long process_id_hash_; |
521 | 527 |
522 int process_id_; | 528 int process_id_; |
523 | 529 |
524 TimeDelta time_offset_; | 530 TimeDelta time_offset_; |
525 | 531 |
526 // Allow tests to wake up when certain events occur. | 532 // Allow tests to wake up when certain events occur. |
527 const unsigned char* watch_category_; | 533 const unsigned char* watch_category_; |
528 std::string watch_event_name_; | 534 std::string watch_event_name_; |
529 | 535 |
530 Options trace_options_; | 536 Options trace_options_; |
531 | 537 |
532 // Sampling thread handles. | 538 // Sampling thread handles. |
533 scoped_ptr<TraceSamplingThread> sampling_thread_; | 539 scoped_ptr<TraceSamplingThread> sampling_thread_; |
534 PlatformThreadHandle sampling_thread_handle_; | 540 PlatformThreadHandle sampling_thread_handle_; |
535 | 541 |
536 CategoryFilter category_filter_; | 542 CategoryFilter category_filter_; |
537 | 543 |
538 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 544 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
539 }; | 545 }; |
540 | 546 |
541 } // namespace debug | 547 } // namespace debug |
542 } // namespace base | 548 } // namespace base |
543 | 549 |
544 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 550 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
OLD | NEW |