Bug 1158081 - Patch (1/2): Define macro to declare SocketObserver functions, r=tzimmermann
authorBen Tian <btian@mozilla.com>
Tue, 28 Apr 2015 11:12:13 +0800
changeset 241668 8721fd2d3caedbe7646e7d5b5da100d0813ebb05
parent 241667 f6dba218092307892666c70d20bd0e9034407949
child 241669 4c438af160679af4b1c21be083f0f494e1ca7e6f
push id28667
push userryanvm@gmail.com
push dateThu, 30 Apr 2015 17:35:13 +0000
treeherdermozilla-central@68490bfe736c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstzimmermann
bugs1158081
milestone40.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 1158081 - Patch (1/2): Define macro to declare SocketObserver functions, r=tzimmermann
dom/bluetooth/BluetoothSocketObserver.h
dom/bluetooth/bluedroid/BluetoothOppManager.h
dom/bluetooth/bluez/BluetoothHfpManager.h
dom/bluetooth/bluez/BluetoothOppManager.h
--- a/dom/bluetooth/BluetoothSocketObserver.h
+++ b/dom/bluetooth/BluetoothSocketObserver.h
@@ -35,14 +35,21 @@ public:
   virtual void OnSocketConnectError(BluetoothSocket* aSocket) = 0;
 
    /**
     * A callback function which would be called when a socket connection
     * is dropped. To be more specific, this would be called when socket state
     * changes from CONNECTED/LISTENING to DISCONNECTED.
     */
   virtual void OnSocketDisconnect(BluetoothSocket* aSocket) = 0;
+};
 
-};
+#define BT_DECL_SOCKET_OBSERVER                                             \
+public:                                                                     \
+  virtual void ReceiveSocketData(BluetoothSocket* aSocket,                  \
+    nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aMessage) override;          \
+  virtual void OnSocketConnectSuccess(BluetoothSocket* aSocket) override;   \
+  virtual void OnSocketConnectError(BluetoothSocket* aSocket) override;     \
+  virtual void OnSocketDisconnect(BluetoothSocket* aSocket) override;
 
 END_BLUETOOTH_NAMESPACE
 
 #endif
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.h
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.h
@@ -35,16 +35,17 @@ class BluetoothOppManager : public Bluet
 {
   class CloseSocketTask;
   class ReadFileTask;
   class SendFileBatch;
   class SendSocketDataTask;
 
 public:
   BT_DECL_PROFILE_MGR_BASE
+  BT_DECL_SOCKET_OBSERVER
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("OPP");
   }
 
   static const int MAX_PACKET_LENGTH = 0xFFFE;
 
   static BluetoothOppManager* Get();
@@ -63,24 +64,16 @@ public:
   void SendPutRequest(uint8_t* aFileBody, int aFileBodyLength);
   void SendPutFinalRequest();
   void SendDisconnectRequest();
 
   void ExtractPacketHeaders(const ObexHeaderSet& aHeader);
   bool ExtractBlobHeaders();
   void CheckPutFinal(uint32_t aNumRead);
 
-  // The following functions are inherited from BluetoothSocketObserver
-  void ReceiveSocketData(
-    BluetoothSocket* aSocket,
-    nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aMessage) override;
-  virtual void OnSocketConnectSuccess(BluetoothSocket* aSocket) override;
-  virtual void OnSocketConnectError(BluetoothSocket* aSocket) override;
-  virtual void OnSocketDisconnect(BluetoothSocket* aSocket) override;
-
 protected:
   virtual ~BluetoothOppManager();
 
 private:
   BluetoothOppManager();
   bool Init();
   void HandleShutdown();
 
--- a/dom/bluetooth/bluez/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.h
@@ -75,32 +75,25 @@ public:
 #endif // MOZ_B2G_RIL
 
 class BluetoothHfpManager : public BluetoothSocketObserver
                           , public BluetoothHfpManagerBase
                           , public BatteryObserver
 {
 public:
   BT_DECL_HFP_MGR_BASE
+  BT_DECL_SOCKET_OBSERVER
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("HFP/HSP");
   }
 
   static BluetoothHfpManager* Get();
+  bool Listen();
 
-  // The following functions are inherited from BluetoothSocketObserver
-  virtual void ReceiveSocketData(
-    BluetoothSocket* aSocket,
-    nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aMessage) override;
-  virtual void OnSocketConnectSuccess(BluetoothSocket* aSocket) override;
-  virtual void OnSocketConnectError(BluetoothSocket* aSocket) override;
-  virtual void OnSocketDisconnect(BluetoothSocket* aSocket) override;
-
-  bool Listen();
   /**
    * This function set up a Synchronous Connection (SCO) link for HFP.
    * Service Level Connection (SLC) should be established before SCO setup
    * process.
    * If SLC haven't been established, this function will return false and
    * send a request to set up SCO ater HfpManager receive AT+CMER, unless we are
    * connecting HSP socket rather than HFP socket.
    *
--- a/dom/bluetooth/bluez/BluetoothOppManager.h
+++ b/dom/bluetooth/bluez/BluetoothOppManager.h
@@ -31,16 +31,17 @@ class BluetoothSocket;
 class ObexHeaderSet;
 class SendFileBatch;
 
 class BluetoothOppManager : public BluetoothSocketObserver
                           , public BluetoothProfileManagerBase
 {
 public:
   BT_DECL_PROFILE_MGR_BASE
+  BT_DECL_SOCKET_OBSERVER
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("OPP");
   }
 
   static const int MAX_PACKET_LENGTH = 0xFFFE;
 
   static BluetoothOppManager* Get();
@@ -59,24 +60,16 @@ public:
   void SendPutRequest(uint8_t* aFileBody, int aFileBodyLength);
   void SendPutFinalRequest();
   void SendDisconnectRequest();
 
   void ExtractPacketHeaders(const ObexHeaderSet& aHeader);
   bool ExtractBlobHeaders();
   void CheckPutFinal(uint32_t aNumRead);
 
-  // The following functions are inherited from BluetoothSocketObserver
-  void ReceiveSocketData(
-    BluetoothSocket* aSocket,
-    nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aMessage) override;
-  virtual void OnSocketConnectSuccess(BluetoothSocket* aSocket) override;
-  virtual void OnSocketConnectError(BluetoothSocket* aSocket) override;
-  virtual void OnSocketDisconnect(BluetoothSocket* aSocket) override;
-
 protected:
   virtual ~BluetoothOppManager();
 
 private:
   BluetoothOppManager();
   bool Init();
   void HandleShutdown();