summaryrefslogtreecommitdiffstats
path: root/dbus/test_service.h
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 04:21:08 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 04:21:08 +0000
commitcf910da2d3cb23ac300968212dc8a196a64b2726 (patch)
treeb7975c349ab6aeccee275e630b2ece900000d387 /dbus/test_service.h
parentc401049c2ed235c156292b632f43198c44641b65 (diff)
downloadchromium_src-cf910da2d3cb23ac300968212dc8a196a64b2726.zip
chromium_src-cf910da2d3cb23ac300968212dc8a196a64b2726.tar.gz
chromium_src-cf910da2d3cb23ac300968212dc8a196a64b2726.tar.bz2
dbus: add Property handling for clients
D-Bus properties can be tricky to handle due to their reliance on variants, and since they use a common interface, result in a lot of copy and paste code to deal with. Add an API that simplifies matters somewhat; detailed documentation is in dbus/property.h, but fundamentally you add a struct Properties to the client implementation derived from dbus::PropertySet, and in it declare members of dbus::Property<property type> and connect them in the constructor with RegisterProperty(name, ptr). The API works on two levels, from a higher-level each member of the structure is a type-safe way to obtain the current value of the property, update the value, and set a new value. From the lower-level, it uses a generic reader/writer based interface so that the parent structure's GetAll and signal handling methods can update the values without requiring knowledge of the contained type. BUG=chromium:109194 TEST=unit tests included in CL change-Id: I111b9e60a2c6c35edd9e0ea9f6976928c6c6474b Review URL: http://codereview.chromium.org/9380053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/test_service.h')
-rw-r--r--dbus/test_service.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/dbus/test_service.h b/dbus/test_service.h
index ea3e5ad..2b49229 100644
--- a/dbus/test_service.h
+++ b/dbus/test_service.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -106,6 +106,24 @@ class TestService : public base::Thread {
void BrokenMethod(MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
+ // Returns a set of property values for testing.
+ void GetAllProperties(MethodCall* method_call,
+ dbus::ExportedObject::ResponseSender response_sender);
+
+ // Returns a new value of 20 for the Version property when called.
+ void GetProperty(MethodCall* method_call,
+ dbus::ExportedObject::ResponseSender response_sender);
+
+ // Allows the name property to be changed, errors otherwise.
+ void SetProperty(MethodCall* method_call,
+ dbus::ExportedObject::ResponseSender response_sender);
+
+ // Sends a property changed signal for the name property.
+ void SendPropertyChangedSignal(const std::string& name);
+
+ // Helper function for SendPropertyChangedSignal().
+ void SendPropertyChangedSignalInternal(const std::string& name);
+
scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_;
base::WaitableEvent on_all_methods_exported_;
// The number of methods actually exported.