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 "ash/metrics/task_switch_time_tracker.h" | 5 #include "ash/metrics/task_switch_time_tracker.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/time/default_tick_clock.h" | 8 #include "base/time/default_tick_clock.h" |
9 | 9 |
10 namespace ash { | 10 namespace ash { |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 TaskSwitchTimeTracker::TaskSwitchTimeTracker(const std::string& histogram_name) | 28 TaskSwitchTimeTracker::TaskSwitchTimeTracker(const std::string& histogram_name) |
29 : histogram_name_(histogram_name), | 29 : histogram_name_(histogram_name), |
30 tick_clock_(new base::DefaultTickClock()) { | 30 tick_clock_(new base::DefaultTickClock()) { |
31 } | 31 } |
32 | 32 |
33 TaskSwitchTimeTracker::TaskSwitchTimeTracker( | 33 TaskSwitchTimeTracker::TaskSwitchTimeTracker( |
34 const std::string& histogram_name, | 34 const std::string& histogram_name, |
35 scoped_ptr<base::TickClock> tick_clock) | 35 std::unique_ptr<base::TickClock> tick_clock) |
36 : histogram_name_(histogram_name), tick_clock_(tick_clock.release()) { | 36 : histogram_name_(histogram_name), tick_clock_(tick_clock.release()) {} |
37 } | |
38 | 37 |
39 TaskSwitchTimeTracker::~TaskSwitchTimeTracker() { | 38 TaskSwitchTimeTracker::~TaskSwitchTimeTracker() { |
40 } | 39 } |
41 | 40 |
42 void TaskSwitchTimeTracker::OnTaskSwitch() { | 41 void TaskSwitchTimeTracker::OnTaskSwitch() { |
43 if (!HasLastActionTime()) | 42 if (!HasLastActionTime()) |
44 SetLastActionTime(); | 43 SetLastActionTime(); |
45 else | 44 else |
46 RecordTimeDelta(); | 45 RecordTimeDelta(); |
47 } | 46 } |
(...skipping 30 matching lines...) Expand all Loading... |
78 } | 77 } |
79 | 78 |
80 #if DCHECK_IS_ON() | 79 #if DCHECK_IS_ON() |
81 histogram_->CheckName(histogram_name_); | 80 histogram_->CheckName(histogram_name_); |
82 #endif // DCHECK_IS_ON() | 81 #endif // DCHECK_IS_ON() |
83 | 82 |
84 return histogram_; | 83 return histogram_; |
85 } | 84 } |
86 | 85 |
87 } // namespace ash | 86 } // namespace ash |
OLD | NEW |