CookiesBackupResource.sys.mjs (1303B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ 4 5 import { BackupResource } from "resource:///modules/backup/BackupResource.sys.mjs"; 6 7 /** 8 * Class representing Cookies database within a user profile. 9 */ 10 export class CookiesBackupResource extends BackupResource { 11 static get key() { 12 return "cookies"; 13 } 14 15 static get requiresEncryption() { 16 return true; 17 } 18 19 static get canBackupResource() { 20 // We don't backup cookies right now 21 return false; 22 } 23 24 async backup( 25 stagingPath, 26 profilePath = PathUtils.profileDir, 27 _isEncrypting = false 28 ) { 29 await BackupResource.copySqliteDatabases(profilePath, stagingPath, [ 30 "cookies.sqlite", 31 ]); 32 return null; 33 } 34 35 async recover(_manifestEntry, recoveryPath, destProfilePath) { 36 await BackupResource.copyFiles(recoveryPath, destProfilePath, [ 37 "cookies.sqlite", 38 ]); 39 return null; 40 } 41 42 async measure(profilePath = PathUtils.profileDir) { 43 let cookiesDBPath = PathUtils.join(profilePath, "cookies.sqlite"); 44 let cookiesSize = await BackupResource.getFileSize(cookiesDBPath); 45 46 Glean.browserBackup.cookiesSize.set(cookiesSize); 47 } 48 }