diff options
author | Thomas Groman <tgroman@nuegia.net> | 2020-05-08 01:13:10 -0700 |
---|---|---|
committer | Thomas Groman <tgroman@nuegia.net> | 2020-05-08 01:13:10 -0700 |
commit | d3cd5c8967245fe0cda7a3ba707aca4007b66bdd (patch) | |
tree | 24279d32273f65cfe209d62585f74c739a64f175 /webbrowser/components | |
parent | a80324acf9506e31c48d180eebc82844bd04bc1f (diff) | |
download | webbrowser-d3cd5c8967245fe0cda7a3ba707aca4007b66bdd.tar webbrowser-d3cd5c8967245fe0cda7a3ba707aca4007b66bdd.tar.gz webbrowser-d3cd5c8967245fe0cda7a3ba707aca4007b66bdd.tar.lz webbrowser-d3cd5c8967245fe0cda7a3ba707aca4007b66bdd.tar.xz webbrowser-d3cd5c8967245fe0cda7a3ba707aca4007b66bdd.zip |
Stop using deprecated calls to getMostRecent()
https://github.com/MoonchildProductions/Pale-Moon/issues/1745
Diffstat (limited to 'webbrowser/components')
-rw-r--r-- | webbrowser/components/nsBrowserGlue.js | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/webbrowser/components/nsBrowserGlue.js b/webbrowser/components/nsBrowserGlue.js index 2bb71e1..08d0221 100644 --- a/webbrowser/components/nsBrowserGlue.js +++ b/webbrowser/components/nsBrowserGlue.js @@ -238,9 +238,9 @@ BrowserGlue.prototype = { this._onPlacesShutdown(); break; case "idle": - if ((this._idleService.idleTime > BOOKMARKS_BACKUP_IDLE_TIME * 1000) && - this._shouldBackupBookmarks()) + if (this._idleService.idleTime > BOOKMARKS_BACKUP_IDLE_TIME * 1000) { this._backupBookmarks(); + } break; case "distribution-customization-complete": Services.obs.removeObserver(this, "distribution-customization-complete"); @@ -941,8 +941,7 @@ BrowserGlue.prototype = { Services.prefs.getBoolPref("browser.bookmarks.restore_default_bookmarks"); if (restoreDefaultBookmarks) { // Ensure that we already have a bookmarks backup for today. - if (this._shouldBackupBookmarks()) - yield this._backupBookmarks(); + yield this._backupBookmarks(); importBookmarks = true; } } catch(ex) {} @@ -1087,23 +1086,19 @@ BrowserGlue.prototype = { this._isIdleObserver = false; } - let waitingForBackupToComplete = true; - if (this._shouldBackupBookmarks()) { - waitingForBackupToComplete = false; - this._backupBookmarks().then( - function onSuccess() { - waitingForBackupToComplete = true; - }, - function onFailure() { - Cu.reportError("Unable to backup bookmarks."); - waitingForBackupToComplete = true; - } - ); - } + this._backupBookmarks().then( + function onSuccess() { + waitingForBackupToComplete = false; + }, + function onFailure() { + Cu.reportError("Unable to backup bookmarks."); + waitingForBackupToComplete = false; + } + ); // Backup bookmarks to bookmarks.html to support apps that depend // on the legacy format. - let waitingForHTMLExportToComplete = true; + let waitingForHTMLExportToComplete = false; // If this fails to get the preference value, we don't export. if (Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML")) { // Exceptionally, since this is a non-default setting and HTML format is @@ -1112,51 +1107,41 @@ BrowserGlue.prototype = { // spin the event loop on shutdown until we include a watchdog to prevent // potential hangs (bug 518683). The asynchronous shutdown operations // will then be handled by a shutdown service (bug 435058). - waitingForHTMLExportToComplete = false; + waitingForHTMLExportToComplete = true; BookmarkHTMLUtils.exportToFile(BookmarkHTMLUtils.defaultPath).then( function onSuccess() { - waitingForHTMLExportToComplete = true; + waitingForHTMLExportToComplete = false; }, function onFailure() { Cu.reportError("Unable to auto export html."); - waitingForHTMLExportToComplete = true; + waitingForHTMLExportToComplete = false; } ); } + // The events loop should spin at least once because waitingForBackupToComplete + // is true before checking whether backup should be made. let thread = Services.tm.currentThread; - while (!waitingForBackupToComplete || !waitingForHTMLExportToComplete) { + while (waitingForBackupToComplete || waitingForHTMLExportToComplete) { thread.processNextEvent(true); } }, /** - * Determine whether to backup bookmarks or not. - * @return true if bookmarks should be backed up, false if not. - */ - _shouldBackupBookmarks: function BG__shouldBackupBookmarks() { - let lastBackupFile = PlacesBackups.getMostRecent(); - - // Should backup bookmarks if there are no backups or the maximum interval between - // backups elapsed. - return (!lastBackupFile || - new Date() - PlacesBackups.getDateForFile(lastBackupFile) > BOOKMARKS_BACKUP_INTERVAL); - }, - - /** * Backup bookmarks. */ _backupBookmarks: function BG__backupBookmarks() { return Task.spawn(function() { - // Backup bookmarks if there are no backups or the maximum interval between - // backups elapsed. - let maxBackups = BOOKMARKS_BACKUP_MAX_BACKUPS; - try { - maxBackups = Services.prefs.getIntPref("browser.bookmarks.max_backups"); + let lastBackupFile = yield PlacesBackups.getMostRecentBackup(); + // Should backup bookmarks if there are no backups or the maximum + // interval between backups elapsed. + if (!lastBackupFile || + new Date() - PlacesBackups.getDateForFile(lastBackupFile) > BOOKMARKS_BACKUP_INTERVAL) { + let maxBackups = BOOKMARKS_BACKUP_MAX_BACKUPS; + try { maxBackups = Services.prefs.getIntPref("browser.bookmarks.max_backups"); } + catch(ex) { /* Use default. */ } + yield PlacesBackups.create(maxBackups); // Don't force creation. } - catch(ex) { /* Use default. */ } - - yield PlacesBackups.create(maxBackups); // Don't force creation. }); }, |