Bug 913171 - Fix intermittent browser_thumbnails_background.js by finishing captures only after thumbnails are written. r=markh
authorDrew Willcoxon <adw@mozilla.com>
Wed, 11 Sep 2013 15:12:22 -0700
changeset 159601 8a3f175f8d75580744817397405ee31f4094db7e
parent 159600 b7a8703a187dea4e96945675fbd1b41b5ec3a4cf
child 159602 f2ee3eca887eeecc15a2a9a9a2d31c6d8c6f39c1
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
bugs913171
milestone26.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 913171 - Fix intermittent browser_thumbnails_background.js by finishing captures only after thumbnails are written. r=markh
toolkit/components/thumbnails/BackgroundPageThumbs.jsm
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -357,44 +357,43 @@ Capture.prototype = {
     this._done(null);
   },
 
   _done: function (data) {
     // 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.
 
-    this.captureCallback(this);
-    this.destroy();
-
     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 callOnDones = function callOnDonesFn() {
+    let done = () => {
+      this.captureCallback(this);
+      this.destroy();
       for (let callback of this.doneCallbacks) {
         try {
           callback.call(this.options, this.url);
         }
         catch (err) {
           Cu.reportError(err);
         }
       }
-    }.bind(this);
+    };
 
     if (!data) {
-      callOnDones();
+      done();
       return;
     }
 
     PageThumbs._store(this.url, data.finalURL, data.imageData, data.wasErrorResponse)
-              .then(callOnDones);
+              .then(done, done);
   },
 };
 
 Capture.nextID = 0;
 
 /**
  * Adds a value to one of this module's telemetry histograms.
  *