Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: ash/metrics/task_switch_time_tracker.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
11 11
12 namespace { 12 namespace {
13 13
14 // The number of buckets in the histogram. 14 // The number of buckets in the histogram.
15 // See IMPORTANT note below if you want to change this value! 15 // See IMPORTANT note below if you want to change this value!
16 const size_t kBucketCount = 50; 16 const size_t kBucketCount = 50;
17 17
18 // The underflow (aka minimum) bucket size for the histogram. 18 // The underflow (aka minimum) bucket size for the histogram.
19 // See IMPORTANT note below if you want to change this value! 19 // See IMPORTANT note below if you want to change this value!
20 const int kMinBucketSizeInSeconds = 0; 20 const int kMinBucketSizeInSeconds = 0;
21 21
22 // The overflow (aka maximium) bucket size for the histogram. 22 // The overflow (aka maximium) bucket size for the histogram.
23 // See IMPORTANT note below if you want to change this value! 23 // See IMPORTANT note below if you want to change this value!
24 const int kMaxBucketSizeInSeconds = 60 * 60; 24 const int kMaxBucketSizeInSeconds = 60 * 60;
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 }
32 31
33 TaskSwitchTimeTracker::TaskSwitchTimeTracker( 32 TaskSwitchTimeTracker::TaskSwitchTimeTracker(
34 const std::string& histogram_name, 33 const std::string& histogram_name,
35 std::unique_ptr<base::TickClock> tick_clock) 34 std::unique_ptr<base::TickClock> tick_clock)
36 : histogram_name_(histogram_name), tick_clock_(tick_clock.release()) {} 35 : histogram_name_(histogram_name), tick_clock_(tick_clock.release()) {}
37 36
38 TaskSwitchTimeTracker::~TaskSwitchTimeTracker() { 37 TaskSwitchTimeTracker::~TaskSwitchTimeTracker() {}
39 }
40 38
41 void TaskSwitchTimeTracker::OnTaskSwitch() { 39 void TaskSwitchTimeTracker::OnTaskSwitch() {
42 if (!HasLastActionTime()) 40 if (!HasLastActionTime())
43 SetLastActionTime(); 41 SetLastActionTime();
44 else 42 else
45 RecordTimeDelta(); 43 RecordTimeDelta();
46 } 44 }
47 45
48 bool TaskSwitchTimeTracker::HasLastActionTime() const { 46 bool TaskSwitchTimeTracker::HasLastActionTime() const {
49 return last_action_time_ != base::TimeTicks(); 47 return last_action_time_ != base::TimeTicks();
(...skipping 27 matching lines...) Expand all
77 } 75 }
78 76
79 #if DCHECK_IS_ON() 77 #if DCHECK_IS_ON()
80 histogram_->CheckName(histogram_name_); 78 histogram_->CheckName(histogram_name_);
81 #endif // DCHECK_IS_ON() 79 #endif // DCHECK_IS_ON()
82 80
83 return histogram_; 81 return histogram_;
84 } 82 }
85 83
86 } // namespace ash 84 } // namespace ash
OLDNEW
« no previous file with comments | « ash/metrics/task_switch_metrics_recorder_unittest.cc ('k') | ash/metrics/task_switch_time_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698