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

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

Issue 893663002: Enhance the DBus interface for peerd (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix minor 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_DBUS_PEER_DAEMON_MANAGER_CLIENT_H_ 5 #ifndef CHROMEOS_DBUS_PEER_DAEMON_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_PEER_DAEMON_MANAGER_CLIENT_H_ 6 #define CHROMEOS_DBUS_PEER_DAEMON_MANAGER_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h" 16 #include "chromeos/dbus/dbus_client.h"
16 #include "chromeos/dbus/dbus_method_call_status.h" 17 #include "chromeos/dbus/dbus_method_call_status.h"
18 #include "dbus/property.h"
17 19
18 namespace chromeos { 20 namespace chromeos {
19 21
20 // PeerDaemonManagerClient is used to communicate with the PeerDaemon Manager 22 // PeerDaemonManagerClient is used to communicate with the PeerDaemon Manager
21 // service. All methods should be called from the origin thread which 23 // service. All methods should be called from the origin thread which
22 // initializes the DBusThreadManager instance. 24 // initializes the DBusThreadManager instance.
23 class CHROMEOS_EXPORT PeerDaemonManagerClient : public DBusClient { 25 class CHROMEOS_EXPORT PeerDaemonManagerClient : public DBusClient {
24 public: 26 public:
27 class ManagerProperties : public dbus::PropertySet {
28 public:
29 ManagerProperties(dbus::ObjectProxy* object_proxy,
30 const PropertyChangedCallback& callback);
31 ~ManagerProperties() override;
32
33 const std::vector<std::string>& monitored_technologies() const {
34 return monitored_technologies_.value();
35 }
36
37 private:
38 dbus::Property<std::vector<std::string>> monitored_technologies_;
39
40 DISALLOW_COPY_AND_ASSIGN(ManagerProperties);
41 };
42
43 class ServiceProperties : public dbus::PropertySet {
44 public:
45 ServiceProperties(dbus::ObjectProxy* object_proxy,
46 const PropertyChangedCallback& callback);
47 ~ServiceProperties() override;
48
49 const std::string& service_id() const { return service_id_.value(); }
50 const std::map<std::string, std::string>& service_info() const {
51 return service_info_.value();
52 }
53 const std::vector<std::pair<std::vector<uint8_t>, uint16_t>>& ip_infos()
54 const {
55 return ip_infos_.value();
56 }
57
58 private:
59 dbus::Property<std::string> service_id_;
60 dbus::Property<std::map<std::string, std::string>> service_info_;
61 dbus::Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>
62 ip_infos_;
63
64 DISALLOW_COPY_AND_ASSIGN(ServiceProperties);
65 };
66
67 class PeerProperties : public dbus::PropertySet {
68 public:
69 PeerProperties(dbus::ObjectProxy* object_proxy,
70 const PropertyChangedCallback& callback);
71 ~PeerProperties() override;
72
73 const std::string& uuid() const { return uuid_.value(); }
74 uint64_t last_seen() const { return last_seen_.value(); }
75
76 private:
77 dbus::Property<std::string> uuid_;
78 dbus::Property<uint64_t> last_seen_;
79
80 DISALLOW_COPY_AND_ASSIGN(PeerProperties);
81 };
82
83 // Interface for observing changes from a leadership daemon.
84 class Observer {
85 public:
86 virtual ~Observer() {}
87
88 // Called when the peer daemon manager is added.
89 virtual void ManagerAdded() {}
90
91 // Called when the peer daemon manager is removed; perhaps on a process
92 // crash of the peer daemon.
93 virtual void ManagerRemoved() {}
94
95 // Called when the manager changes a property value.
96 virtual void ManagerPropertyChanged(const std::string& property_name) {}
97
98 // Called when the service with object path |object_path| is added to the
99 // system.
100 virtual void ServiceAdded(const dbus::ObjectPath& object_path) {}
101
102 // Called when the service with object path |object_path| is removed from
103 // the system.
104 virtual void ServiceRemoved(const dbus::ObjectPath& object_path) {}
105
106 // Called when the service with object path |object_path| changes a
107 // property value.
108 virtual void ServicePropertyChanged(const dbus::ObjectPath& object_path,
109 const std::string& property_name) {}
110
111 // Called when the peer with object path |object_path| is added to the
112 // system.
113 virtual void PeerAdded(const dbus::ObjectPath& object_path) {}
114
115 // Called when the peer with object path |object_path| is removed from
116 // the system.
117 virtual void PeerRemoved(const dbus::ObjectPath& object_path) {}
118
119 // Called when the peer with object path |object_path| changes a
120 // property value.
121 virtual void PeerPropertyChanged(const dbus::ObjectPath& object_path,
122 const std::string& property_name) {}
123 };
124
25 ~PeerDaemonManagerClient() override; 125 ~PeerDaemonManagerClient() override;
26 126
27 // Factory function, creates a new instance which is owned by the caller. 127 // Factory function, creates a new instance which is owned by the caller.
28 // For normal usage, access the singleton via DBusThreadManager::Get(). 128 // For normal usage, access the singleton via DBusThreadManager::Get().
29 static PeerDaemonManagerClient* Create(); 129 static PeerDaemonManagerClient* Create();
30 130
131 // Adds and removes observers for events on all peer events.
132 virtual void AddObserver(Observer* observer) = 0;
133 virtual void RemoveObserver(Observer* observer) = 0;
134
135 // Retrieves a list of all the services.
136 virtual std::vector<dbus::ObjectPath> GetServices() = 0;
137
138 // Retrieves a list of all the peers.
139 virtual std::vector<dbus::ObjectPath> GetPeers() = 0;
140
141 // Obtains the properties for the service with object path |object_path|,
142 // any values should be copied if needed.
143 virtual ServiceProperties* GetServiceProperties(
144 const dbus::ObjectPath& object_path) = 0;
145
146 // Obtains the properties for the peer with object path |object_path|,
147 // any values should be copied if needed.
148 virtual PeerProperties* GetPeerProperties(
149 const dbus::ObjectPath& object_path) = 0;
150
31 // Calls StartMonitoring method. 151 // Calls StartMonitoring method.
32 // |callback| is called with its |call_status| argument set to 152 // |callback| is called with its |call_status| argument set to
33 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, 153 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
34 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. 154 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
35 virtual void StartMonitoring( 155 virtual void StartMonitoring(
36 const std::vector<std::string>& requested_technologies, 156 const std::vector<std::string>& requested_technologies,
37 const base::DictionaryValue& options, 157 const base::DictionaryValue& options,
38 const StringDBusMethodCallback& callback) = 0; 158 const StringDBusMethodCallback& callback) = 0;
39 159
40 // Calls StopMonitoring method. 160 // Calls StopMonitoring method.
(...skipping 30 matching lines...) Expand all
71 // Create() should be used instead. 191 // Create() should be used instead.
72 PeerDaemonManagerClient(); 192 PeerDaemonManagerClient();
73 193
74 private: 194 private:
75 DISALLOW_COPY_AND_ASSIGN(PeerDaemonManagerClient); 195 DISALLOW_COPY_AND_ASSIGN(PeerDaemonManagerClient);
76 }; 196 };
77 197
78 } // namespace chromeos 198 } // namespace chromeos
79 199
80 #endif // CHROMEOS_DBUS_PEER_DAEMON_MANAGER_CLIENT_H_ 200 #endif // CHROMEOS_DBUS_PEER_DAEMON_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_peer_daemon_manager_client.cc ('k') | chromeos/dbus/peer_daemon_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698