Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / session_manager_client.h
blob70ca3f4c7cc2729b50570f1a253cc582a9817442
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
8 #include <map>
9 #include <string>
11 #include "base/callback.h"
12 #include "base/observer_list.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/dbus_client_implementation_type.h"
16 namespace dbus {
17 class Bus;
18 } // namespace
20 namespace chromeos {
22 // SessionManagerClient is used to communicate with the session manager.
23 class CHROMEOS_EXPORT SessionManagerClient {
24 public:
25 // Interface for observing changes from the session manager.
26 class Observer {
27 public:
28 // Called when the owner key is set.
29 virtual void OwnerKeySet(bool success) {}
31 // Called when the property change is complete.
32 virtual void PropertyChangeComplete(bool success) {}
34 // Called when the session manager requests that the lock screen be
35 // displayed. NotifyLockScreenShown() is called after the lock screen
36 // is shown (the canonical "is the screen locked?" state lives in the
37 // session manager).
38 virtual void LockScreen() {}
40 // Called when the session manager requests that the lock screen be
41 // dismissed. NotifyLockScreenDismissed() is called afterward.
42 virtual void UnlockScreen() {}
44 // Called when the session manager announces that the screen has been locked
45 // successfully (i.e. after NotifyLockScreenShown() has been called).
46 virtual void ScreenIsLocked() {}
48 // Called when the session manager announces that the screen has been
49 // unlocked successfully (i.e. after NotifyLockScreenDismissed() has
50 // been called).
51 virtual void ScreenIsUnlocked() {}
54 // Adds and removes the observer.
55 virtual void AddObserver(Observer* observer) = 0;
56 virtual void RemoveObserver(Observer* observer) = 0;
57 virtual bool HasObserver(Observer* observer) = 0;
59 // Kicks off an attempt to emit the "login-prompt-ready" upstart signal.
60 virtual void EmitLoginPromptReady() = 0;
62 // Kicks off an attempt to emit the "login-prompt-visible" upstart signal.
63 virtual void EmitLoginPromptVisible() = 0;
65 // Restarts a job referenced by |pid| with the provided command line.
66 virtual void RestartJob(int pid, const std::string& command_line) = 0;
68 // Restarts entd (the enterprise daemon).
69 // DEPRECATED: will be deleted soon.
70 virtual void RestartEntd() = 0;
72 // Starts the session for the user.
73 virtual void StartSession(const std::string& user_email) = 0;
75 // Stops the current session.
76 virtual void StopSession() = 0;
78 // Starts the factory reset.
79 virtual void StartDeviceWipe() = 0;
81 // Locks the screen.
82 virtual void RequestLockScreen() = 0;
84 // Notifies that the lock screen is shown.
85 virtual void NotifyLockScreenShown() = 0;
87 // Unlocks the screen.
88 virtual void RequestUnlockScreen() = 0;
90 // Notifies that the lock screen is dismissed.
91 virtual void NotifyLockScreenDismissed() = 0;
93 // Map that is used to describe the set of active user sessions where |key|
94 // is user_id and |value| is user_id_hash.
95 typedef std::map<std::string, std::string> ActiveSessionsMap;
97 // The ActiveSessionsCallback is used for the RetrieveActiveSessions()
98 // method. It receives |sessions| argument where the keys are user_ids for
99 // all users that are currently active and |success| argument which indicates
100 // whether or not the request succeded.
101 typedef base::Callback<void(const ActiveSessionsMap& sessions,
102 bool success)> ActiveSessionsCallback;
104 // Enumerates active user sessions. Usually Chrome naturally keeps track of
105 // active users when they are added into current session. When Chrome is
106 // restarted after crash by session_manager it only receives user_id and
107 // user_id_hash for one user. This method is used to retrieve list of all
108 // active users.
109 virtual void RetrieveActiveSessions(
110 const ActiveSessionsCallback& callback) = 0;
112 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and
113 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as
114 // string. Upon success, we will pass a protobuf to the callback. On
115 // failure, we will pass "".
116 typedef base::Callback<void(const std::string&)> RetrievePolicyCallback;
118 // Fetches the device policy blob stored by the session manager. Upon
119 // completion of the retrieve attempt, we will call the provided callback.
120 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0;
122 // Fetches the user policy blob stored by the session manager for the given
123 // |username|. Upon completion of the retrieve attempt, we will call the
124 // provided callback.
125 virtual void RetrievePolicyForUser(
126 const std::string& username,
127 const RetrievePolicyCallback& callback) = 0;
129 // Fetches the policy blob associated with the specified device-local account
130 // from session manager. |callback| is invoked up on completion.
131 virtual void RetrieveDeviceLocalAccountPolicy(
132 const std::string& account_id,
133 const RetrievePolicyCallback& callback) = 0;
135 // Used for StoreDevicePolicy, StorePolicyForUser and
136 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the
137 // operation was successful or not.
138 typedef base::Callback<void(bool)> StorePolicyCallback;
140 // Attempts to asynchronously store |policy_blob| as device policy. Upon
141 // completion of the store attempt, we will call callback.
142 virtual void StoreDevicePolicy(const std::string& policy_blob,
143 const StorePolicyCallback& callback) = 0;
145 // Attempts to asynchronously store |policy_blob| as user policy for the given
146 // |username|. Upon completion of the store attempt, we will call callback.
147 // The |policy_key| argument is not sent to the session manager, but is used
148 // by the stub implementation to enable policy validation on desktop builds.
149 virtual void StorePolicyForUser(const std::string& username,
150 const std::string& policy_blob,
151 const std::string& policy_key,
152 const StorePolicyCallback& callback) = 0;
154 // Sends a request to store a policy blob for the specified device-local
155 // account. The result of the operation is reported through |callback|.
156 virtual void StoreDeviceLocalAccountPolicy(
157 const std::string& account_id,
158 const std::string& policy_blob,
159 const StorePolicyCallback& callback) = 0;
161 // Creates the instance.
162 static SessionManagerClient* Create(DBusClientImplementationType type,
163 dbus::Bus* bus);
165 virtual ~SessionManagerClient();
167 protected:
168 // Create() should be used instead.
169 SessionManagerClient();
171 private:
172 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient);
175 } // namespace chromeos
177 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_