Bug 970713 - Add 'Start Debug Mode' button to about:webrtc. r=smaug, r=Unfocused, r=jesup

This commit is contained in:
Jan-Ivar Bruaroey 2014-06-08 21:00:12 -04:00
parent af0b5dd5d3
commit 8b459224fd
4 changed files with 57 additions and 3 deletions

View File

@ -21,6 +21,14 @@ interface WebrtcGlobalInformation {
[Throws]
static void getLogging(DOMString pattern,
WebrtcGlobalLoggingCallback callback);
// NSPR WebRTC Trace debug level (0 - 65535)
//
// Notes:
// - Setting a non-zero debug level turns on gathering of log for file output.
// - Subsequently setting a zero debug level writes that log to disk.
static attribute long debugLevel;
};

View File

@ -8,7 +8,7 @@
#include <string>
#include "CSFLog.h"
#include "WebRtcLog.h"
#include "mozilla/dom/WebrtcGlobalInformationBinding.h"
#include "nsAutoPtr.h"
@ -232,6 +232,21 @@ WebrtcGlobalInformation::GetLogging(
aRv = rv;
}
static int32_t sLastSetLevel = 0;
void
WebrtcGlobalInformation::SetDebugLevel(const GlobalObject& aGlobal, int32_t aLevel)
{
StartWebRtcLog(webrtc::TraceLevel(aLevel));
sLastSetLevel = aLevel;
}
int32_t
WebrtcGlobalInformation::DebugLevel(const GlobalObject& aGlobal)
{
return sLastSetLevel;
}
struct StreamResult {
StreamResult() : candidateTypeBitpattern(0), streamSucceeded(false) {}
uint8_t candidateTypeBitpattern;

View File

@ -33,6 +33,9 @@ public:
WebrtcGlobalLoggingCallback& aLoggingCallback,
ErrorResult& aRv);
static void SetDebugLevel(const GlobalObject& aGlobal, int32_t aLevel);
static int32_t DebugLevel(const GlobalObject& aGlobal);
static void StoreLongTermICEStatistics(sipcc::PeerConnectionImpl& aPc);
private:

View File

@ -384,13 +384,41 @@ function displayStats(globalReport) {
});
}
function onLoad() {
WebrtcGlobalInformation.getAllStats(displayStats);
if (WebrtcGlobalInformation.debugLevel) {
setDebugButton(true);
} else {
setDebugButton(false);
}
}
function startDebugMode() {
WebrtcGlobalInformation.debugLevel = 65535;
setDebugButton(true);
}
function stopDebugMode() {
WebrtcGlobalInformation.debugLevel = 0;
setDebugButton(false);
}
function setDebugButton(on) {
var button = document.getElementById("debug-toggle-button");
button.innerHTML = on ? "Stop debug mode" : "Start debug mode";
button.onclick = on ? stopDebugMode : startDebugMode;
}
</script>
<body id="body" onload="WebrtcGlobalInformation.getAllStats(displayStats)">
<body id="body" onload="onLoad()">
<div id="stats">
</div>
<button onclick="WebrtcGlobalInformation.getLogging('', displayLogs)">
Show/refresh logging
Connection log
</button>
<button id="debug-toggle-button" onclick="startDebugMode()">
Start debug mode
</button>
<div id="logs">
</div>