Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/time/time.h" | |
| 6 #include "chromeos/dbus/power_data_collector.h" | |
| 7 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | |
| 8 | |
| 9 namespace chromeos { | |
| 10 | |
| 11 PowerDataCollector::PowerDataCollector(PowerManagerClient* pm_client) | |
| 12 : pm_client_(pm_client) { | |
|
stevenjb
2013/12/04 00:51:47
This should just set pm_client_(DBusThreadManager:
| |
| 13 power_supply_.reset(new std::vector<PowerSupplySnapshot>); | |
| 14 pm_client_->AddObserver(this); | |
|
stevenjb
2013/12/04 00:51:47
Probably want to call pm_client_->RequestStatusUpd
| |
| 15 } | |
| 16 | |
| 17 void PowerDataCollector::PowerChanged( | |
| 18 const power_manager::PowerSupplyProperties& prop) { | |
| 19 base::Time now = base::Time::NowFromSystemTime(); | |
| 20 | |
| 21 PowerSupplySnapshot snapshot = { | |
| 22 now.ToInternalValue(), | |
| 23 prop.external_power() != power_manager::PowerSupplyProperties::DISCONNECTED, | |
| 24 prop.battery_percent()}; | |
| 25 | |
| 26 power_supply_->push_back(snapshot); | |
| 27 } | |
| 28 | |
| 29 PowerDataCollector::~PowerDataCollector() { | |
|
stevenjb
2013/12/04 00:51:47
Should follow constructor
| |
| 30 pm_client_->RemoveObserver(this); | |
| 31 } | |
| 32 | |
| 33 } // namespace chromeos | |
| OLD | NEW |