| OLD | NEW |
| 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/common/system/chromeos/power/power_status.h" | 5 #include "ash/common/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/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 g_power_status = NULL; | 187 g_power_status = NULL; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // static | 190 // static |
| 191 bool PowerStatus::IsInitialized() { | 191 bool PowerStatus::IsInitialized() { |
| 192 return g_power_status != NULL; | 192 return g_power_status != NULL; |
| 193 } | 193 } |
| 194 | 194 |
| 195 // static | 195 // static |
| 196 PowerStatus* PowerStatus::Get() { | 196 PowerStatus* PowerStatus::Get() { |
| 197 CHECK(g_power_status) << "PowerStatus::Get() called before Initialize()."; | 197 // PowerStatus::Get() called before Initialize(). |
| 198 CHECK(g_power_status); |
| 198 return g_power_status; | 199 return g_power_status; |
| 199 } | 200 } |
| 200 | 201 |
| 201 // static | 202 // static |
| 202 bool PowerStatus::ShouldDisplayBatteryTime(const base::TimeDelta& time) { | 203 bool PowerStatus::ShouldDisplayBatteryTime(const base::TimeDelta& time) { |
| 203 return time >= base::TimeDelta::FromMinutes(1) && | 204 return time >= base::TimeDelta::FromMinutes(1) && |
| 204 time.InSeconds() <= kMaxBatteryTimeToDisplaySec; | 205 time.InSeconds() <= kMaxBatteryTimeToDisplaySec; |
| 205 } | 206 } |
| 206 | 207 |
| 207 // static | 208 // static |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 510 |
| 510 void PowerStatus::PowerChanged( | 511 void PowerStatus::PowerChanged( |
| 511 const power_manager::PowerSupplyProperties& proto) { | 512 const power_manager::PowerSupplyProperties& proto) { |
| 512 proto_ = proto; | 513 proto_ = proto; |
| 513 SanitizeProto(&proto_); | 514 SanitizeProto(&proto_); |
| 514 for (auto& observer : observers_) | 515 for (auto& observer : observers_) |
| 515 observer.OnPowerStatusChanged(); | 516 observer.OnPowerStatusChanged(); |
| 516 } | 517 } |
| 517 | 518 |
| 518 } // namespace ash | 519 } // namespace ash |
| OLD | NEW |