Bug 799243 - Patch 2: Fix static nsTArray initialization in BluetoothDBusService; r=echou
authorKyle Machulis <kyle@nonpolynomial.com>
Mon, 08 Oct 2012 22:00:02 -0700
changeset 109723 66f9632e35390f9037ebdba9e6c386ad1ca468c9
parent 109722 d01545bde6644b46c9bb69c94daece593c840e2d
child 109724 dd61540f237caed9b66e05419ecc200ef6f1f51d
push id23648
push useremorley@mozilla.com
push dateTue, 09 Oct 2012 14:23:49 +0000
treeherdermozilla-central@dd61540f237c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs799243
milestone19.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 799243 - Patch 2: Fix static nsTArray initialization in BluetoothDBusService; r=echou
dom/bluetooth/linux/BluetoothDBusService.cpp
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -145,18 +145,16 @@ static const char* sBluetoothDBusSignals
 /**
  * DBus Connection held for the BluetoothCommandThread to use. Should never be
  * used by any other thread.
  *
  */
 static nsAutoPtr<RawDBusConnection> gThreadConnection;
 static nsDataHashtable<nsStringHashKey, DBusMessage* > sPairingReqTable;
 static nsDataHashtable<nsStringHashKey, DBusMessage* > sAuthorizeReqTable;
-static nsTArray<uint32_t> sServiceHandles;
-
 typedef void (*UnpackFunc)(DBusMessage*, DBusError*, BluetoothValue&, nsAString&);
 
 class DistributeBluetoothSignalTask : public nsRunnable {
   BluetoothSignal mSignal;
 public:
   DistributeBluetoothSignalTask(const BluetoothSignal& aSignal) :
     mSignal(aSignal)
   {
@@ -763,20 +761,25 @@ public:
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
     nsTArray<uint32_t> uuids;
 
     uuids.AppendElement((uint32_t)(BluetoothServiceUuid::HandsfreeAG >> 32));
     uuids.AppendElement((uint32_t)(BluetoothServiceUuid::HeadsetAG >> 32));
 
-    sServiceHandles.Clear();
-    if (!BluetoothDBusService::AddReservedServicesInternal(mPath, uuids, sServiceHandles)) {
+    // TODO/qdot: This needs to be held for the life of the bluetooth connection
+    // so we could clean it up. For right now though, we can throw it away.
+    nsTArray<uint32_t> handles;
+
+    if (!BluetoothDBusService::AddReservedServicesInternal(mPath, uuids, handles)) {
       NS_WARNING("Failed to add reserved services");
+#ifdef MOZ_WIDGET_GONK
       return NS_ERROR_FAILURE;
+#endif
     }
 
     if(!RegisterAgent(mPath)) {
       NS_WARNING("Failed to register agent");
       return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
@@ -2251,16 +2254,17 @@ BluetoothDBusService::Disconnect(const u
 
   // Currently, just fire success because Disconnect() doesn't fail, 
   // but we still make aRunnable pass into this function for future
   // once Disconnect will fail.
   nsString replyError;
   BluetoothValue v = true;
   DispatchBluetoothReply(aRunnable, v, replyError);
 }
+
 class CreateBluetoothScoSocket : public nsRunnable
 {
 public: 
   CreateBluetoothScoSocket(UnixSocketConsumer* aConsumer,
                            const nsAString& aObjectPath,
                            bool aAuth,
                            bool aEncrypt)
     : mConsumer(aConsumer),