Bug 1137093 - Part 06: Refactor _isActive. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Tue, 24 Mar 2015 18:04:49 +0800
changeset 264429 f85ea6b494aff2b1f43db0da6572c5aa27bb009d
parent 264428 51e35cce870b6dc6d329b4532f3f84cbdaf10585
child 264430 614fb637c4c9af1e93df0e870ee956c2e291e25f
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1137093
milestone39.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 1137093 - Part 06: Refactor _isActive. r=hsinyi
dom/telephony/gonk/TelephonyService.js
--- a/dom/telephony/gonk/TelephonyService.js
+++ b/dom/telephony/gonk/TelephonyService.js
@@ -477,26 +477,26 @@ TelephonyService.prototype = {
         numCalls++;
       }
     }
 
     return hasConference ? numCalls + 1 : numCalls;
   },
 
   /**
-   * Get arbitrary one of active call.
+   * Is there an active call?
    */
-  _getOneActiveCall: function(aClientId) {
+  _isActive: function(aClientId) {
     for (let index in this._currentCalls[aClientId]) {
       let call = this._currentCalls[aClientId][index];
       if (call.state === nsITelephonyService.CALL_STATE_CONNECTED) {
-        return call;
+        return true;
       }
     }
-    return null;
+    return false;
   },
 
   /**
    * Dial number. Perform call setup or SS procedure accordingly.
    *
    * @see 3GPP TS 22.030 Figure 3.5.3.2
    */
   dial: function(aClientId, aNumber, aIsDialEmergency, aCallback) {
@@ -648,18 +648,17 @@ TelephonyService.prototype = {
 
     let options = {
       isEmergency: isEmergency,
       number: aNumber,
       clirMode: aClirMode
     };
 
     // No active call. Dial it out directly.
-    let activeCall = this._getOneActiveCall(aClientId);
-    if (!activeCall) {
+    if (!this._isActive(aClientId)) {
       this._sendDialCallRequest(aClientId, options, aCallback);
       return;
     }
 
     // CDMA 3-way calling.
     if (this._isCdmaClient(aClientId)) {
       this._dialCdmaThreeWayCall(aClientId, aNumber, aCallback);
       return;
@@ -1361,17 +1360,17 @@ TelephonyService.prototype = {
       call.name = pick(aCall.name, "");
       call.numberPresentaation = pick(aCall.numberPresentation, nsITelephonyService.CALL_PRESENTATION_ALLOWED);
       call.namePresentaation = pick(aCall.namePresentation, nsITelephonyService.CALL_PRESENTATION_ALLOWED);
 
       this._currentCalls[aClientId][aCall.callIndex] = call;
     }
 
     // Handle cached dial request.
-    if (this._cachedDialRequest && !this._getOneActiveCall(aClientId)) {
+    if (this._cachedDialRequest && !this._isActive(aClientId)) {
       if (DEBUG) debug("All calls held. Perform the cached dial request.");
 
       let request = this._cachedDialRequest;
       this._sendDialCallRequest(request.clientId, request.options, request.callback);
       this._cachedDialRequest = null;
     }
 
     let callInfo = new TelephonyCallInfo(call);