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 <ctype.h> | 7 #include <ctype.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 | 776 |
777 // Incarnation counter is only significant to testing, as it otherwise will | 777 // Incarnation counter is only significant to testing, as it otherwise will |
778 // never again change in this process. | 778 // never again change in this process. |
779 ++incarnation_counter_; | 779 ++incarnation_counter_; |
780 | 780 |
781 // The lock is not critical for setting status_, but it doesn't hurt. It also | 781 // The lock is not critical for setting status_, but it doesn't hurt. It also |
782 // ensures that if we have a racy initialization, that we'll bail as soon as | 782 // ensures that if we have a racy initialization, that we'll bail as soon as |
783 // we get the lock earlier in this method. | 783 // we get the lock earlier in this method. |
784 base::subtle::Release_Store(&status_, kInitialStartupState); | 784 base::subtle::Release_Store(&status_, kInitialStartupState); |
785 DCHECK(base::subtle::NoBarrier_Load(&status_) != UNINITIALIZED); | 785 DCHECK(base::subtle::NoBarrier_Load(&status_) != UNINITIALIZED); |
786 | |
787 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) | |
788 // Make sure heap tracking is enabled ASAP if the default state is active. | |
789 if (kInitialStartupState == PROFILING_ACTIVE && | |
790 !base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) { | |
791 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); | |
792 } | |
793 #endif // BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) | |
794 } | 786 } |
795 | 787 |
796 // static | 788 // static |
797 void ThreadData::InitializeAndSetTrackingStatus(Status status) { | 789 void ThreadData::InitializeAndSetTrackingStatus(Status status) { |
798 DCHECK_GE(status, DEACTIVATED); | 790 DCHECK_GE(status, DEACTIVATED); |
799 DCHECK_LE(status, PROFILING_ACTIVE); | 791 DCHECK_LE(status, PROFILING_ACTIVE); |
800 | 792 |
801 EnsureTlsInitialization(); // No-op if already initialized. | 793 EnsureTlsInitialization(); // No-op if already initialized. |
802 | 794 |
803 if (status > DEACTIVATED) { | 795 if (status > DEACTIVATED) |
804 status = PROFILING_ACTIVE; | 796 status = PROFILING_ACTIVE; |
805 | 797 |
806 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) | |
807 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) | |
808 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); | |
809 #endif // BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) | |
810 } | |
811 base::subtle::Release_Store(&status_, status); | 798 base::subtle::Release_Store(&status_, status); |
812 } | 799 } |
813 | 800 |
814 // static | 801 // static |
815 ThreadData::Status ThreadData::status() { | 802 ThreadData::Status ThreadData::status() { |
816 return static_cast<ThreadData::Status>(base::subtle::Acquire_Load(&status_)); | 803 return static_cast<ThreadData::Status>(base::subtle::Acquire_Load(&status_)); |
817 } | 804 } |
818 | 805 |
819 // static | 806 // static |
820 bool ThreadData::TrackingStatus() { | 807 bool ThreadData::TrackingStatus() { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 #endif | 1076 #endif |
1090 } | 1077 } |
1091 | 1078 |
1092 ProcessDataSnapshot::ProcessDataSnapshot(const ProcessDataSnapshot& other) = | 1079 ProcessDataSnapshot::ProcessDataSnapshot(const ProcessDataSnapshot& other) = |
1093 default; | 1080 default; |
1094 | 1081 |
1095 ProcessDataSnapshot::~ProcessDataSnapshot() { | 1082 ProcessDataSnapshot::~ProcessDataSnapshot() { |
1096 } | 1083 } |
1097 | 1084 |
1098 } // namespace tracked_objects | 1085 } // namespace tracked_objects |
OLD | NEW |