Bug 838164 - Add a pretty headers to late write stacks. r=vladan.
authorRafael Ávila de Espíndola <respindola@mozilla.org>
Wed, 06 Feb 2013 16:41:30 -0500
changeset 130937 3677d52d74a0129004539bcbd4faae474eb69b75
parent 130936 c71474d33f6357bce04e75a2609338f49824b4d5
child 130938 a4b75cd17e1c6d2b9eded7c158244f372f1a6951
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs838164
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 838164 - Add a pretty headers to late write stacks. r=vladan.
toolkit/content/aboutTelemetry.css
toolkit/content/aboutTelemetry.js
toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
--- a/toolkit/content/aboutTelemetry.css
+++ b/toolkit/content/aboutTelemetry.css
@@ -58,17 +58,17 @@ h2 {
   font-style: italic;
   cursor: pointer;
 }
 
 .empty-caption {
   font-style: italic;
 }
 
-.hang-title {
+.stack-title {
   font-size: medium;
   font-weight: bold;
   text-decoration: underline;
 }
 
 #histograms, #addon-histograms {
   overflow: hidden;
 }
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -281,16 +281,36 @@ let StackRenderer = {
     this.renderMemoryMap(div, aMemoryMap);
 
     for (let i = 0; i < aStacks.length; ++i) {
       let stack = aStacks[i];
       aRenderHeader(i);
       this.renderStack(div, stack)
     }
   },
+
+  /**
+   * Renders the title of the stack: e.g. "Late Write #1" or
+   * "Hang Report #1 (6 seconds)".
+   *
+   * @param aFormatArgs formating args to be passed to formatStringFromName.
+   */
+  renderHeader: function StackRenderer_renderHeader(aPrefix, aFormatArgs) {
+    let div = document.getElementById(aPrefix + "-data");
+
+    let titleElement = document.createElement("span");
+    titleElement.className = "stack-title";
+
+    let titleText = bundle.formatStringFromName(
+      aPrefix + "-title", aFormatArgs, aFormatArgs.length);
+    titleElement.appendChild(document.createTextNode(titleText));
+
+    div.appendChild(titleElement);
+    div.appendChild(document.createElement("br"));
+  }
 };
 
 function SymbolicationRequest(aPrefix, aRenderHeader, aMemoryMap, aStacks) {
   this.prefix = aPrefix;
   this.renderHeader = aRenderHeader;
   this.memoryMap = aMemoryMap;
   this.stacks = aStacks;
 }
@@ -367,36 +387,19 @@ let ChromeHangs = {
     let hangs = Telemetry.chromeHangs;
     let stacks = hangs.stacks;
     let memoryMap = hangs.memoryMap;
 
     StackRenderer.renderStacks("chrome-hangs", stacks, memoryMap,
 			       this.renderHangHeader);
   },
 
-  /**
-   * Renders the title of the hang: e.g. "Hang Report #1 (6 seconds)"
-   *
-   * @param aDiv Output div
-   * @param aIndex The number of the hang
-   * @param aDuration The duration of the hang
-   */
   renderHangHeader: function ChromeHangs_renderHangHeader(aIndex) {
-    let div = document.getElementById("chrome-hangs-data");
-
-    let titleElement = document.createElement("span");
-    titleElement.className = "hang-title";
-
     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"));
+    StackRenderer.renderHeader("chrome-hangs", [aIndex + 1, durations[aIndex]]);
   }
 };
 
 let Histogram = {
 
   hgramSamplesCaption: bundle.GetStringFromName("histogramSamples"),
 
   hgramAverageCaption: bundle.GetStringFromName("histogramAverage"),
@@ -671,17 +674,18 @@ function setupListeners() {
   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() {},
+      let req = new SymbolicationRequest("late-writes",
+                                         LateWritesSingleton.renderHeader,
                                          lateWrites.memoryMap,
                                          lateWrites.stacks);
       req.fetchSymbols();
   }, false);
 
   document.getElementById("late-writes-hide-symbols").addEventListener("click",
     function () {
       let ping = TelemetryPing.getPayload();
@@ -743,21 +747,25 @@ function onLoad() {
     showEmptySectionMessage("addon-histograms-section");
   }
 
   // Get the Telemetry Ping payload
   Telemetry.asyncFetchTelemetryData(displayPingData);
 };
 
 let LateWritesSingleton = {
+  renderHeader: function LateWritesSingleton_renderHeader(aIndex) {
+    StackRenderer.renderHeader("late-writes", [aIndex + 1]);
+  },
+
   renderLateWrites: function LateWritesSingleton_renderLateWrites(lateWrites) {
     let stacks = lateWrites.stacks;
     let memoryMap = lateWrites.memoryMap;
-    function f() {}
-    StackRenderer.renderStacks('late-writes', stacks, memoryMap, f);
+    StackRenderer.renderStacks('late-writes', stacks, memoryMap,
+                               LateWritesSingleton.renderHeader);
   }
 };
 
 /**
  * Helper function for sorting the startup milestones in the Simple Measurements
  * section into temporal order.
  *
  * @param aSimpleMeasurements Telemetry ping's "Simple Measurements" data
--- a/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
+++ b/toolkit/locales/en-US/chrome/global/aboutTelemetry.properties
@@ -15,17 +15,21 @@ slowSqlHits = Hits
 
 slowSqlAverage = Avg. Time (ms)
 
 slowSqlStatement = Statement
 
 # Note to translators:
 # - The %1$S will be replaced with the number of the hang
 # - The %2$S will be replaced with the duration of the hang
-hangTitle = Hang Report #%1$S (%2$S seconds)
+chrome-hangs-title = Hang Report #%1$S (%2$S seconds)
+
+# Note to translators:
+# - The %1$S will be replaced with the number of the hang
+late-writes-title = Late Write #%1$S
 
 stackTitle = Stack:
 
 memoryMapTitle = Memory map:
 
 errorFetchingSymbols = An error occurred while fetching symbols. Check that you are connected to the Internet and try again.
 
 histogramSamples = samples