summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/TabStateFlusher.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /browser/components/sessionstore/TabStateFlusher.sys.mjs
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/TabStateFlusher.sys.mjs')
-rw-r--r--browser/components/sessionstore/TabStateFlusher.sys.mjs100
1 files changed, 4 insertions, 96 deletions
diff --git a/browser/components/sessionstore/TabStateFlusher.sys.mjs b/browser/components/sessionstore/TabStateFlusher.sys.mjs
index e391abc970..ed7953e41e 100644
--- a/browser/components/sessionstore/TabStateFlusher.sys.mjs
+++ b/browser/components/sessionstore/TabStateFlusher.sys.mjs
@@ -2,11 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-const lazy = {};
-ChromeUtils.defineESModuleGetters(lazy, {
- SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
-});
-
/**
* A module that enables async flushes. Updates from frame scripts are
* throttled to be sent only once per second. If an action wants a tab's latest
@@ -33,23 +28,6 @@ export var TabStateFlusher = Object.freeze({
},
/**
- * Resolves the flush request with the given flush ID.
- *
- * @param browser (<xul:browser>)
- * The browser for which the flush is being resolved.
- * @param flushID (int)
- * The ID of the flush that was sent to the browser.
- * @param success (bool, optional)
- * Whether or not the flush succeeded.
- * @param message (string, optional)
- * An error message that will be sent to the Console in the
- * event that a flush failed.
- */
- resolve(browser, flushID, success = true, message = "") {
- TabStateFlusherInternal.resolve(browser, flushID, success, message);
- },
-
- /**
* Resolves all active flush requests for a given browser. This should be
* used when the content process crashed or the final update message was
* seen. In those cases we can't guarantee to ever hear back from the frame
@@ -69,9 +47,6 @@ export var TabStateFlusher = Object.freeze({
});
var TabStateFlusherInternal = {
- // Stores the last request ID.
- _lastRequestID: 0,
-
// A map storing all active requests per browser. A request is a
// triple of a map containing all flush requests, a promise that
// resolve when a request for a browser is canceled, and the
@@ -79,7 +54,6 @@ var TabStateFlusherInternal = {
_requests: new WeakMap(),
initEntry(entry) {
- entry.perBrowserRequests = new Map();
entry.cancelPromise = new Promise(resolve => {
entry.cancel = resolve;
}).then(result => {
@@ -96,7 +70,6 @@ var TabStateFlusherInternal = {
* all the latest data.
*/
flush(browser) {
- let id = ++this._lastRequestID;
let nativePromise = Promise.resolve();
if (browser && browser.frameLoader) {
/*
@@ -106,24 +79,6 @@ var TabStateFlusherInternal = {
nativePromise = browser.frameLoader.requestTabStateFlush();
}
- if (!Services.appinfo.sessionHistoryInParent) {
- /*
- In the event that we have to trigger a process switch and thus change
- browser remoteness, session store needs to register and track the new
- browser window loaded and to have message manager listener registered
- ** before ** TabStateFlusher send "SessionStore:flush" message. This fixes
- the race where we send the message before the message listener is
- registered for it.
- */
- lazy.SessionStore.ensureInitialized(browser.ownerGlobal);
-
- let mm = browser.messageManager;
- mm.sendAsyncMessage("SessionStore:flush", {
- id,
- epoch: lazy.SessionStore.getCurrentEpoch(browser),
- });
- }
-
// Retrieve active requests for given browser.
let permanentKey = browser.permanentKey;
let request = this._requests.get(permanentKey);
@@ -134,22 +89,10 @@ var TabStateFlusherInternal = {
this._requests.set(permanentKey, request);
}
- // Non-SHIP flushes resolve this after the "SessionStore:update" message. We
- // don't use that message for SHIP, so it's fine to resolve the request
- // immediately after the native promise resolves, since SessionStore will
- // have processed all updates from this browser by that point.
- let requestPromise = Promise.resolve();
- if (!Services.appinfo.sessionHistoryInParent) {
- requestPromise = new Promise(resolve => {
- // Store resolve() so that we can resolve the promise later.
- request.perBrowserRequests.set(id, resolve);
- });
- }
-
- return Promise.race([
- nativePromise.then(_ => requestPromise),
- request.cancelPromise,
- ]);
+ // It's fine to resolve the request immediately after the native promise
+ // resolves, since SessionStore will have processed all updates from this
+ // browser by that point.
+ return Promise.race([nativePromise, request.cancelPromise]);
},
/**
@@ -167,41 +110,6 @@ var TabStateFlusherInternal = {
},
/**
- * Resolves the flush request with the given flush ID.
- *
- * @param browser (<xul:browser>)
- * The browser for which the flush is being resolved.
- * @param flushID (int)
- * The ID of the flush that was sent to the browser.
- * @param success (bool, optional)
- * Whether or not the flush succeeded.
- * @param message (string, optional)
- * An error message that will be sent to the Console in the
- * event that a flush failed.
- */
- resolve(browser, flushID, success = true, message = "") {
- // Nothing to do if there are no pending flushes for the given browser.
- if (!this._requests.has(browser.permanentKey)) {
- return;
- }
-
- // Retrieve active requests for given browser.
- let { perBrowserRequests } = this._requests.get(browser.permanentKey);
- if (!perBrowserRequests.has(flushID)) {
- return;
- }
-
- if (!success) {
- console.error("Failed to flush browser: ", message);
- }
-
- // Resolve the request with the given id.
- let resolve = perBrowserRequests.get(flushID);
- perBrowserRequests.delete(flushID);
- resolve(success);
- },
-
- /**
* Resolves all active flush requests for a given browser. This should be
* used when the content process crashed or the final update message was
* seen. In those cases we can't guarantee to ever hear back from the frame