Backed out changeset cfddd3baeb0b (bug 1077075)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 29 Dec 2014 10:30:19 +0100
changeset 221480 cded54c82fb12ad0e8164a792f51fd973ae0511d
parent 221479 a66c84f06cfec5d4950641cf6cbb1450051355a1
child 221481 9901b54d5ce743aaaa9f4308a7ef0b9db3969a0e
push id53352
push usercbook@mozilla.com
push dateMon, 29 Dec 2014 15:17:49 +0000
treeherdermozilla-inbound@8530f5b7443b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1077075
milestone37.0a1
backs outcfddd3baeb0b1538a7c5b7598e01473ab822055b
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
Backed out changeset cfddd3baeb0b (bug 1077075)
dom/telephony/TelephonyCall.cpp
dom/telephony/TelephonyCall.h
--- a/dom/telephony/TelephonyCall.cpp
+++ b/dom/telephony/TelephonyCall.cpp
@@ -221,145 +221,105 @@ TelephonyCall::GetError() const
 
 already_AddRefed<TelephonyCallGroup>
 TelephonyCall::GetGroup() const
 {
   nsRefPtr<TelephonyCallGroup> group = mGroup;
   return group.forget();
 }
 
-already_AddRefed<Promise>
+void
 TelephonyCall::Answer(ErrorResult& aRv)
 {
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
-  if (!global) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
+  if (mCallState != nsITelephonyService::CALL_STATE_INCOMING) {
+    NS_WARNING("Answer on non-incoming call ignored!");
+    return;
   }
 
-  nsRefPtr<Promise> promise = Promise::Create(global, aRv);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
-
-  if (mCallState != nsITelephonyService::CALL_STATE_INCOMING) {
-    NS_WARNING("Answer on non-incoming call is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
-  }
-
-  nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise);
-  aRv = mTelephony->Service()->AnswerCall(mServiceId, mCallIndex, callback);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
-
-  ChangeStateInternal(nsITelephonyService::CALL_STATE_CONNECTING, true);
-  return promise.forget();
-}
-
-already_AddRefed<Promise>
-TelephonyCall::HangUp(ErrorResult& aRv)
-{
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
-  if (!global) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
+  nsresult rv = mTelephony->Service()->AnswerCall(mServiceId, mCallIndex);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
   }
 
-  nsRefPtr<Promise> promise = Promise::Create(global, aRv);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
+  ChangeStateInternal(nsITelephonyService::CALL_STATE_CONNECTING, true);
+}
 
+void
+TelephonyCall::HangUp(ErrorResult& aRv)
+{
   if (mCallState == nsITelephonyService::CALL_STATE_DISCONNECTING ||
       mCallState == nsITelephonyService::CALL_STATE_DISCONNECTED) {
-    NS_WARNING("HangUp on previously disconnected call is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("HangUp on previously disconnected call ignored!");
+    return;
   }
 
-  nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise);
-  aRv = mCallState == nsITelephonyService::CALL_STATE_INCOMING ?
-    mTelephony->Service()->RejectCall(mServiceId, mCallIndex, callback) :
-    mTelephony->Service()->HangUpCall(mServiceId, mCallIndex, callback);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
+  nsresult rv = mCallState == nsITelephonyService::CALL_STATE_INCOMING ?
+                mTelephony->Service()->RejectCall(mServiceId, mCallIndex) :
+                mTelephony->Service()->HangUp(mServiceId, mCallIndex);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
 
   ChangeStateInternal(nsITelephonyService::CALL_STATE_DISCONNECTING, true);
-  return promise.forget();
 }
 
-already_AddRefed<Promise>
+void
 TelephonyCall::Hold(ErrorResult& aRv)
 {
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
-  if (!global) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsRefPtr<Promise> promise = Promise::Create(global, aRv);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
-
   if (mCallState != nsITelephonyService::CALL_STATE_CONNECTED) {
-    NS_WARNING("Hold non-connected call is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("Hold non-connected call ignored!");
+    return;
   }
 
   if (mGroup) {
-    NS_WARNING("Hold a call in conference is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("Hold a call in conference ignored!");
+    return;
   }
 
   if (!mSwitchable) {
-    NS_WARNING("Hold a non-switchable call is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("Hold a non-switchable call ignored!");
+    return;
   }
 
-  nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise);
-  aRv = mTelephony->Service()->HoldCall(mServiceId, mCallIndex, callback);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
+  nsresult rv = mTelephony->Service()->HoldCall(mServiceId, mCallIndex);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
 
   if (mSecondId) {
     // No state transition when we switch two numbers within one TelephonyCall
     // object. Otherwise, the state here will be inconsistent with the backend
     // RIL and will never be right.
-    return promise.forget();
+    return;
   }
 
   ChangeStateInternal(nsITelephonyService::CALL_STATE_HOLDING, true);
-  return promise.forget();
 }
 
-already_AddRefed<Promise>
+void
 TelephonyCall::Resume(ErrorResult& aRv)
 {
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
-  if (!global) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsRefPtr<Promise> promise = Promise::Create(global, aRv);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
-
   if (mCallState != nsITelephonyService::CALL_STATE_HELD) {
-    NS_WARNING("Resume non-held call is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("Resume non-held call ignored!");
+    return;
   }
 
   if (mGroup) {
-    NS_WARNING("Resume a call in conference is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("Resume a call in conference ignored!");
+    return;
   }
 
   if (!mSwitchable) {
-    NS_WARNING("Resume a non-switchable call is rejected!");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return promise.forget();
+    NS_WARNING("Resume a non-switchable call ignored!");
+    return;
   }
 
-  nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise);
-  aRv = mTelephony->Service()->ResumeCall(mServiceId, mCallIndex, callback);
-  NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
+  nsresult rv = mTelephony->Service()->ResumeCall(mServiceId, mCallIndex);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
 
   ChangeStateInternal(nsITelephonyService::CALL_STATE_RESUMING, true);
-  return promise.forget();
 }
--- a/dom/telephony/TelephonyCall.h
+++ b/dom/telephony/TelephonyCall.h
@@ -2,20 +2,21 @@
 /* vim: set ts=2 et sw=2 tw=40: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_telephony_telephonycall_h__
 #define mozilla_dom_telephony_telephonycall_h__
 
+#include "mozilla/dom/telephony/TelephonyCommon.h"
+
 #include "mozilla/dom/DOMError.h"
-#include "mozilla/dom/Promise.h"
-#include "mozilla/dom/TelephonyCallId.h"
-#include "mozilla/dom/telephony/TelephonyCommon.h"
+
+#include "TelephonyCallId.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 
 class TelephonyCall MOZ_FINAL : public DOMEventTargetHelper
 {
@@ -85,26 +86,26 @@ public:
   }
 
   already_AddRefed<DOMError>
   GetError() const;
 
   already_AddRefed<TelephonyCallGroup>
   GetGroup() const;
 
-  already_AddRefed<Promise>
+  void
   Answer(ErrorResult& aRv);
 
-  already_AddRefed<Promise>
+  void
   HangUp(ErrorResult& aRv);
 
-  already_AddRefed<Promise>
+  void
   Hold(ErrorResult& aRv);
 
-  already_AddRefed<Promise>
+  void
   Resume(ErrorResult& aRv);
 
   IMPL_EVENT_HANDLER(statechange)
   IMPL_EVENT_HANDLER(dialing)
   IMPL_EVENT_HANDLER(alerting)
   IMPL_EVENT_HANDLER(connecting)
   IMPL_EVENT_HANDLER(connected)
   IMPL_EVENT_HANDLER(disconnecting)