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 <stack> |
10 #include <string> | 10 #include <string> |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 static void Resurrect(); | 444 static void Resurrect(); |
445 | 445 |
446 // Allow tests to inspect TraceEvents. | 446 // Allow tests to inspect TraceEvents. |
447 size_t GetEventsSize() const { return logged_events_->Size(); } | 447 size_t GetEventsSize() const { return logged_events_->Size(); } |
448 const TraceEvent& GetEventAt(size_t index) const { | 448 const TraceEvent& GetEventAt(size_t index) const { |
449 return logged_events_->GetEventAt(index); | 449 return logged_events_->GetEventAt(index); |
450 } | 450 } |
451 | 451 |
452 void SetProcessID(int process_id); | 452 void SetProcessID(int process_id); |
453 | 453 |
| 454 // Process sort indices, if set, override the order of a process will appear |
| 455 // relative to other processes in the trace viewer. Processes are sorted first |
| 456 // on their sort index, ascending, then by their name, and then tid. |
| 457 void SetProcessSortIndex(int sort_index); |
| 458 |
| 459 // Sets the name of the process. |
| 460 void SetProcessName(const std::string& process_name); |
| 461 |
| 462 // Processes can have labels in addition to their names. Use labels, for |
| 463 // instance, to list out the web page titles that a process is handling. |
| 464 void UpdateProcessLabel(int label_id, const std::string& current_label); |
| 465 void RemoveProcessLabel(int label_id); |
| 466 |
| 467 // Thread sort indices, if set, override the order of a thread will appear |
| 468 // within its process in the trace viewer. Threads are sorted first on their |
| 469 // sort index, ascending, then by their name, and then tid. |
| 470 void SetThreadSortIndex(PlatformThreadId , int sort_index); |
| 471 |
454 // Allow setting an offset between the current TimeTicks time and the time | 472 // Allow setting an offset between the current TimeTicks time and the time |
455 // that should be reported. | 473 // that should be reported. |
456 void SetTimeOffset(TimeDelta offset); | 474 void SetTimeOffset(TimeDelta offset); |
457 | 475 |
458 size_t GetObserverCountForTest() const; | 476 size_t GetObserverCountForTest() const; |
459 | 477 |
460 private: | 478 private: |
461 // This allows constructor and destructor to be private and usable only | 479 // This allows constructor and destructor to be private and usable only |
462 // by the Singleton class. | 480 // by the Singleton class. |
463 friend struct StaticMemorySingletonTraits<TraceLog>; | 481 friend struct StaticMemorySingletonTraits<TraceLog>; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 520 |
503 private: | 521 private: |
504 TraceLog* trace_log_; | 522 TraceLog* trace_log_; |
505 NotificationCallback callback_copy_; | 523 NotificationCallback callback_copy_; |
506 int notification_; | 524 int notification_; |
507 }; | 525 }; |
508 | 526 |
509 TraceLog(); | 527 TraceLog(); |
510 ~TraceLog(); | 528 ~TraceLog(); |
511 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); | 529 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); |
512 void AddThreadNameMetadataEvents(); | 530 void AddMetadataEvents(); |
513 | 531 |
514 #if defined(OS_ANDROID) | 532 #if defined(OS_ANDROID) |
515 void SendToATrace(char phase, | 533 void SendToATrace(char phase, |
516 const char* category_group, | 534 const char* category_group, |
517 const char* name, | 535 const char* name, |
518 unsigned long long id, | 536 unsigned long long id, |
519 int num_args, | 537 int num_args, |
520 const char** arg_names, | 538 const char** arg_names, |
521 const unsigned char* arg_types, | 539 const unsigned char* arg_types, |
522 const unsigned long long* arg_values, | 540 const unsigned long long* arg_values, |
523 scoped_ptr<ConvertableToTraceFormat> convertable_values[], | 541 scoped_ptr<ConvertableToTraceFormat> convertable_values[], |
524 unsigned char flags); | 542 unsigned char flags); |
525 static void ApplyATraceEnabledFlag(unsigned char* category_group_enabled); | 543 static void ApplyATraceEnabledFlag(unsigned char* category_group_enabled); |
526 #endif | 544 #endif |
527 | 545 |
528 TraceBuffer* GetTraceBuffer(); | 546 TraceBuffer* GetTraceBuffer(); |
529 | 547 |
530 // TODO(nduca): switch to per-thread trace buffers to reduce thread | 548 // TODO(nduca): switch to per-thread trace buffers to reduce thread |
531 // synchronization. | 549 // synchronization. |
532 // This lock protects TraceLog member accesses from arbitrary threads. | 550 // This lock protects TraceLog member accesses from arbitrary threads. |
533 Lock lock_; | 551 Lock lock_; |
534 int enable_count_; | 552 int enable_count_; |
535 int num_traces_recorded_; | 553 int num_traces_recorded_; |
536 NotificationCallback notification_callback_; | 554 NotificationCallback notification_callback_; |
537 scoped_ptr<TraceBuffer> logged_events_; | 555 scoped_ptr<TraceBuffer> logged_events_; |
538 EventCallback event_callback_; | 556 EventCallback event_callback_; |
539 bool dispatching_to_observer_list_; | 557 bool dispatching_to_observer_list_; |
540 std::vector<EnabledStateObserver*> enabled_state_observer_list_; | 558 std::vector<EnabledStateObserver*> enabled_state_observer_list_; |
541 | 559 |
| 560 std::string process_name_; |
| 561 base::hash_map<int, std::string> process_labels_; |
| 562 int process_sort_index_; |
| 563 base::hash_map<int, int> thread_sort_indices_; |
| 564 |
542 base::hash_map<int, std::string> thread_names_; | 565 base::hash_map<int, std::string> thread_names_; |
543 base::hash_map<int, std::stack<TimeTicks> > thread_event_start_times_; | 566 base::hash_map<int, std::stack<TimeTicks> > thread_event_start_times_; |
544 base::hash_map<std::string, int> thread_colors_; | 567 base::hash_map<std::string, int> thread_colors_; |
545 | 568 |
546 // XORed with TraceID to make it unlikely to collide with other processes. | 569 // XORed with TraceID to make it unlikely to collide with other processes. |
547 unsigned long long process_id_hash_; | 570 unsigned long long process_id_hash_; |
548 | 571 |
549 int process_id_; | 572 int process_id_; |
550 | 573 |
551 TimeDelta time_offset_; | 574 TimeDelta time_offset_; |
(...skipping 10 matching lines...) Expand all Loading... |
562 | 585 |
563 CategoryFilter category_filter_; | 586 CategoryFilter category_filter_; |
564 | 587 |
565 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 588 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
566 }; | 589 }; |
567 | 590 |
568 } // namespace debug | 591 } // namespace debug |
569 } // namespace base | 592 } // namespace base |
570 | 593 |
571 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 594 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
OLD | NEW |