| 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 #include "base/tracked_objects.h" | 5 #include "base/tracked_objects.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 //------------------------------------------------------------------------------ | 221 //------------------------------------------------------------------------------ |
| 222 Births::Births(const Location& location, const ThreadData& current) | 222 Births::Births(const Location& location, const ThreadData& current) |
| 223 : BirthOnThread(location, current), | 223 : BirthOnThread(location, current), |
| 224 birth_count_(1) { } | 224 birth_count_(1) { } |
| 225 | 225 |
| 226 int Births::birth_count() const { return birth_count_; } | 226 int Births::birth_count() const { return birth_count_; } |
| 227 | 227 |
| 228 void Births::RecordBirth() { ++birth_count_; } | 228 void Births::RecordBirth() { ++birth_count_; } |
| 229 | 229 |
| 230 void Births::ForgetBirth() { --birth_count_; } | |
| 231 | |
| 232 void Births::Clear() { birth_count_ = 0; } | |
| 233 | |
| 234 //------------------------------------------------------------------------------ | 230 //------------------------------------------------------------------------------ |
| 235 // ThreadData maintains the central data for all births and deaths on a single | 231 // ThreadData maintains the central data for all births and deaths on a single |
| 236 // thread. | 232 // thread. |
| 237 | 233 |
| 238 // TODO(jar): We should pull all these static vars together, into a struct, and | 234 // TODO(jar): We should pull all these static vars together, into a struct, and |
| 239 // optimize layout so that we benefit from locality of reference during accesses | 235 // optimize layout so that we benefit from locality of reference during accesses |
| 240 // to them. | 236 // to them. |
| 241 | 237 |
| 242 // static | 238 // static |
| 243 NowFunction* ThreadData::now_function_ = NULL; | 239 NowFunction* ThreadData::now_function_ = NULL; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 643 } |
| 648 | 644 |
| 649 if (!kTrackParentChildLinks) | 645 if (!kTrackParentChildLinks) |
| 650 return; | 646 return; |
| 651 | 647 |
| 652 for (ParentChildSet::iterator it = parent_child_set_.begin(); | 648 for (ParentChildSet::iterator it = parent_child_set_.begin(); |
| 653 it != parent_child_set_.end(); ++it) | 649 it != parent_child_set_.end(); ++it) |
| 654 parent_child_set->insert(*it); | 650 parent_child_set->insert(*it); |
| 655 } | 651 } |
| 656 | 652 |
| 657 // static | |
| 658 void ThreadData::ResetAllThreadData() { | |
| 659 ThreadData* my_list = first(); | |
| 660 | |
| 661 for (ThreadData* thread_data = my_list; | |
| 662 thread_data; | |
| 663 thread_data = thread_data->next()) | |
| 664 thread_data->Reset(); | |
| 665 } | |
| 666 | |
| 667 void ThreadData::Reset() { | |
| 668 base::AutoLock lock(map_lock_); | |
| 669 for (DeathMap::iterator it = death_map_.begin(); | |
| 670 it != death_map_.end(); ++it) | |
| 671 it->second.Clear(); | |
| 672 for (BirthMap::iterator it = birth_map_.begin(); | |
| 673 it != birth_map_.end(); ++it) | |
| 674 it->second->Clear(); | |
| 675 } | |
| 676 | |
| 677 static void OptionallyInitializeAlternateTimer() { | 653 static void OptionallyInitializeAlternateTimer() { |
| 678 NowFunction* alternate_time_source = GetAlternateTimeSource(); | 654 NowFunction* alternate_time_source = GetAlternateTimeSource(); |
| 679 if (alternate_time_source) | 655 if (alternate_time_source) |
| 680 ThreadData::SetAlternateTimeSource(alternate_time_source); | 656 ThreadData::SetAlternateTimeSource(alternate_time_source); |
| 681 } | 657 } |
| 682 | 658 |
| 683 bool ThreadData::Initialize() { | 659 bool ThreadData::Initialize() { |
| 684 if (!kTrackAllTaskObjects) | 660 if (!kTrackAllTaskObjects) |
| 685 return false; // Not compiled in. | 661 return false; // Not compiled in. |
| 686 if (status_ >= DEACTIVATED) | 662 if (status_ >= DEACTIVATED) |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 : process_id(base::GetCurrentProcId()) { | 966 : process_id(base::GetCurrentProcId()) { |
| 991 #else | 967 #else |
| 992 : process_id(0) { | 968 : process_id(0) { |
| 993 #endif | 969 #endif |
| 994 } | 970 } |
| 995 | 971 |
| 996 ProcessDataSnapshot::~ProcessDataSnapshot() { | 972 ProcessDataSnapshot::~ProcessDataSnapshot() { |
| 997 } | 973 } |
| 998 | 974 |
| 999 } // namespace tracked_objects | 975 } // namespace tracked_objects |
| OLD | NEW |