OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/common/task_tracker.h" | 5 #include "mojo/common/task_tracker.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const void* program_counter) { | 47 const void* program_counter) { |
48 // So far we don't track nested invocations. | 48 // So far we don't track nested invocations. |
49 if (IsAlive()) | 49 if (IsAlive()) |
50 return false; | 50 return false; |
51 birth_ = tracked_objects::ThreadData::TallyABirthIfActive( | 51 birth_ = tracked_objects::ThreadData::TallyABirthIfActive( |
52 tracked_objects::Location(function_name, file_name, line_number, | 52 tracked_objects::Location(function_name, file_name, line_number, |
53 program_counter)); | 53 program_counter)); |
54 if (!birth_) | 54 if (!birth_) |
55 return false; | 55 return false; |
56 | 56 |
57 tracked_objects::ThreadData::PrepareForStartOfRun(birth_); | |
58 (new (stopwatch()) tracked_objects::TaskStopwatch())->Start(); | 57 (new (stopwatch()) tracked_objects::TaskStopwatch())->Start(); |
59 return true; | 58 return true; |
60 } | 59 } |
61 | 60 |
62 void TrackingActivation::End() { | 61 void TrackingActivation::End() { |
63 DCHECK(IsAlive()); | 62 DCHECK(IsAlive()); |
64 stopwatch()->Stop(); | 63 stopwatch()->Stop(); |
65 tracked_objects::ThreadData::TallyRunInAScopedRegionIfTracking(birth_, | 64 tracked_objects::ThreadData::TallyRunInAScopedRegionIfTracking(birth_, |
66 *stopwatch()); | 65 *stopwatch()); |
67 stopwatch()->tracked_objects::TaskStopwatch::~TaskStopwatch(); | 66 stopwatch()->tracked_objects::TaskStopwatch::~TaskStopwatch(); |
(...skipping 26 matching lines...) Expand all Loading... |
94 void TaskTracker::EndTracking(intptr_t id) { | 93 void TaskTracker::EndTracking(intptr_t id) { |
95 if (0 == id) | 94 if (0 == id) |
96 return; | 95 return; |
97 // |EndTracking()| must be called from the same thread of |StartTracking()|. | 96 // |EndTracking()| must be called from the same thread of |StartTracking()|. |
98 DCHECK_EQ(reinterpret_cast<TrackingActivation*>(id), g_activation.Get()); | 97 DCHECK_EQ(reinterpret_cast<TrackingActivation*>(id), g_activation.Get()); |
99 reinterpret_cast<TrackingActivation*>(id)->End(); | 98 reinterpret_cast<TrackingActivation*>(id)->End(); |
100 } | 99 } |
101 | 100 |
102 } // namespace common | 101 } // namespace common |
103 } // namespace mojo | 102 } // namespace mojo |
OLD | NEW |