forked from mirrors/gecko-dev
		
	 6fe1bb3a63
			
		
	
	
		6fe1bb3a63
		
	
	
	
	
		
			
			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
		
			
				
	
	
		
			48 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
	
		
			1.2 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.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");
 | |
|   }
 | |
| }
 |