Bug 859005 - Allow ownership take-over in ReceiveSocketData(). r=qDot, r=echou, a=tef+
authorVicamo Yang <vyang@mozilla.com>
Mon, 08 Apr 2013 08:50:54 -0400
changeset 118985 ed94f222170cd349b892f257f3c6918145eac011
parent 118984 a6c459e49121060f58c2402f51c2894883547c54
child 118986 aa6f30aa779cca11c329c1eb1d98d56340f2ee51
push id635
push userryanvm@gmail.com
push dateMon, 08 Apr 2013 12:54:53 +0000
reviewersqDot, echou, tef
bugs859005, 826931
milestone18.0
Bug 859005 - Allow ownership take-over in ReceiveSocketData(). r=qDot, r=echou, a=tef+ Originally from bug 826931.
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothHfpManager.h
dom/bluetooth/BluetoothOppManager.cpp
dom/bluetooth/BluetoothOppManager.h
dom/bluetooth/BluetoothScoManager.cpp
dom/bluetooth/BluetoothScoManager.h
ipc/unixsocket/UnixSocket.h
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -662,17 +662,17 @@ BluetoothHfpManager::HandleShutdown()
   gInShutdown = true;
   CloseSocket();
   gBluetoothHfpManager = nullptr;
   return NS_OK;
 }
 
 // Virtual function of class SocketConsumer
 void
-BluetoothHfpManager::ReceiveSocketData(UnixSocketRawData* aMessage)
+BluetoothHfpManager::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsAutoCString msg((const char*)aMessage->mData.get(), aMessage->mSize);
   msg.StripWhitespace();
 
   nsTArray<nsCString> atCommandValues;
 
--- a/dom/bluetooth/BluetoothHfpManager.h
+++ b/dom/bluetooth/BluetoothHfpManager.h
@@ -47,17 +47,17 @@ enum BluetoothCmeError {
   NETWORK_TIMEOUT = 31,
   NETWORK_NOT_ALLOWED = 32
 };
 
 class BluetoothHfpManager : public mozilla::ipc::UnixSocketConsumer
 {
 public:
   static BluetoothHfpManager* Get();
-  virtual void ReceiveSocketData(mozilla::ipc::UnixSocketRawData* aMessage)
+  virtual void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage)
     MOZ_OVERRIDE;
 
   bool Connect(const nsAString& aDeviceObjectPath,
                const bool aIsHandsfree,
                BluetoothReplyRunnable* aRunnable);
   void Disconnect();
   bool Listen();
 
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -907,17 +907,17 @@ BluetoothOppManager::ClientDataHandler(U
                                                       mRemoteMaxPacketLength));
   } else {
     NS_WARNING("Unhandled ObexRequestCode");
   }
 }
 
 // Virtual function of class SocketConsumer
 void
-BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
+BluetoothOppManager::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
   if (mLastCommand) {
     ClientDataHandler(aMessage);
     return;
   }
 
   ServerDataHandler(aMessage);
 }
--- a/dom/bluetooth/BluetoothOppManager.h
+++ b/dom/bluetooth/BluetoothOppManager.h
@@ -28,17 +28,17 @@ public:
    * function add_reserved_service_records() in
    * external/bluetooth/bluez/src/adapter.c for more information.
    */
   static const int DEFAULT_OPP_CHANNEL = 10;
   static const int MAX_PACKET_LENGTH = 0xFFFE;
 
   ~BluetoothOppManager();
   static BluetoothOppManager* Get();
-  void ReceiveSocketData(mozilla::ipc::UnixSocketRawData* aMessage)
+  void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage)
     MOZ_OVERRIDE;
   void ClientDataHandler(mozilla::ipc::UnixSocketRawData* aMessage);
   void ServerDataHandler(mozilla::ipc::UnixSocketRawData* aMessage);
 
   /*
    * If a application wnats to send a file, first, it needs to
    * call Connect() to create a valid RFCOMM connection. After
    * that, call SendFile()/StopSendingFile() to control file-sharing
--- a/dom/bluetooth/BluetoothScoManager.cpp
+++ b/dom/bluetooth/BluetoothScoManager.cpp
@@ -170,17 +170,17 @@ BluetoothScoManager::Get()
   }
 
   gBluetoothScoManager = manager;
   return gBluetoothScoManager;
 }
 
 // Virtual function of class SocketConsumer
 void
-BluetoothScoManager::ReceiveSocketData(mozilla::ipc::UnixSocketRawData* aMessage)
+BluetoothScoManager::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
   // SCO socket do nothing here
   MOZ_NOT_REACHED("This should never be called!");
 }
 
 nsresult
 BluetoothScoManager::HandleShutdown()
 {
--- a/dom/bluetooth/BluetoothScoManager.h
+++ b/dom/bluetooth/BluetoothScoManager.h
@@ -17,17 +17,17 @@ class BluetoothReplyRunnable;
 class BluetoothScoManagerObserver;
 
 class BluetoothScoManager : public mozilla::ipc::UnixSocketConsumer
 {
 public:
   ~BluetoothScoManager();
 
   static BluetoothScoManager* Get();
-  void ReceiveSocketData(mozilla::ipc::UnixSocketRawData* aMessage)
+  void ReceiveSocketData(nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage)
     MOZ_OVERRIDE;
 
   bool Connect(const nsAString& aDeviceObjectPath);
   void Disconnect();
   bool Listen();
 
 private:
   friend class BluetoothScoManagerObserver;
--- a/ipc/unixsocket/UnixSocket.h
+++ b/ipc/unixsocket/UnixSocket.h
@@ -148,17 +148,17 @@ public:
   }
 
   /**
    * Function to be called whenever data is received. This is only called on the
    * main thread.
    *
    * @param aMessage Data received from the socket.
    */
-  virtual void ReceiveSocketData(UnixSocketRawData* aMessage) = 0;
+  virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) = 0;
 
   /**
    * Queue data to be sent to the socket. Can only be called on the IO thread.
    *
    * @param aImpl Implementation to send the data on.
    * @param aData Data to be sent to the socket.
    */
   static void RawSendSocketData(UnixSocketImpl* aImpl, UnixSocketRawData* aData);