summaryrefslogtreecommitdiffstats
path: root/dom/push/PushSubscription.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/push/PushSubscription.cpp')
-rw-r--r--dom/push/PushSubscription.cpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp
index 0afb63eee8..fdc70edd09 100644
--- a/dom/push/PushSubscription.cpp
+++ b/dom/push/PushSubscription.cpp
@@ -17,7 +17,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWorkerProxy.h"
#include "mozilla/dom/PushSubscriptionOptions.h"
-#include "mozilla/dom/PushUtil.h"
+#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRunnable.h"
@@ -54,12 +54,12 @@ class UnsubscribeResultCallback final : public nsIUnsubscribeResultCallback {
NS_IMPL_ISUPPORTS(UnsubscribeResultCallback, nsIUnsubscribeResultCallback)
-class UnsubscribeResultRunnable final : public WorkerRunnable {
+class UnsubscribeResultRunnable final : public WorkerThreadRunnable {
public:
UnsubscribeResultRunnable(WorkerPrivate* aWorkerPrivate,
RefPtr<PromiseWorkerProxy>&& aProxy,
nsresult aStatus, bool aSuccess)
- : WorkerRunnable(aWorkerPrivate, "UnsubscribeResultRunnable"),
+ : WorkerThreadRunnable("UnsubscribeResultRunnable"),
mProxy(std::move(aProxy)),
mStatus(aStatus),
mSuccess(aSuccess) {
@@ -117,7 +117,7 @@ class WorkerUnsubscribeResultCallback final
WorkerPrivate* worker = mProxy->GetWorkerPrivate();
RefPtr<UnsubscribeResultRunnable> r = new UnsubscribeResultRunnable(
worker, std::move(mProxy), aStatus, aSuccess);
- MOZ_ALWAYS_TRUE(r->Dispatch());
+ MOZ_ALWAYS_TRUE(r->Dispatch(worker));
return NS_OK;
}
@@ -230,30 +230,24 @@ already_AddRefed<PushSubscription> PushSubscription::Constructor(
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
nsTArray<uint8_t> rawKey;
- if (aInitDict.mP256dhKey.WasPassed() &&
- !aInitDict.mP256dhKey.Value().IsNull() &&
- !aInitDict.mP256dhKey.Value().Value().AppendDataTo(rawKey)) {
+ if (!aInitDict.mP256dhKey.IsNull() &&
+ !aInitDict.mP256dhKey.Value().AppendDataTo(rawKey)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
nsTArray<uint8_t> authSecret;
- if (aInitDict.mAuthSecret.WasPassed() &&
- !aInitDict.mAuthSecret.Value().IsNull() &&
- !aInitDict.mAuthSecret.Value().Value().AppendDataTo(authSecret)) {
+ if (!aInitDict.mAuthSecret.IsNull() &&
+ !aInitDict.mAuthSecret.Value().AppendDataTo(authSecret)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
nsTArray<uint8_t> appServerKey;
- if (aInitDict.mAppServerKey.WasPassed() &&
- !aInitDict.mAppServerKey.Value().IsNull()) {
- const OwningArrayBufferViewOrArrayBuffer& bufferSource =
- aInitDict.mAppServerKey.Value().Value();
- if (!PushUtil::CopyBufferSourceToArray(bufferSource, appServerKey)) {
- aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
- return nullptr;
- }
+ if (!aInitDict.mAppServerKey.IsNull() &&
+ !AppendTypedArrayDataTo(aInitDict.mAppServerKey.Value(), appServerKey)) {
+ aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+ return nullptr;
}
Nullable<EpochTimeStamp> expirationTime;
@@ -307,10 +301,10 @@ already_AddRefed<Promise> PushSubscription::Unsubscribe(ErrorResult& aRv) {
void PushSubscription::GetKey(JSContext* aCx, PushEncryptionKeyName aType,
JS::MutableHandle<JSObject*> aKey,
ErrorResult& aRv) {
- if (aType == PushEncryptionKeyName::P256dh) {
- PushUtil::CopyArrayToArrayBuffer(aCx, mRawP256dhKey, aKey, aRv);
- } else if (aType == PushEncryptionKeyName::Auth) {
- PushUtil::CopyArrayToArrayBuffer(aCx, mAuthSecret, aKey, aRv);
+ if (aType == PushEncryptionKeyName::P256dh && !mRawP256dhKey.IsEmpty()) {
+ aKey.set(ArrayBuffer::Create(aCx, mRawP256dhKey, aRv));
+ } else if (aType == PushEncryptionKeyName::Auth && !mAuthSecret.IsEmpty()) {
+ aKey.set(ArrayBuffer::Create(aCx, mAuthSecret, aRv));
} else {
aKey.set(nullptr);
}