Bug 924651 - Log crashes as a telemetry completion reason in BackgroundPageThumbs. r=markh,froydnj
authorDrew Willcoxon <adw@mozilla.com>
Wed, 09 Oct 2013 10:13:01 -0700
changeset 150197 15bab6ba175d454a65a86479d937b5eb1c0d23c7
parent 150196 da9f409953d53453b507eb2d9e1b85223bf64a97
child 150198 daa8fbedef2f42f80a640296d3a86a99dc350199
push id25426
push userryanvm@gmail.com
push dateWed, 09 Oct 2013 19:23:34 +0000
treeherdermozilla-central@10824701bc80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh, froydnj
bugs924651
milestone27.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 924651 - Log crashes as a telemetry completion reason in BackgroundPageThumbs. r=markh,froydnj
toolkit/components/telemetry/Histograms.json
toolkit/components/thumbnails/BackgroundPageThumbs.jsm
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4109,19 +4109,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 = () => {