Bug 773563 - Cleanup BTA_detach callers to avoid redundant state checks; r=robcee

This commit is contained in:
Panos Astithas 2013-12-16 21:27:00 +02:00
parent 3c4faf6777
commit c5250fd127

View File

@ -606,8 +606,7 @@ BrowserTabActor.prototype = {
return;
}
if (this.attached) {
this._detach();
if (this._detach()) {
this.conn.send({ from: this.actorID,
type: "tabDetached" });
}
@ -675,10 +674,12 @@ BrowserTabActor.prototype = {
/**
* Does the actual work of detaching from a tab.
*
* @returns false if the tab wasn't attached or true of detahing succeeds.
*/
_detach: function BTA_detach() {
if (!this.attached) {
return;
return false;
}
if (this._progressListener) {
@ -699,6 +700,7 @@ BrowserTabActor.prototype = {
}
this._attached = false;
return true;
},
// Protocol Request Handlers
@ -714,12 +716,10 @@ BrowserTabActor.prototype = {
},
onDetach: function BTA_onDetach(aRequest) {
if (!this.attached) {
if (!this._detach()) {
return { error: "wrongState" };
}
this._detach();
return { type: "detached" };
},