Index: chromeos/dbus/peer_daemon_manager_client.h |
diff --git a/chromeos/dbus/peer_daemon_manager_client.h b/chromeos/dbus/peer_daemon_manager_client.h |
index a7cacb37b97437e8ed167b9ea1dad3b2d3c3c012..6d44836b448b7bea187c45f036a35382357ecaaf 100644 |
--- a/chromeos/dbus/peer_daemon_manager_client.h |
+++ b/chromeos/dbus/peer_daemon_manager_client.h |
@@ -7,6 +7,7 @@ |
#include <map> |
#include <string> |
+#include <tuple> |
hashimoto
2015/02/05 09:51:12
<tuple> is not allowed yet. http://chromium-cpp.ap
dtapuska
2015/02/05 19:51:16
Done.
|
#include <vector> |
#include "base/macros.h" |
@@ -14,6 +15,7 @@ |
#include "chromeos/chromeos_export.h" |
#include "chromeos/dbus/dbus_client.h" |
#include "chromeos/dbus/dbus_method_call_status.h" |
+#include "dbus/property.h" |
namespace chromeos { |
@@ -22,12 +24,114 @@ namespace chromeos { |
// initializes the DBusThreadManager instance. |
class CHROMEOS_EXPORT PeerDaemonManagerClient : public DBusClient { |
public: |
+ class ManagerProperties : public dbus::PropertySet { |
+ public: |
+ ManagerProperties(dbus::ObjectProxy* object_proxy, |
+ const PropertyChangedCallback& callback); |
+ ~ManagerProperties() override; |
+ |
+ dbus::Property<std::vector<std::string>> monitored_technologies; |
hashimoto
2015/02/05 09:51:12
Could you make this and other properties private?
dtapuska
2015/02/05 19:51:17
I'd need to add access methods for these propertie
hashimoto
2015/02/06 07:45:11
Generally speaking, we shouldn't expose data membe
dtapuska
2015/02/06 15:56:00
Done.
|
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ManagerProperties); |
+ }; |
+ |
+ class ServiceProperties : public dbus::PropertySet { |
+ public: |
+ ServiceProperties(dbus::ObjectProxy* object_proxy, |
+ const PropertyChangedCallback& callback); |
+ ~ServiceProperties() override; |
+ |
+ dbus::Property<std::string> service_id; |
+ dbus::Property<std::map<std::string, std::string>> service_info; |
+ dbus::Property<std::vector<std::tuple<std::vector<uint8_t>, uint16_t>>> |
+ ip_infos; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ServiceProperties); |
+ }; |
+ |
+ class PeerProperties : public dbus::PropertySet { |
+ public: |
+ PeerProperties(dbus::ObjectProxy* object_proxy, |
+ const PropertyChangedCallback& callback); |
+ ~PeerProperties() override; |
+ |
+ dbus::Property<std::string> u_u_i_d; |
hashimoto
2015/02/05 09:51:12
nit: Seems |uuid| is more common.
dtapuska
2015/02/05 19:51:16
Done.
|
+ dbus::Property<uint64_t> last_seen; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(PeerProperties); |
+ }; |
+ |
+ // Interface for observing changes from a leadership daemon. |
+ class Observer { |
+ public: |
+ virtual ~Observer() {} |
+ |
+ // Called when the peer daemon manager is added. |
+ virtual void ManagerAdded() {} |
+ |
+ // Called when the peer daemon manager is removed; perhaps on a process |
+ // crash of the peer daemon. |
+ virtual void ManagerRemoved() {} |
+ |
+ // Called when the manager changes a property value. |
+ virtual void ManagerPropertyChanged(const std::string& property_name) {} |
+ |
+ // Called when the service with object path |object_path| is added to the |
+ // system. |
+ virtual void ServiceAdded(const dbus::ObjectPath& object_path) {} |
+ |
+ // Called when the service with object path |object_path| is removed from |
+ // the system. |
+ virtual void ServiceRemoved(const dbus::ObjectPath& object_path) {} |
+ |
+ // Called when the service with object path |object_path| changes a |
+ // property value. |
+ virtual void ServicePropertyChanged(const dbus::ObjectPath& object_path, |
+ const std::string& property_name) {} |
+ |
+ // Called when the peer with object path |object_path| is added to the |
+ // system. |
+ virtual void PeerAdded(const dbus::ObjectPath& object_path) {} |
+ |
+ // Called when the peer with object path |object_path| is removed from |
+ // the system. |
+ virtual void PeerRemoved(const dbus::ObjectPath& object_path) {} |
+ |
+ // Called when the peer with object path |object_path| changes a |
+ // property value. |
+ virtual void PeerPropertyChanged(const dbus::ObjectPath& object_path, |
+ const std::string& property_name) {} |
+ }; |
+ |
~PeerDaemonManagerClient() override; |
// Factory function, creates a new instance which is owned by the caller. |
// For normal usage, access the singleton via DBusThreadManager::Get(). |
static PeerDaemonManagerClient* Create(); |
+ // Adds and removes observers for events on all peer events. |
+ virtual void AddObserver(Observer* observer) = 0; |
+ virtual void RemoveObserver(Observer* observer) = 0; |
+ |
+ // Retries a list of all the peers. |
hashimoto
2015/02/05 09:51:12
nit: Retrieves?
dtapuska
2015/02/05 19:51:16
Done.
|
+ virtual std::vector<dbus::ObjectPath> GetPeers() = 0; |
+ |
+ // Retries a list of all the services. |
hashimoto
2015/02/05 09:51:12
ditto.
dtapuska
2015/02/05 19:51:17
Done.
|
+ virtual std::vector<dbus::ObjectPath> GetServices() = 0; |
+ |
+ // Obtain the properties for the peer with object path |object_path|, |
hashimoto
2015/02/05 09:51:12
nit: Obtains
dtapuska
2015/02/05 19:51:17
Done.
|
+ // any values should be copied if needed. |
+ virtual PeerProperties* GetPeerProperties( |
+ const dbus::ObjectPath& object_path) = 0; |
+ |
+ // Obtain the properties for the service with object path |object_path|, |
hashimoto
2015/02/05 09:51:12
ditto.
dtapuska
2015/02/05 19:51:16
Done.
|
+ // any values should be copied if needed. |
+ virtual ServiceProperties* GetServiceProperties( |
hashimoto
2015/02/05 09:51:12
nit: Properties and Observer methods are ordered l
dtapuska
2015/02/05 19:51:17
Done.
|
+ const dbus::ObjectPath& object_path) = 0; |
+ |
// Calls StartMonitoring method. |
// |callback| is called with its |call_status| argument set to |
// DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, |