Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chromeos/dbus/leadership_daemon_manager_client.h

Issue 887083002: Add DBus Bindings for leaderd (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_
6
7 #include <map>
8 #include <string>
9 #include <vector>
10
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"
19
20 namespace chromeos {
21
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;
34
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();
38 }
39
40 private:
41 dbus::Property<std::string> leader_uuid_;
42 dbus::Property<std::vector<std::string>> group_members_;
43 };
44
45 // Interface for observing changes from a leadership daemon.
46 class Observer {
47 public:
48 virtual ~Observer();
49
50 // Called when the manager has been added.
51 virtual void ManagerAdded();
52
53 // Called when the manager has been removed.
54 virtual void ManagerRemoved();
55
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);
59
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);
63
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);
68 };
69
70 ~LeadershipDaemonManagerClient() override;
71
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();
75
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;
81
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 StringDBusMethodCallback& callback) = 0;
89
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;
96
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;
104
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;
111
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;
117
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;
122
123 protected:
124 // Create() should be used instead.
125 LeadershipDaemonManagerClient();
126
127 private:
128 DISALLOW_COPY_AND_ASSIGN(LeadershipDaemonManagerClient);
129 };
130
131 } // namespace chromeos
132
133 #endif // CHROMEOS_DBUS_LEADERSHIP_DAEMON_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698