Bug 798035 - Patch 2: Bluetooth SCOManager Cleanup; r=gyeh
authorKyle Machulis <kyle@nonpolynomial.com>
Fri, 05 Oct 2012 19:16:43 -0700
changeset 109513 b7731c744c7f0ef3727e642fba2805013c0d4b48
parent 109512 a170f959971e48a750892ada96d1d922c930d3f9
child 109514 bc36c86d2d27da32f99021e780762a29919d58a6
push idunknown
push userunknown
push dateunknown
reviewersgyeh
bugs798035
milestone18.0a1
Bug 798035 - Patch 2: Bluetooth SCOManager Cleanup; r=gyeh
dom/bluetooth/BluetoothScoManager.cpp
--- a/dom/bluetooth/BluetoothScoManager.cpp
+++ b/dom/bluetooth/BluetoothScoManager.cpp
@@ -52,17 +52,16 @@ public:
 };
 
 NS_IMPL_ISUPPORTS1(BluetoothScoManagerObserver, nsIObserver)
 
 namespace {
 StaticRefPtr<BluetoothScoManager> gBluetoothScoManager;
 StaticAutoPtr<BluetoothScoManagerObserver> sScoObserver;
 bool gInShutdown = false;
-static nsCOMPtr<nsIThread> sScoCommandThread;
 } // anonymous namespace
 
 NS_IMETHODIMP
 BluetoothScoManagerObserver::Observe(nsISupports* aSubject,
                                      const char* aTopic,
                                      const PRUnichar* aData)
 {
   MOZ_ASSERT(gBluetoothScoManager);
@@ -77,57 +76,38 @@ BluetoothScoManagerObserver::Observe(nsI
 BluetoothScoManager::BluetoothScoManager()
   : mConnected(false)
 {
 }
 
 bool
 BluetoothScoManager::Init()
 {
-
-  if (!sScoCommandThread &&
-      NS_FAILED(NS_NewThread(getter_AddRefs(sScoCommandThread)))) {
-    NS_ERROR("Failed to new thread for sScoCommandThread");
-    return false;
-  }
   sScoObserver = new BluetoothScoManagerObserver();
   return true;
 }
 
 BluetoothScoManager::~BluetoothScoManager()
 {
   Cleanup();
 }
 
 void
 BluetoothScoManager::Cleanup()
 {
-  // Shut down the command thread if it still exists.
-  if (sScoCommandThread) {
-    nsCOMPtr<nsIThread> thread;
-    sScoCommandThread.swap(thread);
-    if (NS_FAILED(thread->Shutdown())) {
-      NS_WARNING("Failed to shut down the bluetooth hfpmanager command thread!");
-    }
-  }
   sScoObserver = nullptr;
 }
 
 //static
 BluetoothScoManager*
 BluetoothScoManager::Get()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // If we already exist, exit early
-  if (!gBluetoothScoManager) {
-    return gBluetoothScoManager;
-  }
-
-  // If we already exist, exit early
   if (gBluetoothScoManager) {
     return gBluetoothScoManager;
   }
 
   // If we're in shutdown, don't create a new instance
   if (gInShutdown) {
     NS_WARNING("BluetoothScoManager can't be created during shutdown");
     return nullptr;