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

Side by Side Diff: ash/system/chromeos/power/power_status.cc

Issue 32443004: ash: Improve low-battery notification thresholds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply review feedback: update comment Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/system/chromeos/power/power_status.h" 5 #include "ash/system/chromeos/power/power_status.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 time.InSeconds() <= kMaxBatteryTimeToDisplaySec; 105 time.InSeconds() <= kMaxBatteryTimeToDisplaySec;
106 } 106 }
107 107
108 // static 108 // static
109 void PowerStatus::SplitTimeIntoHoursAndMinutes(const base::TimeDelta& time, 109 void PowerStatus::SplitTimeIntoHoursAndMinutes(const base::TimeDelta& time,
110 int* hours, 110 int* hours,
111 int* minutes) { 111 int* minutes) {
112 DCHECK(hours); 112 DCHECK(hours);
113 DCHECK(minutes); 113 DCHECK(minutes);
114 *hours = time.InHours(); 114 *hours = time.InHours();
115 *minutes = (time - base::TimeDelta::FromHours(*hours)).InMinutes(); 115 const double seconds =
116 (time - base::TimeDelta::FromHours(*hours)).InSecondsF();
117 *minutes = static_cast<int>(seconds / 60.0 + 0.5);
116 } 118 }
117 119
118 void PowerStatus::AddObserver(Observer* observer) { 120 void PowerStatus::AddObserver(Observer* observer) {
119 DCHECK(observer); 121 DCHECK(observer);
120 observers_.AddObserver(observer); 122 observers_.AddObserver(observer);
121 } 123 }
122 124
123 void PowerStatus::RemoveObserver(Observer* observer) { 125 void PowerStatus::RemoveObserver(Observer* observer) {
124 DCHECK(observer); 126 DCHECK(observer);
125 observers_.RemoveObserver(observer); 127 observers_.RemoveObserver(observer);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 287
286 void PowerStatus::PowerChanged( 288 void PowerStatus::PowerChanged(
287 const power_manager::PowerSupplyProperties& proto) { 289 const power_manager::PowerSupplyProperties& proto) {
288 proto_ = proto; 290 proto_ = proto;
289 SanitizeProto(&proto_); 291 SanitizeProto(&proto_);
290 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); 292 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged());
291 } 293 }
292 294
293 } // namespace internal 295 } // namespace internal
294 } // namespace ash 296 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/power/power_status.h ('k') | ash/system/chromeos/power/power_status_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698