summaryrefslogtreecommitdiffstats
path: root/toolkit/components/sessionstore
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/sessionstore')
-rw-r--r--toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs87
-rw-r--r--toolkit/components/sessionstore/SessionStoreListener.cpp14
-rw-r--r--toolkit/components/sessionstore/SessionStoreParent.cpp17
-rw-r--r--toolkit/components/sessionstore/moz.build6
-rw-r--r--toolkit/components/sessionstore/nsISessionStoreFunctions.idl (renamed from toolkit/components/sessionstore/SessionStoreFunctions.idl)0
5 files changed, 21 insertions, 103 deletions
diff --git a/toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs b/toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs
deleted file mode 100644
index f42c371264..0000000000
--- a/toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-import { SessionStore } from "resource:///modules/sessionstore/SessionStore.sys.mjs";
-
-export function UpdateSessionStore(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- aEpoch,
- aCollectSHistory,
- aData
-) {
- return SessionStoreFuncInternal.updateSessionStore(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- aEpoch,
- aCollectSHistory,
- aData
- );
-}
-
-export function UpdateSessionStoreForStorage(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- aEpoch,
- aData
-) {
- return SessionStoreFuncInternal.updateSessionStoreForStorage(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- aEpoch,
- aData
- );
-}
-
-var SessionStoreFuncInternal = {
- updateSessionStore: function SSF_updateSessionStore(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- aEpoch,
- aCollectSHistory,
- aData
- ) {
- let { formdata, scroll } = aData;
-
- if (formdata) {
- aData.formdata = formdata.toJSON();
- }
-
- if (scroll) {
- aData.scroll = scroll.toJSON();
- }
-
- SessionStore.updateSessionStoreFromTablistener(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- {
- data: aData,
- epoch: aEpoch,
- sHistoryNeeded: aCollectSHistory,
- }
- );
- },
-
- updateSessionStoreForStorage: function SSF_updateSessionStoreForStorage(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- aEpoch,
- aData
- ) {
- SessionStore.updateSessionStoreFromTablistener(
- aBrowser,
- aBrowsingContext,
- aPermanentKey,
- { data: { storage: aData }, epoch: aEpoch },
- true
- );
- },
-};
diff --git a/toolkit/components/sessionstore/SessionStoreListener.cpp b/toolkit/components/sessionstore/SessionStoreListener.cpp
index 11b9966954..c8135752f5 100644
--- a/toolkit/components/sessionstore/SessionStoreListener.cpp
+++ b/toolkit/components/sessionstore/SessionStoreListener.cpp
@@ -24,7 +24,7 @@
#include "nsIXULRuntime.h"
#include "nsPresContext.h"
#include "nsPrintfCString.h"
-#include "SessionStoreFunctions.h"
+#include "nsISessionStoreFunctions.h"
using namespace mozilla;
using namespace mozilla::dom;
@@ -436,9 +436,13 @@ void TabListener::UpdateSessionStore(bool aIsFlush) {
data.mIsPrivate.Construct() = mSessionStore->GetPrivateModeEnabled();
}
- nsCOMPtr<nsISessionStoreFunctions> funcs = do_ImportESModule(
- "resource://gre/modules/SessionStoreFunctions.sys.mjs", fallible);
- nsCOMPtr<nsIXPConnectWrappedJS> wrapped = do_QueryInterface(funcs);
+ nsCOMPtr<nsISessionStoreFunctions> sessionStoreFuncs =
+ do_GetService("@mozilla.org/toolkit/sessionstore-functions;1");
+ if (!sessionStoreFuncs) {
+ return;
+ }
+ nsCOMPtr<nsIXPConnectWrappedJS> wrapped =
+ do_QueryInterface(sessionStoreFuncs);
if (!wrapped) {
return;
}
@@ -456,7 +460,7 @@ void TabListener::UpdateSessionStore(bool aIsFlush) {
JS::Rooted<JS::Value> key(jsapi.cx(),
context->Canonical()->Top()->PermanentKey());
- nsresult rv = funcs->UpdateSessionStore(
+ nsresult rv = sessionStoreFuncs->UpdateSessionStore(
mOwnerContent, context, key, mEpoch,
mSessionStore->GetAndClearSHistoryChanged(), update);
if (NS_FAILED(rv)) {
diff --git a/toolkit/components/sessionstore/SessionStoreParent.cpp b/toolkit/components/sessionstore/SessionStoreParent.cpp
index 58be84d4d9..b917990633 100644
--- a/toolkit/components/sessionstore/SessionStoreParent.cpp
+++ b/toolkit/components/sessionstore/SessionStoreParent.cpp
@@ -19,7 +19,7 @@
#include "mozilla/dom/InProcessParent.h"
#include "mozilla/dom/SessionStoreChild.h"
#include "mozilla/dom/SessionStoreUtilsBinding.h"
-#include "SessionStoreFunctions.h"
+#include "nsISessionStoreFunctions.h"
#include "nsISupports.h"
#include "nsIXULRuntime.h"
#include "nsImportModule.h"
@@ -146,9 +146,14 @@ static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext,
data.mScroll.Construct(aScroll);
}
- nsCOMPtr<nsISessionStoreFunctions> funcs = do_ImportESModule(
- "resource://gre/modules/SessionStoreFunctions.sys.mjs", fallible);
- nsCOMPtr<nsIXPConnectWrappedJS> wrapped = do_QueryInterface(funcs);
+ nsCOMPtr<nsISessionStoreFunctions> sessionStoreFuncs =
+ do_GetService("@mozilla.org/toolkit/sessionstore-functions;1");
+ if (!sessionStoreFuncs) {
+ return;
+ }
+
+ nsCOMPtr<nsIXPConnectWrappedJS> wrapped =
+ do_QueryInterface(sessionStoreFuncs);
if (!wrapped) {
return;
}
@@ -166,8 +171,8 @@ static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext,
JS::Rooted<JS::Value> key(jsapi.cx(),
aBrowsingContext->Top()->PermanentKey());
- Unused << funcs->UpdateSessionStore(nullptr, aBrowsingContext, key, aEpoch,
- aNeedCollectSHistory, update);
+ Unused << sessionStoreFuncs->UpdateSessionStore(
+ nullptr, aBrowsingContext, key, aEpoch, aNeedCollectSHistory, update);
}
#endif
diff --git a/toolkit/components/sessionstore/moz.build b/toolkit/components/sessionstore/moz.build
index 9e8d2eb45e..b80dd70644 100644
--- a/toolkit/components/sessionstore/moz.build
+++ b/toolkit/components/sessionstore/moz.build
@@ -31,15 +31,11 @@ UNIFIED_SOURCES += [
"SessionStoreUtils.cpp",
]
-EXTRA_JS_MODULES += [
- "SessionStoreFunctions.sys.mjs",
-]
-
XPIDL_MODULE = "sessionstore"
XPIDL_SOURCES += [
+ "nsISessionStoreFunctions.idl",
"nsISessionStoreRestoreData.idl",
- "SessionStoreFunctions.idl",
]
IPDL_SOURCES += [
diff --git a/toolkit/components/sessionstore/SessionStoreFunctions.idl b/toolkit/components/sessionstore/nsISessionStoreFunctions.idl
index 3c17015437..3c17015437 100644
--- a/toolkit/components/sessionstore/SessionStoreFunctions.idl
+++ b/toolkit/components/sessionstore/nsISessionStoreFunctions.idl