blob: 6049c49e5ec3f66bc178aa6abadcce9ec25ffb1a [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
Darin Petkov3ec55342012-09-28 14:04:44 +02005#ifndef SHILL_POWER_MANAGER_PROXY_INTERFACE_H_
6#define SHILL_POWER_MANAGER_PROXY_INTERFACE_H_
Darin Petkov394b7d42011-11-03 15:48:02 +01007
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
Darin Petkov394b7d42011-11-03 15:48:02 +010020class PowerManagerProxyInterface {
21 public:
22 virtual ~PowerManagerProxyInterface() {}
23
24 // Sends a request to PowerManager to wait for this RPC client for up to
25 // |delay_ms| before suspending the system. When initiating suspend,
26 // PowerManager broadcasts a SuspendDelay signal and suspends the system after
27 // the maximal registered timeout expires or all registered clients are ready
28 // to suspend. Clients tell PowerManager that they are ready through the
Darin Petkov3ec55342012-09-28 14:04:44 +020029 // SuspendReady interface.
Darin Petkov394b7d42011-11-03 15:48:02 +010030 virtual void RegisterSuspendDelay(uint32 delay_ms) = 0;
Darin Petkov3ec55342012-09-28 14:04:44 +020031 virtual void UnregisterSuspendDelay() = 0;
32 virtual void SuspendReady(uint32 sequence_number) = 0;
Darin Petkov394b7d42011-11-03 15:48:02 +010033};
34
35// PowerManager signal delegate to be associated with the proxy.
36class PowerManagerProxyDelegate {
37 public:
mukesh agrawal7c1fece2012-01-13 11:31:27 -080038 // Possible states broadcast from the powerd_suspend script.
39 enum SuspendState {
40 kOn,
41 kStandby,
42 kMem,
43 kDisk,
Darin Petkov3ec55342012-09-28 14:04:44 +020044 kSuspending, // Internal to shill.
mukesh agrawal7c1fece2012-01-13 11:31:27 -080045 // Place new states above kUnknown.
46 kUnknown
47 };
48
Darin Petkov394b7d42011-11-03 15:48:02 +010049 virtual ~PowerManagerProxyDelegate() {}
50
51 // Broadcasted by PowerManager when it initiates suspend. RPC clients that
52 // have registered through RegisterSuspendDelay tell PowerManager that they're
53 // ready to suspend by sending a SuspendReady signal with the same
54 // |sequence_number|.
55 virtual void OnSuspendDelay(uint32 sequence_number) = 0;
mukesh agrawal7c1fece2012-01-13 11:31:27 -080056
57 // This method will be called when suspending or resuming. |new_power_state|
58 // will be "kMem" when suspending (to memory), or "kOn" when resuming.
59 virtual void OnPowerStateChanged(SuspendState new_power_state) = 0;
Darin Petkov394b7d42011-11-03 15:48:02 +010060};
61
62} // namespace shill
63
Darin Petkov3ec55342012-09-28 14:04:44 +020064#endif // SHILL_POWER_MANAGER_PROXY_INTERFACE_H_