1
0
Fork 0
firefox/services/sync/modules/TabsStore.sys.mjs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

45 lines
1.4 KiB
JavaScript

/* 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/. */
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
TabsStore:
"moz-src:///toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustTabs.sys.mjs",
});
var storePromise = null;
export async function getTabsStore() {
if (storePromise == null) {
const path = PathUtils.join(PathUtils.profileDir, "synced-tabs.db");
storePromise = lazy.TabsStore.init(path);
lazy.AsyncShutdown.profileBeforeChange.addBlocker(
"TabsStore: shutdown",
async function blocker() {
try {
let store = await storePromise;
await store.closeConnection();
storePromise = null;
} finally {
lazy.AsyncShutdown.profileBeforeChange.removeBlocker(blocker);
}
}
);
}
return await storePromise;
}
export async function getRemoteCommandStore() {
const store = await getTabsStore();
// creating a new remote command store is cheap (but not free, so maybe we should cache this in the future?)
return await store.newRemoteCommandStore();
}
export {
RemoteCommand,
PendingCommand,
} from "moz-src:///toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustTabs.sys.mjs";