Bug 831623: Move handleSymbolResponse and fetchSymbol to a new class so it can be used for late write stacks too. r=vdjeric
authorRafael Avila de Espindola <respindola@mozilla.com>
Sat, 19 Jan 2013 19:26:05 -0500
changeset 119377 077caacae057202aced93f84cfd423a0ecb71e37
parent 119376 68f8f4b74f63d074b042af1ff4052e4fb1513dda
child 119378 ca1f12ab55c89d24b0a0db572f95181f46d6b732
push id24197
push userryanvm@gmail.com
push dateSun, 20 Jan 2013 05:25:28 +0000
treeherdermozilla-central@1d122eaa9070 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvdjeric
bugs831623
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 831623: Move handleSymbolResponse and fetchSymbol to a new class so it can be used for late write stacks too. r=vdjeric
toolkit/content/aboutTelemetry.js
toolkit/content/aboutTelemetry.xhtml
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -319,16 +319,43 @@ let StackRenderer = {
         div.appendChild(document.createTextNode(symbol));
         div.appendChild(document.createElement("br"));
       }
       div.appendChild(document.createElement("br"));
     }
   }
 };
 
+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,
 
   /**
    * Renders raw chrome hang data
    */
   render: function ChromeHangs_render() {
@@ -355,49 +382,16 @@ let ChromeHangs = {
 
     let durations = Telemetry.chromeHangs.durations;
     let titleText = bundle.formatStringFromName(
       "hangTitle", [aIndex + 1, durations[aIndex]], 2);
     titleElement.appendChild(document.createTextNode(titleText));
 
     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);
   }
 };
 
 let Histogram = {
 
   hgramSamplesCaption: bundle.GetStringFromName("histogramSamples"),
 
   hgramAverageCaption: bundle.GetStringFromName("histogramAverage"),
@@ -657,24 +651,44 @@ function setupListeners() {
   document.getElementById("toggle-telemetry").addEventListener("click",
     function () {
       let value = getPref(PREF_TELEMETRY_ENABLED, false);
       Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, !value);
   }, false);
 
   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",
     function () {
       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) {
     sectionHeader.addEventListener("click", toggleSection, false);
   }
 
   // Clicking on the "collapse"/"expand" text will also toggle section's state
   let toggleLinks = document.getElementsByClassName("toggle-caption");
--- a/toolkit/content/aboutTelemetry.xhtml
+++ b/toolkit/content/aboutTelemetry.xhtml
@@ -82,17 +82,18 @@
     </section>
 
     <section id="late-writes-section" class="data-section">
       <h1 class="section-name">&aboutTelemetry.lateWritesSection;</h1>
       <span class="toggle-caption">&aboutTelemetry.toggleOn;</span>
       <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">
         </div>
       </div>
     </section>
 
     <section id="system-info-section" class="data-section">