Bug 987682 - DumpBookmarks() in bookmarks.jsm hangs due to invalid JSON data. r=jgriffin a=lsblakk DONTBUILD
authorHenrik Skupin <mail@hskupin.info>
Tue, 25 Mar 2014 19:43:33 +0100
changeset 192408 a84920158dd4735450a2bec9112f22219abec395
parent 192407 b74b3c57ab496f2e3254c865aa181486b950207e
child 192409 27349a7974257ce92e37ab4764b1b5e61c0dd747
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin, lsblakk
bugs987682
milestone30.0a2
Bug 987682 - DumpBookmarks() in bookmarks.jsm hangs due to invalid JSON data. r=jgriffin a=lsblakk DONTBUILD
services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm
--- a/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm
+++ b/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm
@@ -7,44 +7,31 @@
   * listed symbols will exposed on import, and only when and where imported.
   */
 
 var EXPORTED_SYMBOLS = ["PlacesItem", "Bookmark", "Separator", "Livemark",
                         "BookmarkFolder", "DumpBookmarks"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
-Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
+Cu.import("resource://gre/modules/PlacesBackups.jsm");
 Cu.import("resource://gre/modules/PlacesUtils.jsm");
-Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
-Cu.import("resource://gre/modules/Task.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://services-common/async.js");
-
 Cu.import("resource://tps/logger.jsm");
 
 var DumpBookmarks = function TPS_Bookmarks__DumpBookmarks() {
-  let writer = {
-    value: "",
-    write: function PlacesItem__dump__write(aStr, aLen) {
-      this.value += aStr;
-    }
-  };
-
-  let options = PlacesUtils.history.getNewQueryOptions();
-  options.queryType = options.QUERY_TYPE_BOOKMARKS;
-  let query = PlacesUtils.history.getNewQuery();
-  query.setFolders([PlacesUtils.placesRootId], 1);
-  let root = PlacesUtils.history.executeQuery(query, options).root;
-  root.containerOpen = true;
   let cb = Async.makeSpinningCallback();
-  Task.spawn(function() {
-    yield BookmarkJSONUtils.serializeNodeAsJSONToOutputStream(root, writer, true, false);
-    let value = JSON.parse(writer.value);
-    Logger.logInfo("dumping bookmarks\n\n" + JSON.stringify(value, null, ' ') + "\n\n");
-    cb();
+  PlacesBackups.getBookmarksTree().then(result => {
+    let [bookmarks, count] = result;
+    Logger.logInfo("Dumping Bookmarks...\n" + JSON.stringify(bookmarks) + "\n\n");
+    cb(null);
+  }).then(null, error => {
+    cb(error);
   });
   cb.wait();
 };
 
 /**
  * extend, causes a child object to inherit from a parent
  */
 function extend(child, supertype)