зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1882171 - Stub out the beginnings of the BackupService. r=mossop,kpatenio,fchasen
This creates a new BackupService component that lives under browser/components/backup. It doesn't do much yet, except allow itself to be instantiated (which currently occurs using the idle scheduler in BrowserGlue) - but it does set us up to have docs, SphinxJS exporting for JSDoc, linting, etc. Differential Revision: https://phabricator.services.mozilla.com/D202753
This commit is contained in:
Родитель
44cdfcbba3
Коммит
6fe1bb3a63
|
@ -3029,3 +3029,5 @@ pref("browser.mailto.dualPrompt.os", false);
|
|||
// When visiting a site which uses registerProtocolHandler: Ask the user to set Firefox as
|
||||
// default mailto handler.
|
||||
pref("browser.mailto.prompt.os", true);
|
||||
|
||||
pref("browser.backup.enabled", false);
|
||||
|
|
|
@ -17,6 +17,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
|
||||
AppMenuNotifications: "resource://gre/modules/AppMenuNotifications.sys.mjs",
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
|
||||
BackupService: "resource:///modules/backup/BackupService.sys.mjs",
|
||||
Blocklist: "resource://gre/modules/Blocklist.sys.mjs",
|
||||
BookmarkHTMLUtils: "resource://gre/modules/BookmarkHTMLUtils.sys.mjs",
|
||||
BookmarkJSONUtils: "resource://gre/modules/BookmarkJSONUtils.sys.mjs",
|
||||
|
@ -3166,6 +3167,14 @@ BrowserGlue.prototype = {
|
|||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "BackupService initialization",
|
||||
condition: Services.prefs.getBoolPref("browser.backup.enabled", false),
|
||||
task: () => {
|
||||
lazy.BackupService.init();
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "browser-startup-idle-tasks-finished",
|
||||
task: () => {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
/* 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";
|
||||
|
||||
module.exports = {
|
||||
extends: ["plugin:mozilla/require-jsdoc"],
|
||||
};
|
|
@ -0,0 +1,48 @@
|
|||
/* 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.defineLazyGetter(lazy, "logConsole", function () {
|
||||
return console.createInstance({
|
||||
prefix: "BackupService",
|
||||
maxLogLevel: Services.prefs.getBoolPref("browser.backup.log", false)
|
||||
? "Debug"
|
||||
: "Warn",
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The BackupService class orchestrates the scheduling and creation of profile
|
||||
* backups. It also does most of the heavy lifting for the restoration of a
|
||||
* profile backup.
|
||||
*/
|
||||
export class BackupService {
|
||||
/**
|
||||
* The BackupService singleton instance.
|
||||
*
|
||||
* @static
|
||||
* @type {BackupService|null}
|
||||
*/
|
||||
static #instance = null;
|
||||
|
||||
/**
|
||||
* Returns a reference to a BackupService singleton. If this is the first time
|
||||
* that this getter is accessed, this causes the BackupService singleton to be
|
||||
* be instantiated.
|
||||
*
|
||||
* @static
|
||||
* @type {BackupService}
|
||||
*/
|
||||
static init() {
|
||||
if (this.#instance) {
|
||||
return this.#instance;
|
||||
}
|
||||
return (this.#instance = new BackupService());
|
||||
}
|
||||
|
||||
constructor() {
|
||||
lazy.logConsole.debug("Instantiated");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
========================
|
||||
Backup Service Reference
|
||||
========================
|
||||
|
||||
.. autoattribute:: BackupService##instance
|
||||
.. js:autoclass:: BackupService
|
||||
:members:
|
||||
:private-members:
|
|
@ -0,0 +1,13 @@
|
|||
.. _components/backup:
|
||||
|
||||
================
|
||||
Backup Component
|
||||
================
|
||||
|
||||
The Backup Component is responsible for creating backups of user profile data
|
||||
into a single file that can be easily restored from.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
|
||||
backup-service
|
|
@ -0,0 +1,11 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
SPHINX_TREES["docs"] = "docs"
|
||||
|
||||
EXTRA_JS_MODULES.backup += [
|
||||
"BackupService.sys.mjs",
|
||||
]
|
|
@ -32,6 +32,7 @@ DIRS += [
|
|||
"aboutwelcome",
|
||||
"asrouter",
|
||||
"attribution",
|
||||
"backup",
|
||||
"contentanalysis",
|
||||
"contextualidentity",
|
||||
"customizableui",
|
||||
|
|
|
@ -31,3 +31,4 @@ This is the nascent documentation of the Firefox front-end code.
|
|||
components/storybook/docs/README.other-widgets.stories
|
||||
components/storybook/docs/README.lit-guide.stories
|
||||
components/storybook/docs/README.xul-and-html.stories
|
||||
components/backup/docs/index
|
||||
|
|
|
@ -54,6 +54,7 @@ extensions = [
|
|||
# When adding more paths to this list, please ensure that they are not
|
||||
# excluded from valid-jsdoc in the top-level .eslintrc.js.
|
||||
js_source_path = [
|
||||
"../browser/components/backup",
|
||||
"../browser/components/extensions",
|
||||
"../browser/components/migration",
|
||||
"../browser/components/migration/content",
|
||||
|
|
Загрузка…
Ссылка в новой задаче