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

Unified Diff: dbus/bus.cc

Issue 8161005: Fix a bug in dbus::Bus::AddFilterFunction(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/bus.cc
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 89918e0abe1234ba0081399fa74551c370e8739c..87fe9c7d9d9ee9a10e9e04669b31e5dfd23bad09 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -439,37 +439,45 @@ void Bus::Send(DBusMessage* request, uint32* serial) {
CHECK(success) << "Unable to allocate memory";
}
-void Bus::AddFilterFunction(DBusHandleMessageFunction filter_function,
+bool Bus::AddFilterFunction(DBusHandleMessageFunction filter_function,
void* user_data) {
DCHECK(connection_);
AssertOnDBusThread();
- if (filter_functions_added_.find(filter_function) !=
+ std::pair<DBusHandleMessageFunction, void*> filter_data_pair =
+ std::make_pair(filter_function, user_data);
+ if (filter_functions_added_.find(filter_data_pair) !=
filter_functions_added_.end()) {
- LOG(ERROR) << "Filter function already exists: " << filter_function;
- return;
+ VLOG(1) << "Filter function already exists: " << filter_function
+ << " with associated data: " << user_data;
+ return false;
cwolfe 2011/10/05 22:39:16 Do not know our rules for logging pointer-like thi
satorux1 2011/10/05 23:04:40 I thought our logging library automatically conver
}
const bool success = dbus_connection_add_filter(
connection_, filter_function, user_data, NULL);
CHECK(success) << "Unable to allocate memory";
- filter_functions_added_.insert(filter_function);
+ filter_functions_added_.insert(filter_data_pair);
+ return true;
}
-void Bus::RemoveFilterFunction(DBusHandleMessageFunction filter_function,
+bool Bus::RemoveFilterFunction(DBusHandleMessageFunction filter_function,
void* user_data) {
DCHECK(connection_);
AssertOnDBusThread();
- if (filter_functions_added_.find(filter_function) ==
+ std::pair<DBusHandleMessageFunction, void*> filter_data_pair =
+ std::make_pair(filter_function, user_data);
+ if (filter_functions_added_.find(filter_data_pair) ==
filter_functions_added_.end()) {
- LOG(ERROR) << "Requested to remove an unknown filter function: "
- << filter_function;
- return;
+ VLOG(1) << "Requested to remove an unknown filter function: "
+ << filter_function
+ << " with associated data: " << user_data;
+ return false;
}
dbus_connection_remove_filter(connection_, filter_function, user_data);
- filter_functions_added_.erase(filter_function);
+ filter_functions_added_.erase(filter_data_pair);
+ return true;
}
void Bus::AddMatch(const std::string& match_rule, DBusError* error) {
« no previous file with comments | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698