summaryrefslogtreecommitdiffstats
path: root/services/cloudsync/CloudSyncBookmarksFolderCache.jsm
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-17 20:22:59 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-17 20:22:59 +0200
commit3eb4310cd889e6c8d22c27f0326273acf0a3e8bf (patch)
tree508827a64a5ad5c2d465535afea68eee39775a11 /services/cloudsync/CloudSyncBookmarksFolderCache.jsm
parent07381c3edad8ec24b5d820ec0592e0cafa7d73fa (diff)
parent1e868fadf94935bcb4a49ea5eec776d84fe2d1e7 (diff)
downloadUXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.gz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.lz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.xz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.zip
Merge branch 'Sync-weave'
Diffstat (limited to 'services/cloudsync/CloudSyncBookmarksFolderCache.jsm')
-rw-r--r--services/cloudsync/CloudSyncBookmarksFolderCache.jsm105
1 files changed, 0 insertions, 105 deletions
diff --git a/services/cloudsync/CloudSyncBookmarksFolderCache.jsm b/services/cloudsync/CloudSyncBookmarksFolderCache.jsm
deleted file mode 100644
index f3c3fc8f2..000000000
--- a/services/cloudsync/CloudSyncBookmarksFolderCache.jsm
+++ /dev/null
@@ -1,105 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["FolderCache"];
-
-// Cache for bookmarks folder heirarchy.
-var FolderCache = function () {
- this.cache = new Map();
-}
-
-FolderCache.prototype = {
- has: function (id) {
- return this.cache.has(id);
- },
-
- insert: function (id, parentId) {
- if (this.cache.has(id)) {
- return;
- }
-
- if (parentId && !(this.cache.has(parentId))) {
- throw new Error("insert :: parentId not found in cache: " + parentId);
- }
-
- this.cache.set(id, {
- parent: parentId || null,
- children: new Set(),
- });
-
- if (parentId) {
- this.cache.get(parentId).children.add(id);
- }
- },
-
- remove: function (id) {
- if (!(this.cache.has(id))) {
- throw new Error("remote :: id not found in cache: " + id);
- }
-
- let parentId = this.cache.get(id).parent;
- if (parentId) {
- this.cache.get(parentId).children.delete(id);
- }
-
- for (let child of this.cache.get(id).children) {
- this.cache.get(child).parent = null;
- }
-
- this.cache.delete(id);
- },
-
- setParent: function (id, parentId) {
- if (!(this.cache.has(id))) {
- throw new Error("setParent :: id not found in cache: " + id);
- }
-
- if (parentId && !(this.cache.has(parentId))) {
- throw new Error("setParent :: parentId not found in cache: " + parentId);
- }
-
- let oldParent = this.cache.get(id).parent;
- if (oldParent) {
- this.cache.get(oldParent).children.delete(id);
- }
- this.cache.get(id).parent = parentId;
- this.cache.get(parentId).children.add(id);
-
- return true;
- },
-
- getParent: function (id) {
- if (this.cache.has(id)) {
- return this.cache.get(id).parent;
- }
-
- throw new Error("getParent :: id not found in cache: " + id);
- },
-
- getChildren: function (id) {
- if (this.cache.has(id)) {
- return this.cache.get(id).children;
- }
-
- throw new Error("getChildren :: id not found in cache: " + id);
- },
-
- setChildren: function (id, children) {
- for (let child of children) {
- if (!this.cache.has(child)) {
- this.insert(child, id);
- } else {
- this.setParent(child, id);
- }
- }
- },
-
- dump: function () {
- dump("FolderCache: " + JSON.stringify(this.cache) + "\n");
- },
-};
-
-this.FolderCache = FolderCache;