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

Unified Diff: src/service_manager.h

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
Index: src/service_manager.h
diff --git a/src/service_manager.h b/src/service_manager.h
index e12fd91503cfb92119166f6cad63103a599b79f4..d743f6cfd260e5fe15f160374e8cfa12759a16e2 100644
--- a/src/service_manager.h
+++ b/src/service_manager.h
@@ -5,6 +5,8 @@
#ifndef SRC_SERVICE_MANAGER_H_
#define SRC_SERVICE_MANAGER_H_
+#include <glib.h>
+
#include <map>
#include <string>
#include <vector>
@@ -13,6 +15,7 @@
#include <dbus-c++/dbus.h> // NOLINT
#include "src/flimflam_manager_client_glue.h"
+#include "src/property_changed_handler.h"
#include "src/service.h"
namespace cashew {
@@ -28,9 +31,11 @@ typedef std::vector<DBus::Path> ServicePathList;
// monitors Flimflam and maintains a collection of cellular service objects
class ServiceManager : public org::chromium::flimflam::Manager_proxy,
public DBus::IntrospectableProxy,
- public DBus::ObjectProxy {
+ public DBus::ObjectProxy,
+ public PropertyChangedDelegate {
public:
- explicit ServiceManager(DBus::Connection& connection); // NOLINT
+ ServiceManager(DBus::Connection& connection, // NOLINT
+ GMainLoop * const main_loop);
virtual ~ServiceManager();
// look up a service by its path name
@@ -66,13 +71,23 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// Flimflam Manager D-Bus Proxy methods
- // receive incoming PropertyChanged D-Bus signal from Flimflam
+ // receive incoming PropertyChanged D-Bus signal from Flimflam and
+ // schedule deferred processing
virtual void PropertyChanged(const std::string& property_name,
const DBus::Variant& new_value);
- // receive incoming StateChanged D-Bus signal from Flimflam
+ // receive incoming StateChanged D-Bus signal from Flimflam, convert to a
+ // PropertyChanged signal, and schedule deferred processing
virtual void StateChanged(const std::string& new_state_string);
+ // PropertyChangedDelegate methods
+
+ // Perform deferred processing for an incoming PropertyChanged D-Bus signal
+ // from Flimflam
+ virtual void OnPropertyChanged(const PropertyChangedHandler *handler,
+ const std::string& property_name,
+ const DBus::Variant& new_value);
+
// Service methods
// a child Service wants us to emit an update about its data plans
@@ -97,6 +112,9 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// shared with Service objs that we create
DBus::Connection& connection_;
+ // glib main loop
+ GMainLoop * const main_loop_;
+
// collection of Service objs representing cellular services
ServiceMap services_;
@@ -123,6 +141,16 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// and our subsequent timer calls
bool retrying_get_properties_;
+ // Handler for deferred processing of D-Bus PropertyChanged signals.
+ //
+ // We construct and enqueue PropertyChangedSignal objects as D-Bus signals
+ // arrive, and the handler calls our OnPropertyChanged method (part of our
+ // PropertyChangedDelegate interface) later from the glib main loop.
+ //
+ // This is done to avoid a libdbus-c++ deadlock that can occur when dbus
+ // messages are sent from within a dbus callback.
+ PropertyChangedHandler property_changed_handler_;
+
// delete a collection of services
void DeleteServices(ServiceMap *service_map);
@@ -135,6 +163,9 @@ class ServiceManager : public org::chromium::flimflam::Manager_proxy,
// returns true on success and false on failure
bool GetFlimflamProperties();
+ // we've received updated State info from Flimflam
+ void OnStateUpdate(const std::string& new_state_string);
+
// we've received updated DefaultTechnology info from Flimflam
void OnDefaultTechnologyUpdate(const std::string& default_technology);
« src/property_changed_handler.cc ('K') | « src/service.cc ('k') | src/service_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698