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

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: Fixed a plethora of build issues 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') | dbus/message.h » ('J')
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 c3cae3f1d7b8c240f2a45cae2df7bb517121ceec..1af2294177e18ba43c1bac89a07e6d1f1adb410a 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"
@@ -167,13 +168,23 @@ class PowerManagerClientImpl : public PowerManagerClient {
}
virtual void RequestStatusUpdate() OVERRIDE {
- dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
+ dbus::MethodCall get_all_method_call(power_manager::kPowerManagerInterface,
satorux1 2012/02/07 21:16:49 Do we still need to call the older method? I thoug
rharrison 2012/02/14 17:03:09 Done.
power_manager::kGetAllPropertiesMethod);
satorux1 2012/02/07 21:16:49 nit: please align parameters vertically: dbus::Me
rharrison 2012/02/14 17:03:09 Done.
power_manager_proxy_->CallMethod(
- &method_call,
+ &get_all_method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&PowerManagerClientImpl::OnGetAllPropertiesMethod,
weak_ptr_factory_.GetWeakPtr()));
+
+ dbus::MethodCall get_power_method_call(
+ power_manager::kPowerManagerInterface,
+ power_manager::kGetPowerSupplyPropertiesMethod);
+ power_manager_proxy_->CallMethod(
+ &get_power_method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&PowerManagerClientImpl::OnGetPowerSupplyPropertiesMethod,
+ weak_ptr_factory_.GetWeakPtr()));
+
}
// Requests restart of the system.
@@ -344,6 +355,30 @@ class PowerManagerClientImpl : public PowerManagerClient {
FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status));
}
+
+ void OnGetPowerSupplyPropertiesMethod(dbus::Response* response) {
+ if (!response) {
+ LOG(ERROR) << "Error calling "
+ << power_manager::kGetPowerSupplyPropertiesMethod;
+ return;
+ }
+
+ dbus::MessageReader reader(response);
+ PowerSupplyProperties protobuf;
+ reader.PopArrayOfBytesAsProto(&protobuf);
+
+ PowerSupplyStatus status;
+ 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));
+ }
+
void OnGetIdleTime(const CalculateIdleTimeCallback& callback,
dbus::Response* response) {
if (!response) {
« no previous file with comments | « no previous file | chrome/chrome_browser.gypi » ('j') | dbus/message.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698