Bug 906990: Part 14. Catch exceptions thrown by getStats, since this can fail in fairly innocuous circumstances. Also, do a better job of error reporting when the stats API is used on a closed PeerConnection. r=ekr, r=jib

This commit is contained in:
Byron Campen [:bwc] 2014-01-09 16:03:19 -08:00
parent 4fcc56263b
commit 5f879bcd8d
2 changed files with 8 additions and 2 deletions

View File

@ -120,8 +120,10 @@ GlobalPCList.prototype = {
getStatsForEachPC: function(callback, errorCallback) {
function getStatsFromPC(pcref) {
if (pcref.get()) {
try {
pcref.get().getStatsInternal(null, callback, errorCallback);
} catch (e) {
errorCallback("Some error getting stats from PC: " + e.toString());
}
}
@ -135,6 +137,8 @@ GlobalPCList.prototype = {
}
},
// TODO(bcampen@mozilla.com): Handle this with a global object in c++
// (Bug 958221)
getLoggingFromFirstPC: function(pattern, callback, errorCallback) {
for (let winId in this._list) {
this.removeNullRefs(winId);
@ -158,6 +162,8 @@ WebrtcGlobalInformation.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
getAllStats: function(successCallback, failureCallback) {
// TODO(bcampen@mozilla.com): Move the work of fanout into c++, and
// only callback once. (Bug 958221)
if (_globalPCList) {
_globalPCList.getStatsForEachPC(successCallback, failureCallback);
} else {

View File

@ -1343,7 +1343,7 @@ PeerConnectionImpl::GetStats(MediaStreamTrack *aSelector, bool internalStats) {
NS_IMETHODIMP
PeerConnectionImpl::GetLogging(const nsAString& aPattern) {
PC_AUTO_ENTER_API_CALL(true);
PC_AUTO_ENTER_API_CALL_NO_CHECK();
#ifdef MOZILLA_INTERNAL_API
std::string pattern(NS_ConvertUTF16toUTF8(aPattern).get());