Bug 676110 - Part 4: Adapt Sync's history engine to implement handleCompletion. r=rnewman
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Fri, 19 Aug 2011 10:12:23 -0700
changeset 75773 66264eefc193af477009fe367b1495d0a72341cb
parent 75772 fda809e5d6e9cffa40659b8101824001cf877377
child 75774 858c7fa7af70585834d9947506ff1c6452c54ffb
push id1441
push userpweitershausen@mozilla.com
push dateWed, 24 Aug 2011 01:33:19 +0000
treeherdermozilla-inbound@7857bbf3a523 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs676110
milestone9.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 676110 - Part 4: Adapt Sync's history engine to implement handleCompletion. r=rnewman
services/sync/modules/engines/history.js
--- a/services/sync/modules/engines/history.js
+++ b/services/sync/modules/engines/history.js
@@ -41,17 +41,16 @@
 const EXPORTED_SYMBOLS = ['HistoryEngine', 'HistoryRec'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
 const HISTORY_TTL = 5184000; // 60 days
-const TOPIC_UPDATEPLACES_COMPLETE = "places-updatePlaces-complete";
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://services-sync/constants.js");
 Cu.import("resource://services-sync/engines.js");
 Cu.import("resource://services-sync/record.js");
 Cu.import("resource://services-sync/async.js");
 Cu.import("resource://services-sync/util.js");
 Cu.import("resource://services-sync/log4moz.js");
@@ -248,30 +247,25 @@ HistoryStore.prototype = {
     }
     records.length = k; // truncate array
 
     // Nothing to do.
     if (!records.length) {
       return failed;
     }
 
-    let cb = Async.makeSyncCallback();
     let updatePlacesCallback = { 
       handleResult: function handleResult() {},
       handleError: function handleError(resultCode, placeInfo) {
         failed.push(placeInfo.guid);
-      }
+      },
+      handleCompletion: Async.makeSyncCallback()
     };
-    let onComplete = function onComplete(subject, topic, data) {
-      Svc.Obs.remove(TOPIC_UPDATEPLACES_COMPLETE, onComplete);
-      cb();
-    };
-    Svc.Obs.add(TOPIC_UPDATEPLACES_COMPLETE, onComplete);
     this._asyncHistory.updatePlaces(records, updatePlacesCallback);
-    Async.waitForSyncCallback(cb);
+    Async.waitForSyncCallback(updatePlacesCallback.handleCompletion);
     return failed;
   },
 
   /**
    * Converts a Sync history record to a mozIPlaceInfo.
    * 
    * Throws if an invalid record is encountered (invalid URI, etc.),
    * returns true if the record is to be applied, false otherwise