shill: power management framework

Add handling of the PowerStateChange event from the power manager.

BUG=chromium-os:22407
TEST=Manual.  Created an instance of PowerManager and verified that signals are
received when the lid is closed and opened.  Verified that when using the root
path, RegisterSuspendDelay is received by powerd.

Change-Id: I040c60b1704879529e1c2e66edc4ddceef3fa39d
Reviewed-on: https://gerrit.chromium.org/gerrit/14162
Commit-Ready: Gary Morain <gmorain@chromium.org>
Reviewed-by: Gary Morain <gmorain@chromium.org>
Tested-by: Gary Morain <gmorain@chromium.org>
diff --git a/power_manager_proxy_interface.h b/power_manager_proxy_interface.h
index d95981e..d7f4003 100644
--- a/power_manager_proxy_interface.h
+++ b/power_manager_proxy_interface.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -9,6 +9,15 @@
 
 namespace shill {
 
+// This class provides events from the power manager.  To use this class, create
+// a subclass from PowerManagerProxyDelegate and implement its member functions.
+// Call ProxyFactory::CreatePowerManagerProxy() to create an instance of this
+// proxy, passing it a pointer to the delegate you created.  When an event from
+// the power manager is received, your delegate's member function will be
+// called. You retain ownership of the delegate and must ensure that the proxy
+// is deleted before the delegate.
+
+
 class PowerManagerProxyInterface {
  public:
   virtual ~PowerManagerProxyInterface() {}
@@ -29,6 +38,16 @@
 // PowerManager signal delegate to be associated with the proxy.
 class PowerManagerProxyDelegate {
  public:
+  // Possible states broadcast from the powerd_suspend script.
+  enum SuspendState {
+    kOn,
+    kStandby,
+    kMem,
+    kDisk,
+    // Place new states above kUnknown.
+    kUnknown
+  };
+
   virtual ~PowerManagerProxyDelegate() {}
 
   // Broadcasted by PowerManager when it initiates suspend. RPC clients that
@@ -36,6 +55,10 @@
   // ready to suspend by sending a SuspendReady signal with the same
   // |sequence_number|.
   virtual void OnSuspendDelay(uint32 sequence_number) = 0;
+
+  // This method will be called when suspending or resuming.  |new_power_state|
+  // will be "kMem" when suspending (to memory), or "kOn" when resuming.
+  virtual void OnPowerStateChanged(SuspendState new_power_state) = 0;
 };
 
 }  // namespace shill