e correct url to restore.
    await Promise.race([
      Promise.allSettled(
        lazy.BrowserWindowTracker.orderedWindows.map(
          lazy.TabStateFlusher.flushWindow
        )
      ),
      new Promise((_, reject) =>
        lazy.setTimeout(reject, lazy.TAB_FLUSH_TIMEOUT, { timeout: true })
      ),
    ]).catch(e => {
      if (e?.timeout) {
        lazy.logConsole.warn("Timed out waiting while flushing tab state.");
      } else {
        lazy.logConsole.error(
          "Unrecognized error while flushing tab state.",
          e
        );
      }
    });

    let sessionStorePath = PathUtils.join(stagingPath, "sessionstore.jsonlz4");

    await IOUtils.writeJSON(sessionStorePath, this.filteredSessionStoreState, {
      compress: true,
    });
    await BackupResource.copyFiles(profilePath, stagingPath, [
      "sessionstore-backups",
    ]);

    return null;
  }

  async recover(_manifestEntry, recoveryPath, destProfilePath) {
    await BackupResource.copyFiles(recoveryPath, destProfilePath, [
      "sessionstore.jsonlz4",
      "sessionstore-backups",
    ]);

    return null;
  }

  async measure(profilePath = PathUtils.profileDir) {
    // Get the current state of the session store JSON and
    // measure it's uncompressed size.
    let sessionStoreJson = this.#sessionStore.getCurrentState(true);
    let sessionStoreSize = new TextEncoder().encode(
      JSON.stringify(sessionStoreJson)
    ).byteLength;
    let sessionStoreNearestTenKb = bytesToFuzzyKilobytes(sessionStoreSize);

    Glean.browserBackup.sessionStoreSize.set(sessionStoreNearestTenKb);

    let sessionStoreBackupsDirectoryPath = PathUtils.join(
      profilePath,
      "sessionstore-backups"
    );
    let sessionStoreBackupsDirectorySize =
      await BackupResource.getDirectorySize(sessionStoreBackupsDirectoryPath);

    Glean.browserBackup.sessionStoreBackupsDirectorySize.set(
      sessionStoreBackupsDirectorySize
    );
  }
}
PK