// and is a good time to ensure any log messages are flushed to disk Services.obs.removeObserver(this, "sessionstore-windows-restored"); this.#observers.delete("sessionstore-windows-restored"); this.requestLogFlush(); this.#isStartingUp = false; break; case this._fileAppenderChangeTopic: { let shouldFlush = false; const msSinceLastFlush = Date.now() - this._fileAppender.lastFlushTime; if (this._fileAppender.sawError) { shouldFlush = true; } else if ( !this.#isStartingUp && msSinceLastFlush / 1000 >= lazy.logFlushIntervalSeconds ) { // we'll flush when initial startup is complete so ignore appends until then shouldFlush = true; } if (shouldFlush) { this.requestLogFlush(); } break; } } } async requestLogFlush(immediate = false) { if (this.#idleCallbackId && !immediate) { return; } if (this.#idleCallbackId) { lazy.cancelIdleCallback(this.#idleCallbackId); this.#idleCallbackId = null; } if (!immediate) { await new Promise(resolve => { this.#idleCallbackId = lazy.requestIdleCallback(resolve); }); this.#idleCallbackId = null; } await this.resetFileLog(); } } export const logManager = new SessionLogManager({ prefRoot: "browser.sessionstore.", logNames: loggerNames, logFilePrefix: "sessionrestore", logFileSubDirectoryEntries: ["sessionstore-logs"], testTopicPrefix: "sessionrestore:log-manager:", fileAppenderChangeTopic: "sessionrestore-log-file-append", overwriteFileOnFlush: false, }); PK