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

Unified Diff: src/device.cc

Issue 5380002: cashew: defer all D-Bus signal processing to main loop (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 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 | « src/device.h ('k') | src/main.cc » ('j') | src/property_changed_handler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/device.cc
diff --git a/src/device.cc b/src/device.cc
index abcc781d984dbaf83a741a52a3c5eef24ef6269c..b5ac6f5103d8a1c05e82b0f6633d7bd6b965b6a0 100644
--- a/src/device.cc
+++ b/src/device.cc
@@ -47,6 +47,7 @@ Device::Device(Service * const parent, DBus::Connection& connection, // NOLINT
if (get_properties_source_id_ == 0) {
LOG(ERROR) << path_ << ": ctor: g_idle_add failed";
}
+ property_changed_handler_.delegate(this);
}
Device::~Device() {
@@ -78,6 +79,21 @@ const std::string& Device::GetInterface() const {
void Device::PropertyChanged(const std::string& property_name,
const DBus::Variant& new_value) {
DLOG(INFO) << path_ << ": PropertyChanged: property_name = " << property_name;
+ // Queue a tuple representing this signal for later processing from the glib
+ // main loop. We do this to avoid libdbus-c++ deadlocks that can occur when
+ // sending a dbus message from within a dbus callback like this one.
+ PropertyChangedSignal signal(property_name, new_value);
+ property_changed_handler_.EnqueueSignal(signal);
+}
+
+// PropertyChangedDelegate methods
+
+void Device::OnPropertyChanged(const PropertyChangedHandler *handler,
+ const std::string& property_name,
+ const DBus::Variant& new_value) {
+ DCHECK(handler == &property_changed_handler_);
+ DLOG(INFO) << path_ << ": OnPropertyChanged: property_name = "
+ << property_name;
if (property_name == kFlimflamDeviceCarrierProperty) {
OnCarrierUpdate(new_value.reader().get_string());
} else if (property_name == kFlimflamDeviceInterfaceProperty) {
« no previous file with comments | « src/device.h ('k') | src/main.cc » ('j') | src/property_changed_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698