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

Unified Diff: dbus/object_proxy.cc

Issue 8681002: dbus: Fix a bug where we were emitting spurious error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 1 month 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/object_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/object_proxy.cc
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc
index d9a53d9a3aee69bc5fdd40248744e51a1c9981f5..5da5901f888c0b5dbc73f0d81b4670d15662fec8 100644
--- a/dbus/object_proxy.cc
+++ b/dbus/object_proxy.cc
@@ -134,14 +134,16 @@ void ObjectProxy::Detach() {
}
}
- for (size_t i = 0; i < match_rules_.size(); ++i) {
+ for (std::set<std::string>::iterator iter = match_rules_.begin();
+ iter != match_rules_.end(); ++iter) {
ScopedDBusError error;
- bus_->RemoveMatch(match_rules_[i], error.get());
+ bus_->RemoveMatch(*iter, error.get());
if (error.is_set()) {
// There is nothing we can do to recover, so just print the error.
- LOG(ERROR) << "Failed to remove match rule: " << match_rules_[i];
+ LOG(ERROR) << "Failed to remove match rule: " << *iter;
}
}
+ match_rules_.clear();
}
// static
@@ -304,14 +306,22 @@ void ObjectProxy::ConnectToSignalInternal(
const std::string match_rule =
base::StringPrintf("type='signal', interface='%s'",
interface_name.c_str());
- ScopedDBusError error;
- bus_->AddMatch(match_rule, error.get());;
- if (error.is_set()) {
- LOG(ERROR) << "Failed to add match rule: " << match_rule;
+
+ // Add the match rule if we don't have it.
+ if (match_rules_.find(match_rule) == match_rules_.end()) {
+ ScopedDBusError error;
+ bus_->AddMatch(match_rule, error.get());;
+ if (error.is_set()) {
+ LOG(ERROR) << "Failed to add match rule: " << match_rule;
+ } else {
+ // Store the match rule, so that we can remove this in Detach().
+ match_rules_.insert(match_rule);
+ // Add the signal callback to the method table.
+ method_table_[absolute_signal_name] = signal_callback;
+ success = true;
+ }
} else {
- // Store the match rule, so that we can remove this in Detach().
- match_rules_.push_back(match_rule);
- // Add the signal callback to the method table.
+ // We already have the match rule.
method_table_[absolute_signal_name] = signal_callback;
success = true;
}
« no previous file with comments | « dbus/object_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698