Bug 924651 - Log crashes as a telemetry completion reason in BackgroundPageThumbs. r=markh,froydnj, a=gavin
authorDrew Willcoxon <adw@mozilla.com>
Wed, 09 Oct 2013 10:13:01 -0700
changeset 160628 829a06f8d05834051152596dcaff866d04f526ec
parent 160627 86d2f433a7ca52d38e8b73981fbcc34b4ea6a578
child 160629 0b755d7d58e3ce345ec019fef258b2bcab89cb1c
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh, froydnj, gavin
bugs924651
milestone26.0a2
Bug 924651 - Log crashes as a telemetry completion reason in BackgroundPageThumbs. r=markh,froydnj, a=gavin
toolkit/components/telemetry/Histograms.json
toolkit/components/thumbnails/BackgroundPageThumbs.jsm
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -3951,19 +3951,19 @@
   },
   "FX_THUMBNAILS_BG_CAPTURE_SERVICE_TIME_MS": {
     "kind": "exponential",
     "high": 30000,
     "n_buckets": 20,
     "extended_statistics_ok": true,
     "description": "BACKGROUND THUMBNAILS: Time the capture took once it started and successfully completed (ms)"
   },
-  "FX_THUMBNAILS_BG_CAPTURE_DONE_REASON": {
+  "FX_THUMBNAILS_BG_CAPTURE_DONE_REASON_2": {
     "kind": "enumerated",
-    "n_values": 4,
+    "n_values": 10,
     "description": "BACKGROUND THUMBNAILS: Reason the capture completed (see TEL_CAPTURE_DONE_* constants in BackgroundPageThumbs.jsm)"
   },
   "FX_THUMBNAILS_BG_CAPTURE_PAGE_LOAD_TIME_MS": {
     "kind": "exponential",
     "high": 60000,
     "n_buckets": 20,
     "extended_statistics_ok": true,
     "description": "BACKGROUND THUMBNAILS: Time the capture's page load took (ms)"
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -14,20 +14,21 @@ const EXPORTED_SYMBOLS = [
 ];
 
 const DEFAULT_CAPTURE_TIMEOUT = 30000; // ms
 const DESTROY_BROWSER_TIMEOUT = 60000; // ms
 const FRAME_SCRIPT_URL = "chrome://global/content/backgroundPageThumbsContent.js";
 
 const TELEMETRY_HISTOGRAM_ID_PREFIX = "FX_THUMBNAILS_BG_";
 
-// possible FX_THUMBNAILS_BG_CAPTURE_DONE_REASON telemetry values
+// possible FX_THUMBNAILS_BG_CAPTURE_DONE_REASON_2 telemetry values
 const TEL_CAPTURE_DONE_OK = 0;
 const TEL_CAPTURE_DONE_TIMEOUT = 1;
 // 2 and 3 were used when we had special handling for private-browsing.
+const TEL_CAPTURE_DONE_CRASHED = 4;
 
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/PageThumbs.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
@@ -196,17 +197,17 @@ const BackgroundPageThumbs = {
       this._destroyBrowser();
       let curCapture = this._captureQueue.length ? this._captureQueue[0] : null;
       // we could retry the pending capture, but it's possible the crash
       // was due directly to it, so trying again might just crash again.
       // We could keep a flag to indicate if it previously crashed, but
       // "resetting" the capture requires more work - so for now, we just
       // discard it.
       if (curCapture && curCapture.pending) {
-        curCapture._done(null);
+        curCapture._done(null, TEL_CAPTURE_DONE_CRASHED);
         // _done automatically continues queue processing.
       }
       // else: we must have been idle and not currently doing a capture (eg,
       // maybe a GC or similar crashed) - so there's no need to attempt a
       // queue restart - the next capture request will set everything up.
     });
 
     browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
@@ -331,36 +332,37 @@ Capture.prototype = {
       delete this._msgMan;
     }
     delete this.captureCallback;
     Services.ww.unregisterNotification(this);
   },
 
   // Called when the didCapture message is received.
   receiveMessage: function (msg) {
-    tel("CAPTURE_DONE_REASON", TEL_CAPTURE_DONE_OK);
     tel("CAPTURE_SERVICE_TIME_MS", new Date() - this.startDate);
 
     // A different timed-out capture may have finally successfully completed, so
     // discard messages that aren't meant for this capture.
     if (msg.json.id == this.id)
-      this._done(msg.json);
+      this._done(msg.json, TEL_CAPTURE_DONE_OK);
   },
 
   // Called when the timeout timer fires.
   notify: function () {
-    tel("CAPTURE_DONE_REASON", TEL_CAPTURE_DONE_TIMEOUT);
-    this._done(null);
+    this._done(null, TEL_CAPTURE_DONE_TIMEOUT);
   },
 
-  _done: function (data) {
+  _done: function (data, reason) {
     // Note that _done will be called only once, by either receiveMessage or
     // notify, since it calls destroy, which cancels the timeout timer and
     // removes the didCapture message listener.
 
+    if (typeof(reason) != "number")
+      throw new Error("A done reason must be given.");
+    tel("CAPTURE_DONE_REASON_2", reason);
     if (data && data.telemetry) {
       // Telemetry is currently disabled in the content process (bug 680508).
       for (let id in data.telemetry) {
         tel(id, data.telemetry[id]);
       }
     }
 
     let done = () => {