blob: d7f4003e74d1dea0787a1a1708f84b9500766c82 [file] [log] [blame]
mukesh agrawal7c1fece2012-01-13 11:31:27 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkov394b7d42011-11-03 15:48:02 +01002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_POWER_MANAGER_PROXY_INTERFACE_
6#define SHILL_POWER_MANAGER_PROXY_INTERFACE_
7
8#include <base/basictypes.h>
9
10namespace shill {
11
mukesh agrawal7c1fece2012-01-13 11:31:27 -080012// This class provides events from the power manager. To use this class, create
13// a subclass from PowerManagerProxyDelegate and implement its member functions.
14// Call ProxyFactory::CreatePowerManagerProxy() to create an instance of this
15// proxy, passing it a pointer to the delegate you created. When an event from
16// the power manager is received, your delegate's member function will be
17// called. You retain ownership of the delegate and must ensure that the proxy
18// is deleted before the delegate.
19
20
Darin Petkov394b7d42011-11-03 15:48:02 +010021class PowerManagerProxyInterface {
22 public:
23 virtual ~PowerManagerProxyInterface() {}
24
25 // Sends a request to PowerManager to wait for this RPC client for up to
26 // |delay_ms| before suspending the system. When initiating suspend,
27 // PowerManager broadcasts a SuspendDelay signal and suspends the system after
28 // the maximal registered timeout expires or all registered clients are ready
29 // to suspend. Clients tell PowerManager that they are ready through the
30 // SuspendReady signal.
31 //
32 // TODO(petkov): Implement SuspendReady signal sending to
33 // PowerManager. Unfortunately, SuspendReady is declared as a signal when it
34 // should be a method.
35 virtual void RegisterSuspendDelay(uint32 delay_ms) = 0;
36};
37
38// PowerManager signal delegate to be associated with the proxy.
39class PowerManagerProxyDelegate {
40 public:
mukesh agrawal7c1fece2012-01-13 11:31:27 -080041 // Possible states broadcast from the powerd_suspend script.
42 enum SuspendState {
43 kOn,
44 kStandby,
45 kMem,
46 kDisk,
47 // Place new states above kUnknown.
48 kUnknown
49 };
50
Darin Petkov394b7d42011-11-03 15:48:02 +010051 virtual ~PowerManagerProxyDelegate() {}
52
53 // Broadcasted by PowerManager when it initiates suspend. RPC clients that
54 // have registered through RegisterSuspendDelay tell PowerManager that they're
55 // ready to suspend by sending a SuspendReady signal with the same
56 // |sequence_number|.
57 virtual void OnSuspendDelay(uint32 sequence_number) = 0;
mukesh agrawal7c1fece2012-01-13 11:31:27 -080058
59 // This method will be called when suspending or resuming. |new_power_state|
60 // will be "kMem" when suspending (to memory), or "kOn" when resuming.
61 virtual void OnPowerStateChanged(SuspendState new_power_state) = 0;
Darin Petkov394b7d42011-11-03 15:48:02 +010062};
63
64} // namespace shill
65
66#endif // SHILL_POWER_MANAGER_PROXY_INTERFACE_