Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: dbus/bus.h

Issue 12088068: DBus: Bus::AddMatch and RemoveMatch support repeated rules. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: RemoveMatch returns a bool. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/bus.h
diff --git a/dbus/bus.h b/dbus/bus.h
index 75de9a3d1e240d51b81ba208ff910df2a5df3942..3f3ef4a3ac643f3f067f3613a26fd536d0607512 100644
--- a/dbus/bus.h
+++ b/dbus/bus.h
@@ -367,8 +367,8 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
// Instead, you should check if an incoming message is what you are
// interested in, in the filter functions.
//
- // The same match rule can be added more than once, but ignored from the
- // second time.
+ // The same match rule can be added more than once and should be removed
+ // as many times as it was added.
//
// The match rule looks like:
// "type='signal', interface='org.chromium.SomeInterface'".
@@ -381,9 +381,11 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
virtual void AddMatch(const std::string& match_rule, DBusError* error);
// Removes the match rule previously added by AddMatch().
+ // Returns false if the requested match rule is unknown or has already been
+ // removed. Otherwise, returns true and sets |error| accordingly.
//
// BLOCKING CALL.
- virtual void RemoveMatch(const std::string& match_rule, DBusError* error);
+ virtual bool RemoveMatch(const std::string& match_rule, DBusError* error);
// Tries to register the object path. Returns true on success.
// Returns false if the object path is already registered.
@@ -517,7 +519,9 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
std::set<std::string> owned_service_names_;
// The following sets are used to check if rules/object_paths/filters
// are properly cleaned up before destruction of the bus object.
- std::set<std::string> match_rules_added_;
+ // Since it's not an error to add the same match rule twice, the repeated
+ // match rules are counted in a map.
+ std::map<std::string, int> match_rules_added_;
std::set<ObjectPath> registered_object_paths_;
std::set<std::pair<DBusHandleMessageFunction, void*> >
filter_functions_added_;
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698