summaryrefslogtreecommitdiffstats
path: root/dbus/object_manager.h
diff options
context:
space:
mode:
authorarmansito <armansito@chromium.org>2014-09-05 10:49:34 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-05 17:52:01 +0000
commitebff093d22cd5c0613f3493acdbc1af1cfd5d31f (patch)
tree39994650df189224daec3bd24aa469cf17227abd /dbus/object_manager.h
parent4502cc6303f4aabd05e7fef6fbfaf4dfd1600bb6 (diff)
downloadchromium_src-ebff093d22cd5c0613f3493acdbc1af1cfd5d31f.zip
chromium_src-ebff093d22cd5c0613f3493acdbc1af1cfd5d31f.tar.gz
chromium_src-ebff093d22cd5c0613f3493acdbc1af1cfd5d31f.tar.bz2
dbus::ObjectManager: Add a match rule for properties before GetManagedObjects.
There is a race condition in the way that match rules get set up for object proxies created in response to GetManagedObjects that may cause us the miss PropertiesChanged signals if they're received before the match rule and filter function get added by ObjectProxy. This patch changes this to work the "intended" way: ObjectManager now adds a single match rule for its corresponding service name, and specifically for the org.freedesktop.DBus.Properties.PropertiesChanged signal. Once it receives the signal, ObjectManager dispatches the signal to the corresponding PropertySet. BUG=407109,400768 TEST=dbus_unittests Review URL: https://codereview.chromium.org/510863002 Cr-Commit-Position: refs/heads/master@{#293551}
Diffstat (limited to 'dbus/object_manager.h')
-rw-r--r--dbus/object_manager.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/dbus/object_manager.h b/dbus/object_manager.h
index 0d3ae5d0..30dfc42 100644
--- a/dbus/object_manager.h
+++ b/dbus/object_manager.h
@@ -223,12 +223,47 @@ public:
// a need to call this manually.
void GetManagedObjects();
+ // Cleans up any match rules and filter functions added by this ObjectManager.
+ // The Bus object will take care of this so you don't have to do it manually.
+ //
+ // BLOCKING CALL.
+ void CleanUp();
+
protected:
virtual ~ObjectManager();
private:
friend class base::RefCountedThreadSafe<ObjectManager>;
+ // Connects the InterfacesAdded and InterfacesRemoved signals and calls
+ // GetManagedObjects. Called from OnSetupMatchRuleAndFilterComplete.
+ void InitializeObjects();
+
+ // Called from the constructor to add a match rule for PropertiesChanged
+ // signals on the DBus thread and set up a corresponding filter function.
+ bool SetupMatchRuleAndFilter();
+
+ // Called on the origin thread once the match rule and filter have been set
+ // up. |success| is false, if an error occurred during set up; it's true
+ // otherwise.
+ void OnSetupMatchRuleAndFilterComplete(bool success);
+
+ // Called by dbus:: when a message is received. This is used to filter
+ // PropertiesChanged signals from the correct sender and relay the event to
+ // the correct PropertySet.
+ static DBusHandlerResult HandleMessageThunk(DBusConnection* connection,
+ DBusMessage* raw_message,
+ void* user_data);
+ DBusHandlerResult HandleMessage(DBusConnection* connection,
+ DBusMessage* raw_message);
+
+ // Called when a PropertiesChanged signal is received from the sender.
+ // This method notifies the relevant PropertySet that it should update its
+ // properties based on the received signal. Called from HandleMessage.
+ void NotifyPropertiesChanged(const dbus::ObjectPath object_path,
+ Signal* signal);
+ void NotifyPropertiesChangedHelper(const dbus::ObjectPath object_path,
+ Signal* signal);
// Called by dbus:: in response to the GetManagedObjects() method call.
void OnGetManagedObjects(Response* response);
@@ -281,8 +316,12 @@ public:
Bus* bus_;
std::string service_name_;
+ std::string service_name_owner_;
+ std::string match_rule_;
ObjectPath object_path_;
ObjectProxy* object_proxy_;
+ bool setup_success_;
+ bool cleanup_called_;
// Maps the name of an interface to the implementation class used for
// instantiating PropertySet structures for that interface's properties.