Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1529)

Side by Side Diff: base/debug/trace_event_impl.h

Issue 17451017: Process names, and predictable thread and process ordering in about:tracing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event_impl.cc » ('j') | content/gpu/gpu_main.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map>
9 #include <stack> 10 #include <stack>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
17 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
18 #include "base/observer_list.h" 19 #include "base/observer_list.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // Allows resurrecting our singleton instance post-AtExit processing. 444 // Allows resurrecting our singleton instance post-AtExit processing.
444 static void Resurrect(); 445 static void Resurrect();
445 446
446 // Allow tests to inspect TraceEvents. 447 // Allow tests to inspect TraceEvents.
447 size_t GetEventsSize() const { return logged_events_->Size(); } 448 size_t GetEventsSize() const { return logged_events_->Size(); }
448 const TraceEvent& GetEventAt(size_t index) const { 449 const TraceEvent& GetEventAt(size_t index) const {
449 return logged_events_->GetEventAt(index); 450 return logged_events_->GetEventAt(index);
450 } 451 }
451 452
452 void SetProcessID(int process_id); 453 void SetProcessID(int process_id);
454 void SetProcessSortIndex(int sort_index);
455 void SetProcessLabel(int label_id, const std::string& current_label);
456 void SetThreadSortIndex(int thread_id, int sort_index);
453 457
454 // Allow setting an offset between the current TimeTicks time and the time 458 // Allow setting an offset between the current TimeTicks time and the time
455 // that should be reported. 459 // that should be reported.
456 void SetTimeOffset(TimeDelta offset); 460 void SetTimeOffset(TimeDelta offset);
457 461
458 size_t GetObserverCountForTest() const; 462 size_t GetObserverCountForTest() const;
459 463
460 private: 464 private:
461 // This allows constructor and destructor to be private and usable only 465 // This allows constructor and destructor to be private and usable only
462 // by the Singleton class. 466 // by the Singleton class.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 506
503 private: 507 private:
504 TraceLog* trace_log_; 508 TraceLog* trace_log_;
505 NotificationCallback callback_copy_; 509 NotificationCallback callback_copy_;
506 int notification_; 510 int notification_;
507 }; 511 };
508 512
509 TraceLog(); 513 TraceLog();
510 ~TraceLog(); 514 ~TraceLog();
511 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); 515 const unsigned char* GetCategoryGroupEnabledInternal(const char* name);
512 void AddThreadNameMetadataEvents(); 516 void AddMetadataEvents();
513 517
514 #if defined(OS_ANDROID) 518 #if defined(OS_ANDROID)
515 void SendToATrace(char phase, 519 void SendToATrace(char phase,
516 const char* category_group, 520 const char* category_group,
517 const char* name, 521 const char* name,
518 unsigned long long id, 522 unsigned long long id,
519 int num_args, 523 int num_args,
520 const char** arg_names, 524 const char** arg_names,
521 const unsigned char* arg_types, 525 const unsigned char* arg_types,
522 const unsigned long long* arg_values, 526 const unsigned long long* arg_values,
523 scoped_ptr<ConvertableToTraceFormat> convertable_values[], 527 scoped_ptr<ConvertableToTraceFormat> convertable_values[],
524 unsigned char flags); 528 unsigned char flags);
525 static void ApplyATraceEnabledFlag(unsigned char* category_group_enabled); 529 static void ApplyATraceEnabledFlag(unsigned char* category_group_enabled);
526 #endif 530 #endif
527 531
528 TraceBuffer* GetTraceBuffer(); 532 TraceBuffer* GetTraceBuffer();
529 533
530 // TODO(nduca): switch to per-thread trace buffers to reduce thread 534 // TODO(nduca): switch to per-thread trace buffers to reduce thread
531 // synchronization. 535 // synchronization.
532 // This lock protects TraceLog member accesses from arbitrary threads. 536 // This lock protects TraceLog member accesses from arbitrary threads.
533 Lock lock_; 537 Lock lock_;
534 int enable_count_; 538 int enable_count_;
535 int num_traces_recorded_; 539 int num_traces_recorded_;
536 NotificationCallback notification_callback_; 540 NotificationCallback notification_callback_;
537 scoped_ptr<TraceBuffer> logged_events_; 541 scoped_ptr<TraceBuffer> logged_events_;
538 EventCallback event_callback_; 542 EventCallback event_callback_;
539 bool dispatching_to_observer_list_; 543 bool dispatching_to_observer_list_;
540 std::vector<EnabledStateObserver*> enabled_state_observer_list_; 544 std::vector<EnabledStateObserver*> enabled_state_observer_list_;
541 545
546 std::map<int, std::string> process_labels_;
547 int process_sort_index_;
548 base::hash_map<int, int> thread_sort_indices_;
549
542 base::hash_map<int, std::string> thread_names_; 550 base::hash_map<int, std::string> thread_names_;
543 base::hash_map<int, std::stack<TimeTicks> > thread_event_start_times_; 551 base::hash_map<int, std::stack<TimeTicks> > thread_event_start_times_;
544 base::hash_map<std::string, int> thread_colors_; 552 base::hash_map<std::string, int> thread_colors_;
545 553
546 // XORed with TraceID to make it unlikely to collide with other processes. 554 // XORed with TraceID to make it unlikely to collide with other processes.
547 unsigned long long process_id_hash_; 555 unsigned long long process_id_hash_;
548 556
549 int process_id_; 557 int process_id_;
550 558
551 TimeDelta time_offset_; 559 TimeDelta time_offset_;
(...skipping 10 matching lines...) Expand all
562 570
563 CategoryFilter category_filter_; 571 CategoryFilter category_filter_;
564 572
565 DISALLOW_COPY_AND_ASSIGN(TraceLog); 573 DISALLOW_COPY_AND_ASSIGN(TraceLog);
566 }; 574 };
567 575
568 } // namespace debug 576 } // namespace debug
569 } // namespace base 577 } // namespace base
570 578
571 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ 579 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_impl.cc » ('j') | content/gpu/gpu_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698