Bug 919913: Introduce DBusReplyCallback, r=qdot,echou
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 01 Oct 2013 10:20:55 +0200
changeset 149481 80cb0e43b3d4e6b789e1dafdf38a7c9a6353505e
parent 149480 3ae1579c5105e05984a8ff2471c4862b91760a44
child 149482 e5f7ef93ce3948a9876d1c580791dc5b52e1ce77
push id25391
push userryanvm@gmail.com
push dateTue, 01 Oct 2013 21:23:05 +0000
treeherdermozilla-central@242aa3916310 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot, echou
bugs919913
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 919913: Introduce DBusReplyCallback, r=qdot,echou DBusReplyCallback replaces the removed DBusCallback as type for reply-handler functions. Bluetooth, the only user of DBus, has been updated as well.
dom/bluetooth/linux/BluetoothDBusService.cpp
dom/bluetooth/linux/BluetoothDBusService.h
ipc/dbus/RawDBusConnection.cpp
ipc/dbus/RawDBusConnection.h
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -1940,17 +1940,17 @@ BluetoothDBusService::SendDiscoveryMessa
 
   return NS_OK;
 }
 
 nsresult
 BluetoothDBusService::SendInputMessage(const nsAString& aDeviceAddress,
                                        const nsAString& aMessage)
 {
-  void (*callback)(DBusMessage*, void*);
+  DBusReplyCallback callback;
   if (aMessage.EqualsLiteral("Connect")) {
     callback = InputConnectCallback;
   } else if (aMessage.EqualsLiteral("Disconnect")) {
     callback = InputDisconnectCallback;
   } else {
     MOZ_ASSERT(false);
     return NS_ERROR_FAILURE;
   }
@@ -1958,17 +1958,17 @@ BluetoothDBusService::SendInputMessage(c
   nsString objectPath = GetObjectPathFromAddress(sAdapterPath, aDeviceAddress);
   return SendAsyncDBusMessage(objectPath, DBUS_INPUT_IFACE, aMessage, callback);
 }
 
 nsresult
 BluetoothDBusService::SendAsyncDBusMessage(const nsAString& aObjectPath,
                                            const char* aInterface,
                                            const nsAString& aMessage,
-                                           void (*aCallback)(DBusMessage*, void*))
+                                           DBusReplyCallback aCallback)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mConnection);
   MOZ_ASSERT(IsEnabled());
   MOZ_ASSERT(aCallback);
   MOZ_ASSERT(!aObjectPath.IsEmpty());
   MOZ_ASSERT(aInterface);
 
@@ -1992,17 +1992,17 @@ BluetoothDBusService::SendAsyncDBusMessa
 
   return NS_OK;
 }
 
 nsresult
 BluetoothDBusService::SendSinkMessage(const nsAString& aDeviceAddress,
                                       const nsAString& aMessage)
 {
-  void (*callback)(DBusMessage*, void*);
+  DBusReplyCallback callback;
   if (aMessage.EqualsLiteral("Connect")) {
     callback = SinkConnectCallback;
   } else if (aMessage.EqualsLiteral("Disconnect")) {
     callback = SinkDisconnectCallback;
   } else {
     MOZ_ASSERT(false);
     return NS_ERROR_FAILURE;
   }
--- a/dom/bluetooth/linux/BluetoothDBusService.h
+++ b/dom/bluetooth/linux/BluetoothDBusService.h
@@ -198,14 +198,14 @@ private:
                                   const BluetoothNamedValue& aValue,
                                   BluetoothReplyRunnable* aRunnable);
 
   void UpdateNotification(ControlEventId aEventId, uint64_t aData);
 
   nsresult SendAsyncDBusMessage(const nsAString& aObjectPath,
                                 const char* aInterface,
                                 const nsAString& aMessage,
-                                void (*aCallback)(DBusMessage*, void*));
+                                mozilla::ipc::DBusReplyCallback aCallback);
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif
--- a/ipc/dbus/RawDBusConnection.cpp
+++ b/ipc/dbus/RawDBusConnection.cpp
@@ -130,31 +130,31 @@ protected:
 // run it in DBus thread.
 //
 class DBusConnectionSendWithReplyRunnable : public DBusConnectionSendRunnableBase
 {
 private:
   class NotifyData
   {
   public:
-    NotifyData(void (*aCallback)(DBusMessage*, void*), void* aData)
+    NotifyData(DBusReplyCallback aCallback, void* aData)
     : mCallback(aCallback),
       mData(aData)
     { }
 
     void RunNotifyCallback(DBusMessage* aMessage)
     {
       if (mCallback) {
         mCallback(aMessage, mData);
       }
     }
 
   private:
-    void (*mCallback)(DBusMessage*, void*);
-    void*  mData;
+    DBusReplyCallback mCallback;
+    void*             mData;
   };
 
   // Callback function for DBus replies. Only run it in DBus thread.
   //
   static void Notify(DBusPendingCall* aCall, void* aData)
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
@@ -172,17 +172,17 @@ private:
     dbus_pending_call_cancel(aCall);
     dbus_pending_call_unref(aCall);
   }
 
 public:
   DBusConnectionSendWithReplyRunnable(DBusConnection* aConnection,
                                       DBusMessage* aMessage,
                                       int aTimeout,
-                                      void (*aCallback)(DBusMessage*, void*),
+                                      DBusReplyCallback aCallback,
                                       void* aData)
   : DBusConnectionSendRunnableBase(aConnection, aMessage),
     mCallback(aCallback),
     mData(aData),
     mTimeout(aTimeout)
   { }
 
   NS_IMETHOD Run()
@@ -210,19 +210,19 @@ public:
     return NS_OK;
   };
 
 protected:
   ~DBusConnectionSendWithReplyRunnable()
   { }
 
 private:
-  void (*mCallback)(DBusMessage*, void*);
-  void*  mData;
-  int    mTimeout;
+  DBusReplyCallback mCallback;
+  void*             mData;
+  int               mTimeout;
 };
 
 //
 // Legacy interface, don't use in new code
 //
 // Sends a message and waits for the reply. Only run it in DBus thread.
 //
 class DBusConnectionSendAndBlockRunnable : public DBusConnectionSendSyncRunnable
@@ -364,17 +364,17 @@ bool RawDBusConnection::Send(DBusMessage
       dbus_message_unref(aMessage);
     }
     return false;
   }
 
   return true;
 }
 
-bool RawDBusConnection::SendWithReply(void (*aCallback)(DBusMessage*, void*),
+bool RawDBusConnection::SendWithReply(DBusReplyCallback aCallback,
                                       void* aData,
                                       int aTimeout,
                                       DBusMessage* aMessage)
 {
   nsRefPtr<nsIRunnable> t(
     new DBusConnectionSendWithReplyRunnable(mConnection, aMessage,
                                             aTimeout, aCallback, aData));
   MOZ_ASSERT(t);
@@ -386,17 +386,17 @@ bool RawDBusConnection::SendWithReply(vo
       dbus_message_unref(aMessage);
     }
     return false;
   }
 
   return true;
 }
 
-bool RawDBusConnection::SendWithReply(void (*aCallback)(DBusMessage*, void*),
+bool RawDBusConnection::SendWithReply(DBusReplyCallback aCallback,
                                       void* aData,
                                       int aTimeout,
                                       const char* aPath,
                                       const char* aIntf,
                                       const char* aFunc,
                                       int aFirstArgType,
                                       ...)
 {
--- a/ipc/dbus/RawDBusConnection.h
+++ b/ipc/dbus/RawDBusConnection.h
@@ -19,16 +19,18 @@
 
 struct DBusConnection;
 struct DBusError;
 struct DBusMessage;
 
 namespace mozilla {
 namespace ipc {
 
+typedef void (*DBusReplyCallback)(DBusMessage*, void*);
+
 class RawDBusConnection : public AtomicRefCounted<RawDBusConnection>
 {
   struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits<DBusConnection>
   {
     static void release(DBusConnection* ptr);
   };
 
 public:
@@ -39,20 +41,20 @@ public:
 
   DBusConnection* GetConnection()
   {
     return mConnection;
   }
 
   bool Send(DBusMessage* aMessage);
 
-  bool SendWithReply(void (*aCallback)(DBusMessage*, void*), void* aData,
+  bool SendWithReply(DBusReplyCallback aCallback, void* aData,
                      int aTimeout, DBusMessage* aMessage);
 
-  bool SendWithReply(void (*aCallback)(DBusMessage*, void*), void* aData,
+  bool SendWithReply(DBusReplyCallback aCallback, void* aData,
                      int aTimeout, const char* aPath, const char* aIntf,
                      const char *aFunc, int aFirstArgType, ...);
 
   /* Legacy interface, don't use in new code */
   bool SendWithError(DBusMessage** aReply, DBusError* aError, int aTimeout,
                      DBusMessage* aMessage);
 
   /* Legacy interface, don't use in new code */