summaryrefslogtreecommitdiff
path: root/dom/workers
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-04-07 16:39:41 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-04-07 23:41:55 +0800
commitb3a6a8f27410fe1a66c0ee90213870b888a6f874 (patch)
tree12e537c9b4d5343c7728d02f2ccff117a07213bf /dom/workers
parent83501c86d2bc9e7b9e12da143204b38f426f20a0 (diff)
downloaduxp-b3a6a8f27410fe1a66c0ee90213870b888a6f874.tar.gz
Issue #2197 - Part 2c: Implement StructuredSerializeOptions for ServiceWorker
Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=1502802
Diffstat (limited to 'dom/workers')
-rw-r--r--dom/workers/ServiceWorker.cpp10
-rw-r--r--dom/workers/ServiceWorker.h8
-rw-r--r--dom/workers/ServiceWorkerClient.cpp9
-rw-r--r--dom/workers/ServiceWorkerClient.h6
4 files changed, 33 insertions, 0 deletions
diff --git a/dom/workers/ServiceWorker.cpp b/dom/workers/ServiceWorker.cpp
index 87b86c4805..f2a39ea9c2 100644
--- a/dom/workers/ServiceWorker.cpp
+++ b/dom/workers/ServiceWorker.cpp
@@ -14,6 +14,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/dom/Promise.h"
+#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
#ifdef XP_WIN
@@ -97,6 +98,15 @@ ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
aRv = workerPrivate->SendMessageEvent(aCx, aMessage, aTransferable, Move(clientInfo));
}
+void
+ServiceWorker::PostMessage(JSContext* aCx,
+ JS::Handle<JS::Value> aMessage,
+ const StructuredSerializeOptions& aOptions,
+ ErrorResult& aRv)
+{
+ PostMessage(aCx, aMessage, aOptions.mTransfer, aRv);
+}
+
} // namespace workers
} // namespace dom
} // namespace mozilla
diff --git a/dom/workers/ServiceWorker.h b/dom/workers/ServiceWorker.h
index d85d055aab..eb14fc4293 100644
--- a/dom/workers/ServiceWorker.h
+++ b/dom/workers/ServiceWorker.h
@@ -15,6 +15,8 @@ class nsPIDOMWindowInner;
namespace mozilla {
namespace dom {
+struct StructuredSerializeOptions;
+
namespace workers {
class ServiceWorkerInfo;
@@ -66,6 +68,12 @@ public:
const Sequence<JSObject*>& aTransferable,
ErrorResult& aRv);
+ void
+ PostMessage(JSContext* aCx,
+ JS::Handle<JS::Value> aMessage,
+ const StructuredSerializeOptions& aOptions,
+ ErrorResult& aRv);
+
private:
// This class can only be created from ServiceWorkerInfo::GetOrCreateInstance().
ServiceWorker(nsPIDOMWindowInner* aWindow, ServiceWorkerInfo* aInfo);
diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp
index eb4e676ffa..e8b8341e21 100644
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -11,6 +11,7 @@
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/ServiceWorkerMessageEvent.h"
#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
+#include "mozilla/dom/MessagePortBinding.h"
#include "nsGlobalWindow.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIDocument.h"
@@ -220,3 +221,11 @@ ServiceWorkerClient::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
}
}
+void
+ServiceWorkerClient::PostMessage(JSContext* aCx,
+ JS::Handle<JS::Value> aMessage,
+ const StructuredSerializeOptions& aOptions,
+ ErrorResult& aRv)
+{
+ PostMessage(aCx, aMessage, aOptions.mTransfer, aRv);
+}
diff --git a/dom/workers/ServiceWorkerClient.h b/dom/workers/ServiceWorkerClient.h
index 4d8759c408..7f89ee611a 100644
--- a/dom/workers/ServiceWorkerClient.h
+++ b/dom/workers/ServiceWorkerClient.h
@@ -94,6 +94,12 @@ public:
const Sequence<JSObject*>& aTransferable,
ErrorResult& aRv);
+ void
+ PostMessage(JSContext* aCx,
+ JS::Handle<JS::Value> aMessage,
+ const StructuredSerializeOptions& aOptions,
+ ErrorResult& aRv);
+
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
protected: