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

Unified Diff: dbus/object_proxy.cc

Issue 24673006: dbus: Stop accessing ObjectProxy::name_owner_changed_callback_ on the D-Bus thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/object_proxy.h ('k') | dbus/signal_sender_verification_unittest.cc » ('j') | 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 5ff0b862fd1666aeea1fee77c2c6c74c1d4ea3d3..f2c4ebd7932f61c3b80ef043cab1426c89d3bf18 100644
--- a/dbus/object_proxy.cc
+++ b/dbus/object_proxy.cc
@@ -185,6 +185,13 @@ void ObjectProxy::ConnectToSignal(const std::string& interface_name,
signal_name));
}
+void ObjectProxy::SetNameOwnerChangedCallback(
+ NameOwnerChangedCallback callback) {
+ bus_->AssertOnOriginThread();
+
+ name_owner_changed_callback_ = callback;
+}
+
void ObjectProxy::Detach() {
bus_->AssertOnDBusThread();
@@ -407,12 +414,6 @@ bool ObjectProxy::ConnectToSignalInternal(const std::string& interface_name,
return success;
}
-void ObjectProxy::SetNameOwnerChangedCallback(SignalCallback callback) {
- bus_->AssertOnOriginThread();
-
- name_owner_changed_callback_ = callback;
-}
-
DBusHandlerResult ObjectProxy::HandleMessage(
DBusConnection* connection,
DBusMessage* raw_message) {
@@ -620,19 +621,10 @@ DBusHandlerResult ObjectProxy::HandleNameOwnerChanged(
reader.PopString(&new_owner) &&
name == service_name_) {
service_name_owner_ = new_owner;
- if (!name_owner_changed_callback_.is_null()) {
- const base::TimeTicks start_time = base::TimeTicks::Now();
- Signal* released_signal = signal.release();
- std::vector<SignalCallback> callbacks;
- callbacks.push_back(name_owner_changed_callback_);
- bus_->GetOriginTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&ObjectProxy::RunMethod,
- this,
- start_time,
- callbacks,
- released_signal));
- }
+ bus_->GetOriginTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ObjectProxy::RunNameOwnerChangedCallback,
+ this, old_owner, new_owner));
}
}
@@ -641,4 +633,11 @@ DBusHandlerResult ObjectProxy::HandleNameOwnerChanged(
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+void ObjectProxy::RunNameOwnerChangedCallback(const std::string& old_owner,
+ const std::string& new_owner) {
+ bus_->AssertOnOriginThread();
+ if (!name_owner_changed_callback_.is_null())
+ name_owner_changed_callback_.Run(old_owner, new_owner);
+}
+
} // namespace dbus
« no previous file with comments | « dbus/object_proxy.h ('k') | dbus/signal_sender_verification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698