Bug 917012 - Too many mainthread stat() calls during downloads. r=enn, a=lsblakk
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 08 Oct 2013 20:28:35 +0200
changeset 160676 d38bb5b38b7f94742eef65f491fd8c1eefa79263
parent 160675 5ce2322ee9100cf6d8502f6bb44b5909191ab428
child 160677 6c3224b0b2a794f1f0cfd0cc28cafd7bde70b7c8
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)
reviewersenn, lsblakk
bugs917012
milestone26.0a2
Bug 917012 - Too many mainthread stat() calls during downloads. r=enn, a=lsblakk
browser/components/downloads/src/DownloadsCommon.jsm
--- a/browser/components/downloads/src/DownloadsCommon.jsm
+++ b/browser/components/downloads/src/DownloadsCommon.jsm
@@ -752,30 +752,33 @@ DownloadsDataCtor.prototype = {
     }
   },
 
   /**
    * Updates the given data item and sends related notifications.
    */
   _updateDataItemState: function (aDataItem)
   {
+    let oldState = aDataItem.state;
     let wasInProgress = aDataItem.inProgress;
     let wasDone = aDataItem.done;
 
     aDataItem.updateFromJSDownload();
 
     if (wasInProgress && !aDataItem.inProgress) {
       aDataItem.endTime = Date.now();
     }
 
-    for (let view of this._views) {
-      try {
-        view.getViewItem(aDataItem).onStateChange({});
-      } catch (ex) {
-        Cu.reportError(ex);
+    if (oldState != aDataItem.state) {
+      for (let view of this._views) {
+        try {
+          view.getViewItem(aDataItem).onStateChange(oldState);
+        } catch (ex) {
+          Cu.reportError(ex);
+        }
       }
     }
 
     if (!aDataItem.newDownloadNotified) {
       aDataItem.newDownloadNotified = true;
       this._notifyDownloadEvent("start");
     }