diff options
author | dtapuska <dtapuska@chromium.org> | 2015-02-09 08:02:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-09 16:04:03 +0000 |
commit | 32d25453c4d04474d75a6db01cd1e006537bd3bf (patch) | |
tree | d8aaa2e5be36c1e568be6601d9faa308a9332a8d /chromeos/dbus | |
parent | b2e3ececdfdc5ce1037d1bb648a7ff0f1d38f508 (diff) | |
download | chromium_src-32d25453c4d04474d75a6db01cd1e006537bd3bf.zip chromium_src-32d25453c4d04474d75a6db01cd1e006537bd3bf.tar.gz chromium_src-32d25453c4d04474d75a6db01cd1e006537bd3bf.tar.bz2 |
Enhance the DBus interface for peerd
Add ability to query properties of
- Manager
- Peer
- Service
Add Observer to peerd so we are told when things change.
BUG=453873
Review URL: https://codereview.chromium.org/893663002
Cr-Commit-Position: refs/heads/master@{#315311}
Diffstat (limited to 'chromeos/dbus')
-rw-r--r-- | chromeos/dbus/fake_peer_daemon_manager_client.cc | 26 | ||||
-rw-r--r-- | chromeos/dbus/fake_peer_daemon_manager_client.h | 8 | ||||
-rw-r--r-- | chromeos/dbus/peer_daemon_manager_client.cc | 283 | ||||
-rw-r--r-- | chromeos/dbus/peer_daemon_manager_client.h | 120 |
4 files changed, 404 insertions, 33 deletions
diff --git a/chromeos/dbus/fake_peer_daemon_manager_client.cc b/chromeos/dbus/fake_peer_daemon_manager_client.cc index 4eb1606..7424ebc 100644 --- a/chromeos/dbus/fake_peer_daemon_manager_client.cc +++ b/chromeos/dbus/fake_peer_daemon_manager_client.cc @@ -15,6 +15,32 @@ FakePeerDaemonManagerClient::~FakePeerDaemonManagerClient() { void FakePeerDaemonManagerClient::Init(dbus::Bus* bus) { } +void FakePeerDaemonManagerClient::AddObserver(Observer* observer) { +} + +void FakePeerDaemonManagerClient::RemoveObserver(Observer* observer) { +} + +std::vector<dbus::ObjectPath> FakePeerDaemonManagerClient::GetPeers() { + return std::vector<dbus::ObjectPath>(); +} + +std::vector<dbus::ObjectPath> FakePeerDaemonManagerClient::GetServices() { + return std::vector<dbus::ObjectPath>(); +} + +PeerDaemonManagerClient::PeerProperties* +FakePeerDaemonManagerClient::GetPeerProperties( + const dbus::ObjectPath& object_path) { + return nullptr; +} + +PeerDaemonManagerClient::ServiceProperties* +FakePeerDaemonManagerClient::GetServiceProperties( + const dbus::ObjectPath& object_path) { + return nullptr; +} + void FakePeerDaemonManagerClient::StartMonitoring( const std::vector<std::string>& requested_technologies, const base::DictionaryValue& options, diff --git a/chromeos/dbus/fake_peer_daemon_manager_client.h b/chromeos/dbus/fake_peer_daemon_manager_client.h index a4b16fa..c2c2717 100644 --- a/chromeos/dbus/fake_peer_daemon_manager_client.h +++ b/chromeos/dbus/fake_peer_daemon_manager_client.h @@ -24,6 +24,14 @@ class FakePeerDaemonManagerClient : public PeerDaemonManagerClient { void Init(dbus::Bus* bus) override; // PeerDaemonManagerClient overrides: + void AddObserver(Observer* observer) override; + void RemoveObserver(Observer* observer) override; + std::vector<dbus::ObjectPath> GetPeers() override; + std::vector<dbus::ObjectPath> GetServices() override; + PeerProperties* GetPeerProperties( + const dbus::ObjectPath& object_path) override; + ServiceProperties* GetServiceProperties( + const dbus::ObjectPath& object_path) override; void StartMonitoring(const std::vector<std::string>& requested_technologies, const base::DictionaryValue& options, const StringDBusMethodCallback& callback) override; diff --git a/chromeos/dbus/peer_daemon_manager_client.cc b/chromeos/dbus/peer_daemon_manager_client.cc index b2ba214..9fdea05 100644 --- a/chromeos/dbus/peer_daemon_manager_client.cc +++ b/chromeos/dbus/peer_daemon_manager_client.cc @@ -8,8 +8,11 @@ #include "base/callback.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" +#include "base/message_loop/message_loop.h" +#include "base/observer_list.h" #include "dbus/bus.h" #include "dbus/message.h" +#include "dbus/object_manager.h" #include "dbus/object_proxy.h" #include "dbus/values_util.h" @@ -19,8 +22,11 @@ namespace { // TODO(benchan): Move these constants to system_api. namespace peerd { const char kPeerdServiceName[] = "org.chromium.peerd"; +const char kPeerdObjectManagerServicePath[] = "/org/chromium/peerd"; const char kPeerdManagerPath[] = "/org/chromium/peerd/Manager"; const char kManagerInterface[] = "org.chromium.peerd.Manager"; +const char kServiceInterface[] = "org.chromium.peerd.Service"; +const char kPeerInterface[] = "org.chromium.peerd.Peer"; const char kStartMonitoringMethod[] = "StartMonitoring"; const char kStopMonitoringMethod[] = "StopMonitoring"; const char kExposeServiceMethod[] = "ExposeService"; @@ -29,15 +35,24 @@ const char kPingMethod[] = "Ping"; } // namespace peerd // The PeerDaemonManagerClient implementation used in production. -class PeerDaemonManagerClientImpl : public PeerDaemonManagerClient { +class PeerDaemonManagerClientImpl : public PeerDaemonManagerClient, + public dbus::ObjectManager::Interface { public: PeerDaemonManagerClientImpl(); ~PeerDaemonManagerClientImpl() override; - // DBusClient overrides: + // DBusClient overrides. void Init(dbus::Bus* bus) override; - // PeerDaemonManagerClient overrides: + // PeerDaemonManagerClient overrides. + void AddObserver(Observer* observer) override; + void RemoveObserver(Observer* observer) override; + std::vector<dbus::ObjectPath> GetServices() override; + std::vector<dbus::ObjectPath> GetPeers() override; + ServiceProperties* GetServiceProperties( + const dbus::ObjectPath& object_path) override; + PeerProperties* GetPeerProperties( + const dbus::ObjectPath& object_path) override; void StartMonitoring( const std::vector<std::string>& requested_technologies, const base::DictionaryValue& options, @@ -53,55 +68,126 @@ class PeerDaemonManagerClientImpl : public PeerDaemonManagerClient { const VoidDBusMethodCallback& callback) override; void Ping(const StringDBusMethodCallback& callback) override; + // dbus::ObjectManager::Interface overrides. + dbus::PropertySet* CreateProperties( + dbus::ObjectProxy* object_proxy, + const dbus::ObjectPath& object_path, + const std::string& interface_name) override; + void ObjectAdded(const dbus::ObjectPath& object_path, + const std::string& interface_name) override; + void ObjectRemoved(const dbus::ObjectPath& object_path, + const std::string& interface_name) override; + private: void OnStringDBusMethod(const StringDBusMethodCallback& callback, dbus::Response* response); void OnVoidDBusMethod(const VoidDBusMethodCallback& callback, dbus::Response* response); + void OnManagerPropertyChanged(const std::string& property_name); + void OnServicePropertyChanged(const dbus::ObjectPath& object_path, + const std::string& property_name); + void OnPeerPropertyChanged(const dbus::ObjectPath& object_path, + const std::string& property_name); + + // List of observers interested in event notifications from us. + ObserverList<Observer> observers_; + dbus::ObjectManager* object_manager_; - dbus::ObjectProxy* peer_daemon_proxy_; base::WeakPtrFactory<PeerDaemonManagerClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(PeerDaemonManagerClientImpl); }; PeerDaemonManagerClientImpl::PeerDaemonManagerClientImpl() - : peer_daemon_proxy_(nullptr), weak_ptr_factory_(this) { + : object_manager_(nullptr), weak_ptr_factory_(this) { } PeerDaemonManagerClientImpl::~PeerDaemonManagerClientImpl() { + if (object_manager_) { + object_manager_->UnregisterInterface(peerd::kManagerInterface); + object_manager_->UnregisterInterface(peerd::kServiceInterface); + object_manager_->UnregisterInterface(peerd::kPeerInterface); + } +} + +void PeerDaemonManagerClientImpl::AddObserver(Observer* observer) { + DCHECK(observer); + observers_.AddObserver(observer); +} + +void PeerDaemonManagerClientImpl::RemoveObserver(Observer* observer) { + DCHECK(observer); + observers_.RemoveObserver(observer); +} + +std::vector<dbus::ObjectPath> PeerDaemonManagerClientImpl::GetServices() { + return object_manager_->GetObjectsWithInterface(peerd::kServiceInterface); +} + +std::vector<dbus::ObjectPath> PeerDaemonManagerClientImpl::GetPeers() { + return object_manager_->GetObjectsWithInterface(peerd::kPeerInterface); +} + +PeerDaemonManagerClient::ServiceProperties* +PeerDaemonManagerClientImpl::GetServiceProperties( + const dbus::ObjectPath& object_path) { + return static_cast<ServiceProperties*>( + object_manager_->GetProperties(object_path, peerd::kServiceInterface)); +} + +PeerDaemonManagerClient::PeerProperties* +PeerDaemonManagerClientImpl::GetPeerProperties( + const dbus::ObjectPath& object_path) { + return static_cast<PeerProperties*>( + object_manager_->GetProperties(object_path, peerd::kPeerInterface)); } void PeerDaemonManagerClientImpl::StartMonitoring( const std::vector<std::string>& requested_technologies, const base::DictionaryValue& options, const StringDBusMethodCallback& callback) { + dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( + dbus::ObjectPath(peerd::kPeerdManagerPath)); + if (!object_proxy) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&PeerDaemonManagerClientImpl::OnStringDBusMethod, + weak_ptr_factory_.GetWeakPtr(), callback, nullptr)); + return; + } + dbus::MethodCall method_call(peerd::kManagerInterface, peerd::kStartMonitoringMethod); dbus::MessageWriter writer(&method_call); writer.AppendArrayOfStrings(requested_technologies); dbus::AppendValueData(&writer, options); - peer_daemon_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + object_proxy->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&PeerDaemonManagerClientImpl::OnStringDBusMethod, - weak_ptr_factory_.GetWeakPtr(), - callback)); + weak_ptr_factory_.GetWeakPtr(), callback)); } void PeerDaemonManagerClientImpl::StopMonitoring( const std::string& monitoring_token, const VoidDBusMethodCallback& callback) { + dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( + dbus::ObjectPath(peerd::kPeerdManagerPath)); + if (!object_proxy) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&PeerDaemonManagerClientImpl::OnVoidDBusMethod, + weak_ptr_factory_.GetWeakPtr(), callback, nullptr)); + return; + } + dbus::MethodCall method_call(peerd::kManagerInterface, peerd::kStopMonitoringMethod); dbus::MessageWriter writer(&method_call); writer.AppendString(monitoring_token); - peer_daemon_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + object_proxy->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&PeerDaemonManagerClientImpl::OnVoidDBusMethod, - weak_ptr_factory_.GetWeakPtr(), - callback)); + weak_ptr_factory_.GetWeakPtr(), callback)); } void PeerDaemonManagerClientImpl::ExposeService( @@ -109,6 +195,16 @@ void PeerDaemonManagerClientImpl::ExposeService( const std::map<std::string, std::string>& service_info, const base::DictionaryValue& options, const StringDBusMethodCallback& callback) { + dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( + dbus::ObjectPath(peerd::kPeerdManagerPath)); + if (!object_proxy) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&PeerDaemonManagerClientImpl::OnStringDBusMethod, + weak_ptr_factory_.GetWeakPtr(), callback, nullptr)); + return; + } + dbus::MethodCall method_call(peerd::kManagerInterface, peerd::kExposeServiceMethod); dbus::MessageWriter writer(&method_call); @@ -126,12 +222,10 @@ void PeerDaemonManagerClientImpl::ExposeService( writer.CloseContainer(&array_writer); dbus::AppendValueData(&writer, options); - peer_daemon_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + object_proxy->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&PeerDaemonManagerClientImpl::OnStringDBusMethod, - weak_ptr_factory_.GetWeakPtr(), - callback)); + weak_ptr_factory_.GetWeakPtr(), callback)); } void PeerDaemonManagerClientImpl::RemoveExposedService( @@ -139,27 +233,95 @@ void PeerDaemonManagerClientImpl::RemoveExposedService( const VoidDBusMethodCallback& callback) { dbus::MethodCall method_call(peerd::kManagerInterface, peerd::kRemoveExposedServiceMethod); + dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( + dbus::ObjectPath(peerd::kPeerdManagerPath)); + if (!object_proxy) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&PeerDaemonManagerClientImpl::OnVoidDBusMethod, + weak_ptr_factory_.GetWeakPtr(), callback, nullptr)); + return; + } dbus::MessageWriter writer(&method_call); writer.AppendString(service_token); - peer_daemon_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + object_proxy->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&PeerDaemonManagerClientImpl::OnVoidDBusMethod, - weak_ptr_factory_.GetWeakPtr(), - callback)); + weak_ptr_factory_.GetWeakPtr(), callback)); } void PeerDaemonManagerClientImpl::Ping( const StringDBusMethodCallback& callback) { dbus::MethodCall method_call(peerd::kManagerInterface, peerd::kPingMethod); + dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( + dbus::ObjectPath(peerd::kPeerdManagerPath)); + if (!object_proxy) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&PeerDaemonManagerClientImpl::OnStringDBusMethod, + weak_ptr_factory_.GetWeakPtr(), callback, nullptr)); + return; + } dbus::MessageWriter writer(&method_call); - peer_daemon_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + object_proxy->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&PeerDaemonManagerClientImpl::OnStringDBusMethod, - weak_ptr_factory_.GetWeakPtr(), - callback)); + weak_ptr_factory_.GetWeakPtr(), callback)); +} + +dbus::PropertySet* PeerDaemonManagerClientImpl::CreateProperties( + dbus::ObjectProxy* object_proxy, + const dbus::ObjectPath& object_path, + const std::string& interface_name) { + dbus::PropertySet* properties = nullptr; + if (interface_name == peerd::kManagerInterface) { + properties = new ManagerProperties( + object_proxy, + base::Bind(&PeerDaemonManagerClientImpl::OnManagerPropertyChanged, + weak_ptr_factory_.GetWeakPtr())); + } else if (interface_name == peerd::kServiceInterface) { + properties = new ServiceProperties( + object_proxy, + base::Bind(&PeerDaemonManagerClientImpl::OnServicePropertyChanged, + weak_ptr_factory_.GetWeakPtr(), object_path)); + } else if (interface_name == peerd::kPeerInterface) { + properties = new PeerProperties( + object_proxy, + base::Bind(&PeerDaemonManagerClientImpl::OnPeerPropertyChanged, + weak_ptr_factory_.GetWeakPtr(), object_path)); + } else { + NOTREACHED() << "Unhandled interface name " << interface_name; + } + return properties; +} + +void PeerDaemonManagerClientImpl::ObjectAdded( + const dbus::ObjectPath& object_path, + const std::string& interface_name) { + if (interface_name == peerd::kManagerInterface) { + FOR_EACH_OBSERVER(Observer, observers_, ManagerAdded()); + } else if (interface_name == peerd::kServiceInterface) { + FOR_EACH_OBSERVER(Observer, observers_, ServiceAdded(object_path)); + } else if (interface_name == peerd::kPeerInterface) { + FOR_EACH_OBSERVER(Observer, observers_, PeerAdded(object_path)); + } else { + NOTREACHED() << "Unhandled interface name " << interface_name; + } +} + +void PeerDaemonManagerClientImpl::ObjectRemoved( + const dbus::ObjectPath& object_path, + const std::string& interface_name) { + if (interface_name == peerd::kManagerInterface) { + FOR_EACH_OBSERVER(Observer, observers_, ManagerRemoved()); + } else if (interface_name == peerd::kServiceInterface) { + FOR_EACH_OBSERVER(Observer, observers_, ServiceRemoved(object_path)); + } else if (interface_name == peerd::kPeerInterface) { + FOR_EACH_OBSERVER(Observer, observers_, PeerRemoved(object_path)); + } else { + NOTREACHED() << "Unhandled interface name " << interface_name; + } } void PeerDaemonManagerClientImpl::OnStringDBusMethod( @@ -187,13 +349,68 @@ void PeerDaemonManagerClientImpl::OnVoidDBusMethod( } void PeerDaemonManagerClientImpl::Init(dbus::Bus* bus) { - peer_daemon_proxy_ = - bus->GetObjectProxy(peerd::kPeerdServiceName, - dbus::ObjectPath(peerd::kPeerdManagerPath)); + object_manager_ = bus->GetObjectManager( + peerd::kPeerdServiceName, + dbus::ObjectPath(peerd::kPeerdObjectManagerServicePath)); + object_manager_->RegisterInterface(peerd::kManagerInterface, this); + object_manager_->RegisterInterface(peerd::kServiceInterface, this); + object_manager_->RegisterInterface(peerd::kPeerInterface, this); +} + +void PeerDaemonManagerClientImpl::OnManagerPropertyChanged( + const std::string& property_name) { + FOR_EACH_OBSERVER(Observer, observers_, + ManagerPropertyChanged(property_name)); +} + +void PeerDaemonManagerClientImpl::OnServicePropertyChanged( + const dbus::ObjectPath& object_path, + const std::string& property_name) { + FOR_EACH_OBSERVER(Observer, observers_, + ServicePropertyChanged(object_path, property_name)); +} + +void PeerDaemonManagerClientImpl::OnPeerPropertyChanged( + const dbus::ObjectPath& object_path, + const std::string& property_name) { + FOR_EACH_OBSERVER(Observer, observers_, + PeerPropertyChanged(object_path, property_name)); } } // namespace +PeerDaemonManagerClient::ManagerProperties::ManagerProperties( + dbus::ObjectProxy* object_proxy, + const PropertyChangedCallback& callback) + : dbus::PropertySet{object_proxy, peerd::kManagerInterface, callback} { + RegisterProperty("MonitoredTechnologies", &monitored_technologies_); +} + +PeerDaemonManagerClient::ManagerProperties::~ManagerProperties() { +} + +PeerDaemonManagerClient::ServiceProperties::ServiceProperties( + dbus::ObjectProxy* object_proxy, + const PropertyChangedCallback& callback) + : dbus::PropertySet{object_proxy, peerd::kServiceInterface, callback} { + RegisterProperty("ServiceId", &service_id_); + RegisterProperty("ServiceInfo", &service_info_); + RegisterProperty("IpInfos", &ip_infos_); +} + +PeerDaemonManagerClient::ServiceProperties::~ServiceProperties() { +} + +PeerDaemonManagerClient::PeerProperties::PeerProperties( + dbus::ObjectProxy* object_proxy, + const PropertyChangedCallback& callback) + : dbus::PropertySet{object_proxy, peerd::kPeerInterface, callback} { + RegisterProperty("UUID", &uuid_); + RegisterProperty("LastSeen", &last_seen_); +} + +PeerDaemonManagerClient::PeerProperties::~PeerProperties() { +} PeerDaemonManagerClient::PeerDaemonManagerClient() { } diff --git a/chromeos/dbus/peer_daemon_manager_client.h b/chromeos/dbus/peer_daemon_manager_client.h index a7cacb3..a3cad81 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 <utility> #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,130 @@ 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; + + const std::vector<std::string>& monitored_technologies() const { + return monitored_technologies_.value(); + } + + private: + dbus::Property<std::vector<std::string>> monitored_technologies_; + + DISALLOW_COPY_AND_ASSIGN(ManagerProperties); + }; + + class ServiceProperties : public dbus::PropertySet { + public: + ServiceProperties(dbus::ObjectProxy* object_proxy, + const PropertyChangedCallback& callback); + ~ServiceProperties() override; + + const std::string& service_id() const { return service_id_.value(); } + const std::map<std::string, std::string>& service_info() const { + return service_info_.value(); + } + const std::vector<std::pair<std::vector<uint8_t>, uint16_t>>& ip_infos() + const { + return ip_infos_.value(); + } + + private: + dbus::Property<std::string> service_id_; + dbus::Property<std::map<std::string, std::string>> service_info_; + dbus::Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>> + ip_infos_; + + DISALLOW_COPY_AND_ASSIGN(ServiceProperties); + }; + + class PeerProperties : public dbus::PropertySet { + public: + PeerProperties(dbus::ObjectProxy* object_proxy, + const PropertyChangedCallback& callback); + ~PeerProperties() override; + + const std::string& uuid() const { return uuid_.value(); } + uint64_t last_seen() const { return last_seen_.value(); } + + private: + dbus::Property<std::string> uuid_; + dbus::Property<uint64_t> last_seen_; + + 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; + + // Retrieves a list of all the services. + virtual std::vector<dbus::ObjectPath> GetServices() = 0; + + // Retrieves a list of all the peers. + virtual std::vector<dbus::ObjectPath> GetPeers() = 0; + + // Obtains the properties for the service with object path |object_path|, + // any values should be copied if needed. + virtual ServiceProperties* GetServiceProperties( + const dbus::ObjectPath& object_path) = 0; + + // Obtains the properties for the peer with object path |object_path|, + // any values should be copied if needed. + virtual PeerProperties* GetPeerProperties( + 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, |