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}
CrOS-Libchrome-Original-Commit: 32d25453c4d04474d75a6db01cd1e006537bd3bf
diff --git a/dbus/property.h b/dbus/property.h
index ea893dc..419da53 100644
--- a/dbus/property.h
+++ b/dbus/property.h
@@ -7,6 +7,8 @@
#include <map>
#include <string>
+#include <utility>
+#include <vector>
#include "base/basictypes.h"
#include "base/bind.h"
@@ -158,7 +160,7 @@
// no knowledge of the contained type is required, this method returns
// true if its expected type was found, false if not.
// Implementation provided by specialization.
- virtual bool PopValueFromReader(MessageReader*) = 0;
+ virtual bool PopValueFromReader(MessageReader* reader) = 0;
// Method used by PropertySet to append the set value to a MessageWriter,
// no knowledge of the contained type is required.
@@ -229,7 +231,7 @@
// Methods connected by ConnectSignals() and called by dbus:: when
// a property is changed. Sub-classes may override if the property
// changed signal provides different arguments.
- virtual void ChangedReceived(Signal*);
+ virtual void ChangedReceived(Signal* signal);
virtual void ChangedConnected(const std::string& interface_name,
const std::string& signal_name,
bool success);
@@ -376,7 +378,7 @@
// Method used by PropertySet to retrieve the value from a MessageReader,
// no knowledge of the contained type is required, this method returns
// true if its expected type was found, false if not.
- bool PopValueFromReader(MessageReader*) override;
+ bool PopValueFromReader(MessageReader* reader) override;
// Method used by PropertySet to append the set value to a MessageWriter,
// no knowledge of the contained type is required.
@@ -398,6 +400,10 @@
property_set()->NotifyPropertyChanged(name());
}
+ // Method used by test and stub implementations to directly set the
+ // |set_value_| of a property.
+ void ReplaceSetValueForTesting(const T& value) { set_value_ = value; }
+
private:
// Current cached value of the property.
T value_;
@@ -485,6 +491,23 @@
MessageWriter* writer);
extern template class Property<std::vector<uint8> >;
+template <>
+bool Property<std::map<std::string, std::string>>::PopValueFromReader(
+ MessageReader* reader);
+template <>
+void Property<std::map<std::string, std::string>>::AppendSetValueToWriter(
+ MessageWriter* writer);
+extern template class Property<std::map<std::string, std::string>>;
+
+template <>
+bool Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
+ PopValueFromReader(MessageReader* reader);
+template <>
+void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
+ AppendSetValueToWriter(MessageWriter* writer);
+extern template class Property<
+ std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>;
+
} // namespace dbus
#endif // DBUS_PROPERTY_H_