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

Unified Diff: chrome/browser/chromeos/dbus/power_manager_client.cc

Issue 9318007: Adding using protobuf based communication for the power information transfer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rewrote the gypi rule for the protobuf, so to not leak into non-cros builds Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/dbus/power_manager_client.cc
diff --git a/chrome/browser/chromeos/dbus/power_manager_client.cc b/chrome/browser/chromeos/dbus/power_manager_client.cc
index cdbcb2fa2e0c3496d8a374352e3c5f1919df54c9..2963fadbccc4cd7d3115bc4a05c702cd1585e6b9 100644
--- a/chrome/browser/chromeos/dbus/power_manager_client.cc
+++ b/chrome/browser/chromeos/dbus/power_manager_client.cc
@@ -14,6 +14,7 @@
#include "base/stringprintf.h"
#include "base/time.h"
#include "base/timer.h"
+#include "chrome/browser/chromeos/dbus/power_supply_properties.pb.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
@@ -181,12 +182,13 @@ class PowerManagerClientImpl : public PowerManagerClient {
}
virtual void RequestStatusUpdate(UpdateRequestType update_type) OVERRIDE {
- dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
- power_manager::kGetAllPropertiesMethod);
+ dbus::MethodCall method_call(
+ power_manager::kPowerManagerInterface,
+ power_manager::kGetPowerSupplyPropertiesMethod);
power_manager_proxy_->CallMethod(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&PowerManagerClientImpl::OnGetAllPropertiesMethod,
+ base::Bind(&PowerManagerClientImpl::OnGetPowerSupplyPropertiesMethod,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -319,29 +321,24 @@ class PowerManagerClientImpl : public PowerManagerClient {
RequestStatusUpdate(UPDATE_POLL);
}
- void OnGetAllPropertiesMethod(dbus::Response* response) {
+ void OnGetPowerSupplyPropertiesMethod(dbus::Response* response) {
if (!response) {
- LOG(ERROR) << "Error calling " << power_manager::kGetAllPropertiesMethod;
+ LOG(ERROR) << "Error calling "
+ << power_manager::kGetPowerSupplyPropertiesMethod;
return;
}
+
dbus::MessageReader reader(response);
+ PowerSupplyProperties protobuf;
+ reader.PopArrayOfBytesAsProto(&protobuf);
+
PowerSupplyStatus status;
- double unused_battery_voltage = 0.0;
- double unused_battery_energy = 0.0;
- double unused_battery_energy_rate = 0.0;
- if (!reader.PopBool(&status.line_power_on) ||
- !reader.PopDouble(&unused_battery_energy) ||
- !reader.PopDouble(&unused_battery_energy_rate) ||
- !reader.PopDouble(&unused_battery_voltage) ||
- !reader.PopInt64(&status.battery_seconds_to_empty) ||
- !reader.PopInt64(&status.battery_seconds_to_full) ||
- !reader.PopDouble(&status.battery_percentage) ||
- !reader.PopBool(&status.battery_is_present) ||
- !reader.PopBool(&status.battery_is_full)) {
- LOG(ERROR) << "Error reading response from powerd: "
- << response->ToString();
- return;
- }
+ status.line_power_on = protobuf.line_power_on();
+ status.battery_seconds_to_empty = protobuf.battery_time_to_empty();
+ status.battery_seconds_to_full = protobuf.battery_time_to_full();
+ status.battery_percentage = protobuf.battery_percentage();
+ status.battery_is_present = protobuf.battery_is_present();
+ status.battery_is_full = protobuf.battery_is_charged();
VLOG(1) << "Power status: " << status.ToString();
FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status));
« no previous file with comments | « no previous file | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698