MonitorSignal low-level wrapper introduced
Change-Id: I12dd3725dcd05ba5fd490d1a94575fd794aa335b
BUG=chromium-os:11121
TEST=none
Review URL: http://codereview.chromium.org/6485006
diff --git a/chromeos/dbus/dbus.h b/chromeos/dbus/dbus.h
index 0258021..f786b2b 100644
--- a/chromeos/dbus/dbus.h
+++ b/chromeos/dbus/dbus.h
@@ -14,6 +14,9 @@
#include "base/logging.h"
#include "chromeos/glib/object.h"
+struct DBusMessage;
+struct DBusConnection;
+
namespace chromeos {
// \precondition No functions in the dbus namespace can be called before
@@ -416,6 +419,32 @@
const char* interface_name,
const char* signal_name);
+// \brief Low-level signal monitor base class.
+//
+// Used when there is no definite named signal sender (that Proxy
+// could be used for).
+
+class SignalWatcher {
+ public:
+ SignalWatcher() {}
+ ~SignalWatcher();
+ void StartMonitoring(const std::string& interface, const std::string& signal);
+ private:
+
+ // Callback invoked on the given signal arrival.
+ virtual void OnSignal(DBusMessage* message) = 0;
+
+ // Returns a string matching the D-Bus messages that we want to listen for.
+ std::string GetDBusMatchString() const;
+
+ // A D-Bus message filter to receive signals.
+ static DBusHandlerResult FilterDBusMessage(DBusConnection* dbus_conn,
+ DBusMessage* message,
+ void* data);
+ std::string interface_;
+ std::string signal_;
+};
+
} // namespace dbus
} // namespace chromeos