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

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 lint error 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 struct GroupProperties : public dbus::PropertySet {
29 GroupProperties(dbus::ObjectProxy* object_proxy,
30 const std::string& interface_name,
31 const PropertyChangedCallback& callback);
32 ~GroupProperties() override;
33
34 const std::string& leader_uuid() const { return leader_uuid_.value(); }
35 const std::vector<std::string>& group_members() const {
36 return group_members_.value();
37 }
stevenjb 2015/02/12 23:03:22 Either make this a class or use members without th
dtapuska 2015/02/13 15:23:49 Done.
38
39 private:
40 dbus::Property<std::string> leader_uuid_;
41 dbus::Property<std::vector<std::string>> group_members_;
42 };
43
44 // Interface for observing changes from a leadership daemon.
45 class Observer {
46 public:
47 virtual ~Observer() {}
48
49 // Called when the manager has been added.
50 virtual void ManagerAdded() {}
stevenjb 2015/02/12 23:03:22 Classes with concrete (even empty) implementations
dtapuska 2015/02/13 15:23:49 Done.
51
52 // Called when the manager has been removed.
53 virtual void ManagerRemoved() {}
54
55 // Called when the group with object path |object_path| is added to the
56 // system.
57 virtual void GroupAdded(const dbus::ObjectPath& object_path) {}
58
59 // Called when the group with object path |object_path| is removed from
60 // the system.
61 virtual void GroupRemoved(const dbus::ObjectPath& object_path) {}
62
63 // Called when the adapter with object path |object_path| has a
64 // change in value of the property named |property_name|.
65 virtual void GroupPropertyChanged(const dbus::ObjectPath& object_path,
66 const std::string& property_name) {}
67 };
68
69 ~LeadershipDaemonManagerClient() override;
70
71 // Factory function, creates a new instance which is owned by the caller.
72 // For normal usage, access the singleton via DBusThreadManager::Get().
73 static LeadershipDaemonManagerClient* Create();
74
75 // Adds and removes observers for events on all leadership group
76 // events. Check the |object_path| parameter of observer methods to
77 // determine which group is issuing the event.
78 virtual void AddObserver(Observer* observer) = 0;
79 virtual void RemoveObserver(Observer* observer) = 0;
80
81 // Calls JoinGroup method.
82 // |callback| is called with its |call_status| argument set to
83 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
84 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
85 virtual void JoinGroup(const std::string& group,
86 const base::DictionaryValue& options,
87 const StringDBusMethodCallback& callback) = 0;
88
89 // Calls LeaveGroup method.
90 // |callback| is called with its |call_status| argument set to
91 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
92 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
93 virtual void LeaveGroup(const std::string& object_path,
94 const VoidDBusMethodCallback& callback) = 0;
95
96 // Calls SetScore method.
97 // |callback| is called with its |call_status| argument set to
98 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
99 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
100 virtual void SetScore(const std::string& object_path,
101 int score,
102 const VoidDBusMethodCallback& callback) = 0;
103
104 // Calls PokeLeader method.
105 // |callback| is called with its |call_status| argument set to
106 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
107 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
108 virtual void PokeLeader(const std::string& object_path,
109 const VoidDBusMethodCallback& callback) = 0;
110
111 // Calls Ping method.
112 // |callback| is called with its |call_status| argument set to
113 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
114 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
115 virtual void Ping(const StringDBusMethodCallback& callback) = 0;
116
117 // Obtains the properties for the group with object path |object_path|,
118 // any values should be copied if needed.
119 virtual const GroupProperties* GetGroupProperties(
120 const dbus::ObjectPath& object_path) = 0;
121
122 protected:
123 // Create() should be used instead.
124 LeadershipDaemonManagerClient();
125
126 private:
127 DISALLOW_COPY_AND_ASSIGN(LeadershipDaemonManagerClient);
128 };
129
130 } // namespace chromeos
131
132 #endif // CHROMEOS_DBUS_LEADERSHIP_DAEMON_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698