зеркало из https://github.com/mozilla/gecko-dev.git
Bug 861718 - Friendly error about PeerConnection missing in Offline mode. r=jesup
This commit is contained in:
Родитель
6e44758482
Коммит
9f4b6ef454
|
@ -272,7 +272,7 @@ PeerConnection.prototype = {
|
|||
|
||||
// Nothing starts until ICE gathering completes.
|
||||
this._queueOrRun({
|
||||
func: this._pc.initialize,
|
||||
func: this._getPC().initialize,
|
||||
args: [this._observer, win, rtcConfig, Services.tm.currentThread],
|
||||
wait: true
|
||||
});
|
||||
|
@ -285,6 +285,13 @@ PeerConnection.prototype = {
|
|||
_globalPCList.addPC(this);
|
||||
},
|
||||
|
||||
_getPC: function() {
|
||||
if (!this._pc) {
|
||||
throw new Components.Exception("PeerConnection is gone (did you turn on Offline mode?)");
|
||||
}
|
||||
return this._pc;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a function to the queue or run it immediately if the queue is empty.
|
||||
* Argument is an object with the func, args and wait properties; wait should
|
||||
|
@ -467,7 +474,7 @@ PeerConnection.prototype = {
|
|||
this._onCreateOfferFailure = onError;
|
||||
|
||||
this._queueOrRun({
|
||||
func: this._pc.createOffer,
|
||||
func: this._getPC().createOffer,
|
||||
args: [constraints],
|
||||
wait: true
|
||||
});
|
||||
|
@ -493,7 +500,7 @@ PeerConnection.prototype = {
|
|||
|
||||
// TODO: Implement provisional answer.
|
||||
|
||||
this._pc.createAnswer(constraints);
|
||||
this._getPC().createAnswer(constraints);
|
||||
},
|
||||
|
||||
createAnswer: function(onSuccess, onError, constraints, provisional) {
|
||||
|
@ -536,7 +543,7 @@ PeerConnection.prototype = {
|
|||
}
|
||||
|
||||
this._queueOrRun({
|
||||
func: this._pc.setLocalDescription,
|
||||
func: this._getPC().setLocalDescription,
|
||||
args: [type, desc.sdp],
|
||||
wait: true,
|
||||
type: desc.type
|
||||
|
@ -565,7 +572,7 @@ PeerConnection.prototype = {
|
|||
}
|
||||
|
||||
this._queueOrRun({
|
||||
func: this._pc.setRemoteDescription,
|
||||
func: this._getPC().setRemoteDescription,
|
||||
args: [type, desc.sdp],
|
||||
wait: true,
|
||||
type: desc.type
|
||||
|
@ -589,7 +596,7 @@ PeerConnection.prototype = {
|
|||
this._onAddIceCandidateError = onError;
|
||||
|
||||
this._queueOrRun({
|
||||
func: this._pc.addIceCandidate,
|
||||
func: this._getPC().addIceCandidate,
|
||||
args: [cand.candidate, cand.sdpMid || "", cand.sdpMLineIndex],
|
||||
wait: true
|
||||
});
|
||||
|
@ -598,7 +605,7 @@ PeerConnection.prototype = {
|
|||
addStream: function(stream, constraints) {
|
||||
// TODO: Implement constraints.
|
||||
this._queueOrRun({
|
||||
func: this._pc.addStream,
|
||||
func: this._getPC().addStream,
|
||||
args: [stream],
|
||||
wait: false
|
||||
});
|
||||
|
@ -611,7 +618,7 @@ PeerConnection.prototype = {
|
|||
|
||||
close: function() {
|
||||
this._queueOrRun({
|
||||
func: this._pc.close,
|
||||
func: this._getPC().close,
|
||||
args: [false],
|
||||
wait: false
|
||||
});
|
||||
|
@ -620,17 +627,17 @@ PeerConnection.prototype = {
|
|||
|
||||
get localStreams() {
|
||||
this._checkClosed();
|
||||
return this._pc.localStreams;
|
||||
return this._getPC().localStreams;
|
||||
},
|
||||
|
||||
get remoteStreams() {
|
||||
this._checkClosed();
|
||||
return this._pc.remoteStreams;
|
||||
return this._getPC().remoteStreams;
|
||||
},
|
||||
|
||||
get localDescription() {
|
||||
this._checkClosed();
|
||||
let sdp = this._pc.localDescription;
|
||||
let sdp = this._getPC().localDescription;
|
||||
if (sdp.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -642,7 +649,7 @@ PeerConnection.prototype = {
|
|||
|
||||
get remoteDescription() {
|
||||
this._checkClosed();
|
||||
let sdp = this._pc.remoteDescription;
|
||||
let sdp = this._getPC().remoteDescription;
|
||||
if (sdp.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -660,7 +667,7 @@ PeerConnection.prototype = {
|
|||
}
|
||||
|
||||
var state="undefined";
|
||||
switch (this._pc.readyState) {
|
||||
switch (this._getPC().readyState) {
|
||||
case Ci.IPeerConnection.kNew:
|
||||
state = "new";
|
||||
break;
|
||||
|
@ -707,7 +714,7 @@ PeerConnection.prototype = {
|
|||
}
|
||||
|
||||
// Synchronous since it doesn't block.
|
||||
let channel = this._pc.createDataChannel(
|
||||
let channel = this._getPC().createDataChannel(
|
||||
label, protocol, type, dict.outOfOrderAllowed, dict.maxRetransmitTime,
|
||||
dict.maxRetransmitNum, dict.preset ? true : false,
|
||||
dict.stream != undefined ? dict.stream : 0xFFFF
|
||||
|
@ -720,7 +727,7 @@ PeerConnection.prototype = {
|
|||
numstreams = 16;
|
||||
}
|
||||
this._queueOrRun({
|
||||
func: this._pc.connectDataConnection,
|
||||
func: this._getPC().connectDataConnection,
|
||||
args: [localport, remoteport, numstreams],
|
||||
wait: false
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче