Bug 1041440: Create Promise using |Promise::Create|, r=btian
authorThomas Zimmermann <tdz@users.sourceforge.net>
Mon, 21 Jul 2014 12:41:29 +0200
changeset 195246 753d801d019a4508cb7e92c172d175bccbd09041
parent 195245 2165a6295412f700353e4dae1be0155b438fdb0a
child 195247 9397d4794199879c95363b379484cc724d443d48
push id9083
push usertdz@users.sourceforge.net
push dateMon, 21 Jul 2014 10:46:31 +0000
treeherderb2g-inbound@753d801d019a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1041440
milestone33.0a1
Bug 1041440: Create Promise using |Promise::Create|, r=btian This patch fixes a call to the private constructor of |Promise|.
dom/bluetooth2/BluetoothAdapter.cpp
--- a/dom/bluetooth2/BluetoothAdapter.cpp
+++ b/dom/bluetooth2/BluetoothAdapter.cpp
@@ -452,17 +452,20 @@ BluetoothAdapter::StartDiscovery(ErrorRe
 already_AddRefed<Promise>
 BluetoothAdapter::StopDiscovery(ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   if (!global) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
-  nsRefPtr<Promise> promise = new Promise(global);
+  nsRefPtr<Promise> promise = Promise::Create(global, aRv);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
 
   /**
    * Ensure
    * - adapter is discovering,
    * - adapter is already enabled, and
    * - BluetoothService is available
    */
   BT_ENSURE_TRUE_RESOLVE(mDiscovering, JS::UndefinedHandleValue);