| 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 char* alternate_selector = getenv(kAlternateProfilerTime); | 651 NowFunction* alternate_time_source = GetAlternateTimeSource(); |
| 652 if (!alternate_selector) | 652 if (alternate_time_source) |
| 653 return; | 653 ThreadData::SetAlternateTimeSource(alternate_time_source); |
| 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 } | |
| 666 } | 654 } |
| 667 | 655 |
| 668 bool ThreadData::Initialize() { | 656 bool ThreadData::Initialize() { |
| 669 if (!kTrackAllTaskObjects) | 657 if (!kTrackAllTaskObjects) |
| 670 return false; // Not compiled in. | 658 return false; // Not compiled in. |
| 671 if (status_ >= DEACTIVATED) | 659 if (status_ >= DEACTIVATED) |
| 672 return true; // Someone else did the initialization. | 660 return true; // Someone else did the initialization. |
| 673 // Due to racy lazy initialization in tests, we'll need to recheck status_ | 661 // Due to racy lazy initialization in tests, we'll need to recheck status_ |
| 674 // after we acquire the lock. | 662 // after we acquire the lock. |
| 675 | 663 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 : process_id(base::GetCurrentProcId()) { | 860 : process_id(base::GetCurrentProcId()) { |
| 873 #else | 861 #else |
| 874 : process_id(0) { | 862 : process_id(0) { |
| 875 #endif | 863 #endif |
| 876 } | 864 } |
| 877 | 865 |
| 878 ProcessDataSnapshot::~ProcessDataSnapshot() { | 866 ProcessDataSnapshot::~ProcessDataSnapshot() { |
| 879 } | 867 } |
| 880 | 868 |
| 881 } // namespace tracked_objects | 869 } // namespace tracked_objects |
| OLD | NEW |