Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / chromeos / dbus / leadership_daemon_manager_client.h
blob2c68460e31ffe35c0f59ce4d0e6790901187b390
1 // Copyright 2015 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.
4 #ifndef CHROMEOS_DBUS_LEADERSHIP_DAEMON_MANAGER_CLIENT_H_
5 #define CHROMEOS_DBUS_LEADERSHIP_DAEMON_MANAGER_CLIENT_H_
7 #include <map>
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h"
16 #include "chromeos/dbus/dbus_method_call_status.h"
17 #include "dbus/object_path.h"
18 #include "dbus/property.h"
20 namespace chromeos {
22 // LeadershipDaemonManagerClient is used to communicate with the
23 // leaderd's Manager service. All methods should be called from
24 // the origin thread which initializes the DBusThreadManager instance.
25 class CHROMEOS_EXPORT LeadershipDaemonManagerClient : public DBusClient {
26 public:
27 // Structure of properties associated with advertised groups.
28 class GroupProperties : public dbus::PropertySet {
29 public:
30 GroupProperties(dbus::ObjectProxy* object_proxy,
31 const std::string& interface_name,
32 const PropertyChangedCallback& callback);
33 ~GroupProperties() override;
35 const std::string& leader_uuid() const { return leader_uuid_.value(); }
36 const std::vector<std::string>& group_members() const {
37 return group_members_.value();
40 private:
41 dbus::Property<std::string> leader_uuid_;
42 dbus::Property<std::vector<std::string>> group_members_;
45 // Interface for observing changes from a leadership daemon.
46 class Observer {
47 public:
48 virtual ~Observer();
50 // Called when the manager has been added.
51 virtual void ManagerAdded();
53 // Called when the manager has been removed.
54 virtual void ManagerRemoved();
56 // Called when the group with object path |object_path| is added to the
57 // system.
58 virtual void GroupAdded(const dbus::ObjectPath& object_path);
60 // Called when the group with object path |object_path| is removed from
61 // the system.
62 virtual void GroupRemoved(const dbus::ObjectPath& object_path);
64 // Called when the adapter with object path |object_path| has a
65 // change in value of the property named |property_name|.
66 virtual void GroupPropertyChanged(const dbus::ObjectPath& object_path,
67 const std::string& property_name);
70 ~LeadershipDaemonManagerClient() override;
72 // Factory function, creates a new instance which is owned by the caller.
73 // For normal usage, access the singleton via DBusThreadManager::Get().
74 static LeadershipDaemonManagerClient* Create();
76 // Adds and removes observers for events on all leadership group
77 // events. Check the |object_path| parameter of observer methods to
78 // determine which group is issuing the event.
79 virtual void AddObserver(Observer* observer) = 0;
80 virtual void RemoveObserver(Observer* observer) = 0;
82 // Calls JoinGroup method.
83 // |callback| is called with its |call_status| argument set to
84 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
85 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
86 virtual void JoinGroup(const std::string& group,
87 const base::DictionaryValue& options,
88 const ObjectPathDBusMethodCallback& callback) = 0;
90 // Calls LeaveGroup method.
91 // |callback| is called with its |call_status| argument set to
92 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
93 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
94 virtual void LeaveGroup(const std::string& object_path,
95 const VoidDBusMethodCallback& callback) = 0;
97 // Calls SetScore method.
98 // |callback| is called with its |call_status| argument set to
99 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
100 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
101 virtual void SetScore(const std::string& object_path,
102 int score,
103 const VoidDBusMethodCallback& callback) = 0;
105 // Calls PokeLeader method.
106 // |callback| is called with its |call_status| argument set to
107 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
108 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
109 virtual void PokeLeader(const std::string& object_path,
110 const VoidDBusMethodCallback& callback) = 0;
112 // Calls Ping method.
113 // |callback| is called with its |call_status| argument set to
114 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
115 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
116 virtual void Ping(const StringDBusMethodCallback& callback) = 0;
118 // Obtains the properties for the group with object path |object_path|,
119 // any values should be copied if needed.
120 virtual const GroupProperties* GetGroupProperties(
121 const dbus::ObjectPath& object_path) = 0;
123 protected:
124 // Create() should be used instead.
125 LeadershipDaemonManagerClient();
127 private:
128 DISALLOW_COPY_AND_ASSIGN(LeadershipDaemonManagerClient);
131 } // namespace chromeos
133 #endif // CHROMEOS_DBUS_LEADERSHIP_DAEMON_MANAGER_CLIENT_H_