Bug 1022498 - Patch1: Passing nsresult while using Promise::MaybeReject, r=btian
authorJocelyn Liu <joliu@mozilla.com>
Mon, 09 Jun 2014 16:22:27 +0800
changeset 206793 d4702c721d802e5620e5c5a1260f3ddb25f90037
parent 206792 7eed0d4a0424594430817fa9ee15142608f3002b
child 206794 d8bcbb0d8cc495418700c4f508cda13fef1f0f30
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1022498
milestone32.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 1022498 - Patch1: Passing nsresult while using Promise::MaybeReject, r=btian
dom/bluetooth2/BluetoothAdapter.cpp
--- a/dom/bluetooth2/BluetoothAdapter.cpp
+++ b/dom/bluetooth2/BluetoothAdapter.cpp
@@ -19,19 +19,16 @@
 #include "mozilla/LazyIdleThread.h"
 
 #include "BluetoothAdapter.h"
 #include "BluetoothDevice.h"
 #include "BluetoothReplyRunnable.h"
 #include "BluetoothService.h"
 #include "BluetoothUtils.h"
 
-#define ERR_INVALID_ADAPTER_STATE "InvalidAdapterStateError"
-#define ERR_CHANGE_ADAPTER_STATE  "ChangeAdapterStateError"
-
 using namespace mozilla;
 using namespace mozilla::dom;
 
 USING_BLUETOOTH_NAMESPACE
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothAdapter)
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(BluetoothAdapter,
@@ -716,39 +713,39 @@ BluetoothAdapter::EnableDisable(bool aEn
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   NS_ENSURE_TRUE(global, nullptr);
 
   nsRefPtr<Promise> promise = new Promise(global);
 
   // Make sure BluetoothService is available before modifying adapter state
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
-    promise->MaybeReject(ERR_CHANGE_ADAPTER_STATE);
+    promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
     return promise.forget();
   }
 
   if (aEnable) {
     if (mState != BluetoothAdapterState::Disabled) {
-      promise->MaybeReject(ERR_INVALID_ADAPTER_STATE);
+      promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
       return promise.forget();
     }
     mState = BluetoothAdapterState::Enabling;
   } else {
     if (mState != BluetoothAdapterState::Enabled) {
-      promise->MaybeReject(ERR_INVALID_ADAPTER_STATE);
+      promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
       return promise.forget();
     }
     mState = BluetoothAdapterState::Disabling;
   }
 
   // TODO: Fire attr changed event for this state change
   nsRefPtr<BluetoothReplyRunnable> result = new EnableDisableAdapterTask(promise);
 
   if(NS_FAILED(bs->EnableDisable(aEnable, result))) {
-    promise->MaybeReject(ERR_CHANGE_ADAPTER_STATE);
+    promise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
   }
 
   return promise.forget();
 }
 
 already_AddRefed<Promise>
 BluetoothAdapter::Enable()
 {