summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authornywang <nywang@chromium.org>2015-09-22 17:06:40 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-23 00:08:50 +0000
commit8dbb26ec72f34075d951cbfd576fe2165e2f2e69 (patch)
treefc3094f0d2d12ea6d80e8e102bb7560f283e8710 /dbus
parent84bbc68af080af5388046697fa2cfa548962833d (diff)
downloadchromium_src-8dbb26ec72f34075d951cbfd576fe2165e2f2e69.zip
chromium_src-8dbb26ec72f34075d951cbfd576fe2165e2f2e69.tar.gz
chromium_src-8dbb26ec72f34075d951cbfd576fe2165e2f2e69.tar.bz2
libchrome: add support for synchronous PropertySet::Set to dbus
The existing PropertySet::Set function is asynchrounous. This CL adds the synchrounous version of PropertySet::Set. It is defined as PropertySet::SetAndBlock. BUG=https://b.corp.google.com/u/0/issues/24131409 TEST=manually tested Review URL: https://codereview.chromium.org/1361503003 Cr-Commit-Position: refs/heads/master@{#350268}
Diffstat (limited to 'dbus')
-rw-r--r--dbus/property.cc16
-rw-r--r--dbus/property.h8
2 files changed, 24 insertions, 0 deletions
diff --git a/dbus/property.cc b/dbus/property.cc
index dde0611..b7a0c8b 100644
--- a/dbus/property.cc
+++ b/dbus/property.cc
@@ -174,6 +174,22 @@ void PropertySet::Set(PropertyBase* property, SetCallback callback) {
callback));
}
+bool PropertySet::SetAndBlock(PropertyBase* property) {
+ MethodCall method_call(kPropertiesInterface, kPropertiesSet);
+ MessageWriter writer(&method_call);
+ writer.AppendString(interface());
+ writer.AppendString(property->name());
+ property->AppendSetValueToWriter(&writer);
+
+ DCHECK(object_proxy_);
+ scoped_ptr<dbus::Response> response(
+ object_proxy_->CallMethodAndBlock(&method_call,
+ ObjectProxy::TIMEOUT_USE_DEFAULT));
+ if (response.get())
+ return true;
+ return false;
+}
+
void PropertySet::OnSet(PropertyBase* property,
SetCallback callback,
Response* response) {
diff --git a/dbus/property.h b/dbus/property.h
index b308c82..940ef715d 100644
--- a/dbus/property.h
+++ b/dbus/property.h
@@ -276,6 +276,8 @@ class CHROME_DBUS_EXPORT PropertySet {
// depending on the remote object. This method may be overridden by
// sub-classes if interfaces use different method calls.
virtual void Set(PropertyBase* property, SetCallback callback);
+ // The sychronous version of Set().
+ virtual bool SetAndBlock(PropertyBase* property);
virtual void OnSet(PropertyBase* property, SetCallback callback,
Response* response);
@@ -389,6 +391,12 @@ class CHROME_DBUS_EXPORT Property : public PropertyBase {
property_set()->Set(this, callback);
}
+ // The sychronous version of Set().
+ virtual bool SetAndBlock(const T& value) {
+ set_value_ = value;
+ return property_set()->SetAndBlock(this);
+ }
+
// 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.