Backed out changeset 334773fe02f0 (bug 1908727) for causing codecs failures.

This commit is contained in:
Stanca Serban
2024-11-04 23:49:46 +02:00
parent 7bb12fdb44
commit 708727fac6
4 changed files with 6 additions and 306 deletions

View File

@@ -133,13 +133,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
*/
null,
async function onUpdateLocationDirPath(_pref, _prevVal, newVal) {
let bs;
try {
bs = BackupService.get();
} catch (e) {
// This can throw if the BackupService hasn't initialized yet, which
// is a case we're okay to ignore.
}
let bs = BackupService.get();
if (bs) {
await bs.onUpdateLocationDirPath(newVal);
}
@@ -683,14 +677,6 @@ export class BackupService extends EventTarget {
*/
#regenerationDebouncer = null;
/**
* True if takeMeasurements has been called and various measurements related
* to the BackupService have been taken.
*
* @type {boolean}
*/
#takenMeasurements = false;
/**
* The path of the default parent directory for saving backups.
* The current default is the Documents directory.
@@ -917,7 +903,10 @@ export class BackupService extends EventTarget {
}
this.#instance = new BackupService(DefaultBackupResources);
this.#instance.checkForPostRecovery();
this.#instance.checkForPostRecovery().then(() => {
this.#instance.takeMeasurements();
});
this.#instance.initBackupScheduler();
return this.#instance;
}
@@ -2880,19 +2869,7 @@ export class BackupService extends EventTarget {
async takeMeasurements() {
lazy.logConsole.debug("Taking Telemetry measurements");
// We'll start by taking some basic BackupService state measurements.
Glean.browserBackup.enabled.set(true);
Glean.browserBackup.schedulerEnabled.set(lazy.scheduledBackupsPref);
await this.loadEncryptionState();
Glean.browserBackup.pswdEncrypted.set(this.#_state.encryptionEnabled);
const USING_DEFAULT_DIR_PATH =
lazy.backupDirPref ==
PathUtils.join(lazy.defaultParentDirPath, BackupService.BACKUP_DIR_NAME);
Glean.browserBackup.locationOnDevice.set(USING_DEFAULT_DIR_PATH ? 1 : 2);
// Next, we'll measure the available disk space on the storage
// We'll start by measuring the available disk space on the storage
// device that the profile directory is on.
let profileDir = await IOUtils.getFile(PathUtils.profileDir);
@@ -3324,11 +3301,6 @@ export class BackupService extends EventTarget {
*/
onIdle() {
lazy.logConsole.debug("Saw idle callback");
if (!this.#takenMeasurements) {
this.takeMeasurements();
this.#takenMeasurements = true;
}
if (lazy.scheduledBackupsPref) {
lazy.logConsole.debug("Scheduled backups enabled.");
let now = Math.floor(Date.now() / 1000);

View File

@@ -11,68 +11,6 @@ $tags:
- 'Firefox :: Profiles'
browser.backup:
enabled:
type: boolean
description: >
True if the BackupService is enabled by default.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_sensitivity:
- technical
notification_emails:
- mconley@mozilla.com
expires: never
telemetry_mirror: BROWSER_BACKUP_ENABLED
scheduler_enabled:
type: boolean
description: >
True if the BackupService is configured to automatically create backups
in the background.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_sensitivity:
- technical
notification_emails:
- mconley@mozilla.com
expires: never
telemetry_mirror: BROWSER_BACKUP_SCHEDULER_ENABLED
pswd_encrypted:
type: boolean
description: >
True if the BackupService is configured to encrypt backups.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_sensitivity:
- technical
notification_emails:
- mconley@mozilla.com
expires: never
telemetry_mirror: BROWSER_BACKUP_PSWD_ENCRYPTED
location_on_device:
type: quantity
unit: enum (see description)
description: >
1 = the default location, 2 = a non-default location
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1908727
data_sensitivity:
- technical
notification_emails:
- mconley@mozilla.com
expires: never
telemetry_mirror: BROWSER_BACKUP_LOCATION_ON_DEVICE
prof_d_disk_space:
type: quantity
unit: kilobyte

View File

@@ -41,8 +41,6 @@ add_task(async function test_takeMeasurements() {
* Tests that we can measure the disk space available in the profile directory.
*/
add_task(async function test_profDDiskSpace() {
Services.telemetry.clearScalars();
let bs = new BackupService();
await bs.takeMeasurements();
let measurement = Glean.browserBackup.profDDiskSpace.testGetValue();
@@ -59,154 +57,3 @@ add_task(async function test_profDDiskSpace() {
"device"
);
});
/**
* Tests that we record a scalar if the BackupService is configured to
* initialize on launch.
*/
add_task(async function test_BackupService_enabled_state() {
Services.telemetry.clearScalars();
let bs = new BackupService();
await bs.takeMeasurements();
Assert.ok(
Glean.browserBackup.enabled.testGetValue(),
"Should have set the enabled scalar."
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.enabled",
true,
"Should have set the enabled scalar in legacy Telemetry."
);
});
/**
* Tests that we record a scalar if the BackupService is configured to
* initialize on launch.
*/
add_task(async function test_BackupService_scheduler_enabled_state() {
Services.telemetry.clearScalars();
const SCHEDULED_BACKUPS_ENABLED_PREF_NAME =
"browser.backup.scheduled.enabled";
Services.prefs.setBoolPref(SCHEDULED_BACKUPS_ENABLED_PREF_NAME, false);
let bs = new BackupService();
await bs.takeMeasurements();
Assert.ok(
!Glean.browserBackup.schedulerEnabled.testGetValue(),
"Scalar for scheduled backups should be false"
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.scheduler_enabled",
false,
"Scalar for scheduled backups should be false in legacy Telemetry."
);
Services.telemetry.clearScalars();
Services.prefs.setBoolPref(SCHEDULED_BACKUPS_ENABLED_PREF_NAME, true);
await bs.takeMeasurements();
Assert.ok(
Glean.browserBackup.schedulerEnabled.testGetValue(),
"Scalar for scheduled backups should be true"
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.scheduler_enabled",
true,
"Scalar for scheduled backups should be true in legacy Telemetry."
);
// Now reset the scheduling state to the default to not interfere with
// other tests.
Services.prefs.clearUserPref(SCHEDULED_BACKUPS_ENABLED_PREF_NAME);
});
/**
* Tests that we record a scalar if the BackupService is configured to
* encrypt backups.
*/
add_task(async function test_BackupService_pswd_encrypted_state() {
Services.telemetry.clearScalars();
let bs = new BackupService();
await bs.takeMeasurements();
Assert.ok(
!Glean.browserBackup.pswdEncrypted.testGetValue(),
"Scalar for encrypted backups should be false"
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.pswd_encrypted",
false,
"Scalar for encrypted backups should be false in legacy Telemetry."
);
Services.telemetry.clearScalars();
const tempDir = await IOUtils.createUniqueDirectory(
PathUtils.tempDir,
"BackupService-takeMeasurements-test"
);
await bs.enableEncryption("some-fake-password", tempDir);
await bs.takeMeasurements();
Assert.ok(
Glean.browserBackup.pswdEncrypted.testGetValue(),
"Scalar for encrypted backups should be true"
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.pswd_encrypted",
true,
"Scalar for encrypted backups should be true in legacy Telemetry."
);
await maybeRemovePath(tempDir);
});
/**
* Tests that we record a scalar that tells us if backups are configured to
* be written to the default location, or somewhere else entirely.
*/
add_task(async function test_BackupService_location_on_device() {
Services.telemetry.clearScalars();
const DEFAULT_LOCATION = 1;
const NON_DEFAULT_LOCATION = 2;
let bs = new BackupService();
bs.setParentDirPath(PathUtils.tempDir);
await bs.takeMeasurements();
Assert.equal(
Glean.browserBackup.locationOnDevice.testGetValue(),
NON_DEFAULT_LOCATION,
"Scalar for location on device should indicate the non-default " +
"location"
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.location_on_device",
NON_DEFAULT_LOCATION,
"Scalar for location on device should indicate the non-default " +
"location in legacy Telemetry."
);
Services.telemetry.clearScalars();
// The system "Docs" folder is considered the default location.
bs.setParentDirPath(Services.dirsvc.get("Docs", Ci.nsIFile).path);
await bs.takeMeasurements();
Assert.equal(
Glean.browserBackup.locationOnDevice.testGetValue(),
DEFAULT_LOCATION,
"Scalar for location on device should indicate the default location"
);
TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent", false, true),
"browser.backup.location_on_device",
DEFAULT_LOCATION,
"Scalar for location on device should indicate the default " +
"location in legacy Telemetry."
);
});