Bug 831623: Move handleSymbolResponse and fetchSymbol to a new class so it can be used for late write stacks too. r=vdjeric

This commit is contained in:
Rafael Avila de Espindola 2013-01-19 19:26:05 -05:00
Родитель 502c1025d7
Коммит 89e5bcee7e
2 изменённых файлов: 50 добавлений и 35 удалений

Просмотреть файл

@ -324,6 +324,33 @@ let StackRenderer = {
}
};
function SymbolicationRequest(aPrefix, aRenderHeader, aMemoryMap, aStacks) {
this.prefix = aPrefix;
this.renderHeader = aRenderHeader;
this.memoryMap = aMemoryMap;
this.stacks = aStacks;
}
SymbolicationRequest.prototype.handleSymbolResponse = function() {
StackRenderer.renderSymbolicatedStacks(this.prefix, this.symbolRequest,
this.renderHeader);
};
SymbolicationRequest.prototype.fetchSymbols = function() {
let symbolServerURI =
getPref(PREF_SYMBOL_SERVER_URI, DEFAULT_SYMBOL_SERVER_URI);
let request = {"memoryMap" : this.memoryMap, "stacks" : this.stacks,
"version" : 3};
let requestJSON = JSON.stringify(request);
this.symbolRequest = XMLHttpRequest();
this.symbolRequest.open("POST", symbolServerURI, true);
this.symbolRequest.setRequestHeader("Content-type", "application/json");
this.symbolRequest.setRequestHeader("Content-length",
requestJSON.length);
this.symbolRequest.setRequestHeader("Connection", "close");
this.symbolRequest.onreadystatechange = this.handleSymbolResponse.bind(this);
this.symbolRequest.send(requestJSON);
}
let ChromeHangs = {
symbolRequest: null,
@ -360,39 +387,6 @@ let ChromeHangs = {
div.appendChild(titleElement);
div.appendChild(document.createElement("br"));
},
/**
* Sends a symbolication request for the recorded hangs
*/
fetchSymbols: function ChromeHangs_fetchSymbols() {
let symbolServerURI =
getPref(PREF_SYMBOL_SERVER_URI, DEFAULT_SYMBOL_SERVER_URI);
let hangs = Telemetry.chromeHangs;
let memoryMap = hangs.memoryMap;
let stacks = hangs.stacks;
let request = {"memoryMap" : memoryMap, "stacks" : stacks,
"version" : 3};
let requestJSON = JSON.stringify(request);
this.symbolRequest = XMLHttpRequest();
this.symbolRequest.open("POST", symbolServerURI, true);
this.symbolRequest.setRequestHeader("Content-type", "application/json");
this.symbolRequest.setRequestHeader("Content-length", requestJSON.length);
this.symbolRequest.setRequestHeader("Connection", "close");
this.symbolRequest.onreadystatechange = this.handleSymbolResponse.bind(this);
this.symbolRequest.send(requestJSON);
},
/**
* Called when the 'readyState' of the XMLHttpRequest changes. We only care
* about state 4 ("completed") - handling the response data.
*/
handleSymbolResponse: function ChromeHangs_handleSymbolResponse() {
StackRenderer.renderSymbolicatedStacks("chrome-hangs", this.symbolRequest,
this.renderHangHeader);
}
};
@ -662,7 +656,11 @@ function setupListeners() {
document.getElementById("chrome-hangs-fetch-symbols").addEventListener("click",
function () {
ChromeHangs.fetchSymbols();
let hangs = Telemetry.chromeHangs;
let req = new SymbolicationRequest("chrome-hangs",
ChromeHangs.renderHangHeader,
hangs.memoryMap, hangs.stacks);
req.fetchSymbols();
}, false);
document.getElementById("chrome-hangs-hide-symbols").addEventListener("click",
@ -670,6 +668,22 @@ function setupListeners() {
ChromeHangs.render();
}, false);
document.getElementById("late-writes-fetch-symbols").addEventListener("click",
function () {
let lateWrites = TelemetryPing.getPayload().lateWrites;
let req = new SymbolicationRequest("late-writes", function() {},
lateWrites.memoryMap,
lateWrites.stacks);
req.fetchSymbols();
}, false);
document.getElementById("late-writes-hide-symbols").addEventListener("click",
function () {
let ping = TelemetryPing.getPayload();
LateWritesSingleton.renderLateWrites(ping.lateWrites);
}, false);
// Clicking on the section name will toggle its state
let sectionHeaders = document.getElementsByClassName("section-name");
for (let sectionHeader of sectionHeaders) {

Просмотреть файл

@ -87,7 +87,8 @@
<span class="toggle-caption hidden">&aboutTelemetry.toggleOff;</span>
<span class="empty-caption hidden">&aboutTelemetry.emptySection;</span>
<div id="late-writes" class="data hidden">
<!-- FIXME: add fetch-symbols and hide-symbols -->
<a id="late-writes-fetch-symbols" href="javascript:">&aboutTelemetry.fetchSymbols;</a>
<a id="late-writes-hide-symbols" class="hidden" href="javascript:">&aboutTelemetry.hideSymbols;</a>
<br/>
<br/>
<div id="late-writes-data">