| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Options determines how the trace buffer stores data. | 255 // Options determines how the trace buffer stores data. |
| 255 enum Options { | 256 enum Options { |
| 256 // Record until the trace buffer is full. | 257 // Record until the trace buffer is full. |
| 257 RECORD_UNTIL_FULL = 1 << 0, | 258 RECORD_UNTIL_FULL = 1 << 0, |
| 258 | 259 |
| 259 // Record until the user ends the trace. The trace buffer is a fixed size | 260 // Record until the user ends the trace. The trace buffer is a fixed size |
| 260 // and we use it as a ring buffer during recording. | 261 // and we use it as a ring buffer during recording. |
| 261 RECORD_CONTINUOUSLY = 1 << 1, | 262 RECORD_CONTINUOUSLY = 1 << 1, |
| 262 | 263 |
| 263 // Enable the sampling profiler. | 264 // Enable the sampling profiler. |
| 264 ENABLE_SAMPLING = 1 << 2 | 265 ENABLE_SAMPLING = 1 << 2, |
| 266 |
| 267 // Echo to VLOG. Events are discared. |
| 268 ECHO_TO_VLOG = 1 << 3 |
| 265 }; | 269 }; |
| 266 | 270 |
| 267 static TraceLog* GetInstance(); | 271 static TraceLog* GetInstance(); |
| 268 | 272 |
| 269 // Convert the given string to trace options. Defaults to RECORD_UNTIL_FULL if | 273 // Convert the given string to trace options. Defaults to RECORD_UNTIL_FULL if |
| 270 // the string does not provide valid options. | 274 // the string does not provide valid options. |
| 271 static Options TraceOptionsFromString(const std::string& str); | 275 static Options TraceOptionsFromString(const std::string& str); |
| 272 | 276 |
| 273 // Get set of known category groups. This can change as new code paths are | 277 // Get set of known category groups. This can change as new code paths are |
| 274 // reached. The known category groups are inserted into |category_groups|. | 278 // reached. The known category groups are inserted into |category_groups|. |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // This lock protects TraceLog member accesses from arbitrary threads. | 493 // This lock protects TraceLog member accesses from arbitrary threads. |
| 490 Lock lock_; | 494 Lock lock_; |
| 491 int enable_count_; | 495 int enable_count_; |
| 492 NotificationCallback notification_callback_; | 496 NotificationCallback notification_callback_; |
| 493 scoped_ptr<TraceBuffer> logged_events_; | 497 scoped_ptr<TraceBuffer> logged_events_; |
| 494 EventCallback event_callback_; | 498 EventCallback event_callback_; |
| 495 bool dispatching_to_observer_list_; | 499 bool dispatching_to_observer_list_; |
| 496 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; | 500 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; |
| 497 | 501 |
| 498 base::hash_map<int, std::string> thread_names_; | 502 base::hash_map<int, std::string> thread_names_; |
| 503 base::hash_map<int, std::stack<TimeTicks> > thread_event_start_times_; |
| 504 base::hash_map<std::string, int> thread_colors_; |
| 499 | 505 |
| 500 // XORed with TraceID to make it unlikely to collide with other processes. | 506 // XORed with TraceID to make it unlikely to collide with other processes. |
| 501 unsigned long long process_id_hash_; | 507 unsigned long long process_id_hash_; |
| 502 | 508 |
| 503 int process_id_; | 509 int process_id_; |
| 504 | 510 |
| 505 TimeDelta time_offset_; | 511 TimeDelta time_offset_; |
| 506 | 512 |
| 507 // Allow tests to wake up when certain events occur. | 513 // Allow tests to wake up when certain events occur. |
| 508 const unsigned char* watch_category_; | 514 const unsigned char* watch_category_; |
| 509 std::string watch_event_name_; | 515 std::string watch_event_name_; |
| 510 | 516 |
| 511 Options trace_options_; | 517 Options trace_options_; |
| 512 | 518 |
| 513 // Sampling thread handles. | 519 // Sampling thread handles. |
| 514 scoped_ptr<TraceSamplingThread> sampling_thread_; | 520 scoped_ptr<TraceSamplingThread> sampling_thread_; |
| 515 PlatformThreadHandle sampling_thread_handle_; | 521 PlatformThreadHandle sampling_thread_handle_; |
| 516 | 522 |
| 517 CategoryFilter category_filter_; | 523 CategoryFilter category_filter_; |
| 518 | 524 |
| 519 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 525 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 520 }; | 526 }; |
| 521 | 527 |
| 522 } // namespace debug | 528 } // namespace debug |
| 523 } // namespace base | 529 } // namespace base |
| 524 | 530 |
| 525 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 531 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
| OLD | NEW |