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 <math.h> | 7 #include <math.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 base::AutoLock lock(map_lock_); | 641 base::AutoLock lock(map_lock_); |
642 for (DeathMap::iterator it = death_map_.begin(); | 642 for (DeathMap::iterator it = death_map_.begin(); |
643 it != death_map_.end(); ++it) | 643 it != death_map_.end(); ++it) |
644 it->second.Clear(); | 644 it->second.Clear(); |
645 for (BirthMap::iterator it = birth_map_.begin(); | 645 for (BirthMap::iterator it = birth_map_.begin(); |
646 it != birth_map_.end(); ++it) | 646 it != birth_map_.end(); ++it) |
647 it->second->Clear(); | 647 it->second->Clear(); |
648 } | 648 } |
649 | 649 |
650 static void OptionallyInitializeAlternateTimer() { | 650 static void OptionallyInitializeAlternateTimer() { |
651 NowFunction* alternate_time_source = GetAlternateTimeSource(); | 651 char* alternate_selector = getenv(kAlternateProfilerTime); |
652 if (alternate_time_source) | 652 if (!alternate_selector) |
653 ThreadData::SetAlternateTimeSource(alternate_time_source); | 653 return; |
| 654 switch (*alternate_selector) { |
| 655 case '0': // This is the default value, and uses the wall clock time. |
| 656 break; |
| 657 case '1': { |
| 658 // Use the TCMalloc allocations-on-thread as a pseudo-time. |
| 659 ThreadData::SetAlternateTimeSource(GetAlternateTimeSource()); |
| 660 break; |
| 661 } |
| 662 default: |
| 663 NOTREACHED(); |
| 664 break; |
| 665 } |
654 } | 666 } |
655 | 667 |
656 bool ThreadData::Initialize() { | 668 bool ThreadData::Initialize() { |
657 if (!kTrackAllTaskObjects) | 669 if (!kTrackAllTaskObjects) |
658 return false; // Not compiled in. | 670 return false; // Not compiled in. |
659 if (status_ >= DEACTIVATED) | 671 if (status_ >= DEACTIVATED) |
660 return true; // Someone else did the initialization. | 672 return true; // Someone else did the initialization. |
661 // Due to racy lazy initialization in tests, we'll need to recheck status_ | 673 // Due to racy lazy initialization in tests, we'll need to recheck status_ |
662 // after we acquire the lock. | 674 // after we acquire the lock. |
663 | 675 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 : process_id(base::GetCurrentProcId()) { | 872 : process_id(base::GetCurrentProcId()) { |
861 #else | 873 #else |
862 : process_id(0) { | 874 : process_id(0) { |
863 #endif | 875 #endif |
864 } | 876 } |
865 | 877 |
866 ProcessDataSnapshot::~ProcessDataSnapshot() { | 878 ProcessDataSnapshot::~ProcessDataSnapshot() { |
867 } | 879 } |
868 | 880 |
869 } // namespace tracked_objects | 881 } // namespace tracked_objects |
OLD | NEW |