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

Side by Side Diff: base/tracked_objects.cc

Issue 3452030: FBTF: Moves code to the headers. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 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
« no previous file with comments | « base/tracked_objects.h ('k') | base/waitable_event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/tracked_objects.h" 5 #include "base/tracked_objects.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // static 84 // static
85 ThreadData* ThreadData::first_ = NULL; 85 ThreadData* ThreadData::first_ = NULL;
86 // static 86 // static
87 Lock ThreadData::list_lock_; 87 Lock ThreadData::list_lock_;
88 88
89 // static 89 // static
90 ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED; 90 ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED;
91 91
92 ThreadData::ThreadData() : next_(NULL), message_loop_(MessageLoop::current()) {} 92 ThreadData::ThreadData() : next_(NULL), message_loop_(MessageLoop::current()) {}
93 93
94 ThreadData::~ThreadData() {}
95
94 // static 96 // static
95 ThreadData* ThreadData::current() { 97 ThreadData* ThreadData::current() {
96 if (!tls_index_.initialized()) 98 if (!tls_index_.initialized())
97 return NULL; 99 return NULL;
98 100
99 ThreadData* registry = static_cast<ThreadData*>(tls_index_.Get()); 101 ThreadData* registry = static_cast<ThreadData*>(tls_index_.Get());
100 if (!registry) { 102 if (!registry) {
101 // We have to create a new registry for ThreadData. 103 // We have to create a new registry for ThreadData.
102 bool too_late_to_create = false; 104 bool too_late_to_create = false;
103 { 105 {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // TODO(jar): Provide version that gathers stats safely via PostTask in all 579 // TODO(jar): Provide version that gathers stats safely via PostTask in all
578 // cases where thread_data supplies a message_loop to post to. Be careful to 580 // cases where thread_data supplies a message_loop to post to. Be careful to
579 // handle message_loops that are destroyed!?! 581 // handle message_loops that are destroyed!?!
580 for (ThreadData* thread_data = my_list; 582 for (ThreadData* thread_data = my_list;
581 thread_data; 583 thread_data;
582 thread_data = thread_data->next()) { 584 thread_data = thread_data->next()) {
583 Append(*thread_data); 585 Append(*thread_data);
584 } 586 }
585 } 587 }
586 588
589 DataCollector::~DataCollector() {
590 }
591
587 void DataCollector::Append(const ThreadData& thread_data) { 592 void DataCollector::Append(const ThreadData& thread_data) {
588 // Get copy of data (which is done under ThreadData's lock). 593 // Get copy of data (which is done under ThreadData's lock).
589 ThreadData::BirthMap birth_map; 594 ThreadData::BirthMap birth_map;
590 thread_data.SnapshotBirthMap(&birth_map); 595 thread_data.SnapshotBirthMap(&birth_map);
591 ThreadData::DeathMap death_map; 596 ThreadData::DeathMap death_map;
592 thread_data.SnapshotDeathMap(&death_map); 597 thread_data.SnapshotDeathMap(&death_map);
593 598
594 // Use our lock to protect our accumulation activity. 599 // Use our lock to protect our accumulation activity.
595 AutoLock lock(accumulation_lock_); 600 AutoLock lock(accumulation_lock_);
596 601
(...skipping 23 matching lines...) Expand all
620 for (BirthCount::iterator it = global_birth_count_.begin(); 625 for (BirthCount::iterator it = global_birth_count_.begin();
621 it != global_birth_count_.end(); ++it) { 626 it != global_birth_count_.end(); ++it) {
622 if (it->second > 0) 627 if (it->second > 0)
623 collection_.push_back(Snapshot(*it->first, it->second)); 628 collection_.push_back(Snapshot(*it->first, it->second));
624 } 629 }
625 } 630 }
626 631
627 //------------------------------------------------------------------------------ 632 //------------------------------------------------------------------------------
628 // Aggregation 633 // Aggregation
629 634
635 Aggregation::Aggregation()
636 : birth_count_(0) {
637 }
638
639 Aggregation::~Aggregation() {
640 }
641
630 void Aggregation::AddDeathSnapshot(const Snapshot& snapshot) { 642 void Aggregation::AddDeathSnapshot(const Snapshot& snapshot) {
631 AddBirth(snapshot.birth()); 643 AddBirth(snapshot.birth());
632 death_threads_[snapshot.death_thread()]++; 644 death_threads_[snapshot.death_thread()]++;
633 AddDeathData(snapshot.death_data()); 645 AddDeathData(snapshot.death_data());
634 } 646 }
635 647
636 void Aggregation::AddBirths(const Births& births) { 648 void Aggregation::AddBirths(const Births& births) {
637 AddBirth(births); 649 AddBirth(births);
638 birth_count_ += births.birth_count(); 650 birth_count_ += births.birth_count();
639 } 651 }
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 (combined_selectors_ & BIRTH_THREAD) ? "*" : 1032 (combined_selectors_ & BIRTH_THREAD) ? "*" :
1021 sample.birth().birth_thread()->ThreadName().c_str(), 1033 sample.birth().birth_thread()->ThreadName().c_str(),
1022 (combined_selectors_ & DEATH_THREAD) ? "*" : 1034 (combined_selectors_ & DEATH_THREAD) ? "*" :
1023 sample.DeathThreadName().c_str()); 1035 sample.DeathThreadName().c_str());
1024 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), 1036 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE),
1025 !(combined_selectors_ & BIRTH_FUNCTION), 1037 !(combined_selectors_ & BIRTH_FUNCTION),
1026 output); 1038 output);
1027 } 1039 }
1028 1040
1029 } // namespace tracked_objects 1041 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/tracked_objects.h ('k') | base/waitable_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698