/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
WorkerPrivate* worker = mProxy->GetWorkerPrivate();
RefPtr<GetSubscriptionResultRunnable> r = new GetSubscriptionResultRunnable(
worker, std::move(mProxy), aStatus, endpoint, mScope,
std::move(mExpirationTime), std::move(rawP256dhKey),
std::move(authSecret), std::move(appServerKey)); if (!r->Dispatch(worker)) { return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
// Convenience method for use in this file. void OnPushSubscriptionError(nsresult aStatus) {
Unused << NS_WARN_IF(NS_FAILED(OnPushSubscription(aStatus, nullptr)));
}
{ // Bug 1228723: If permission is revoked or an error occurs, the // subscription callback will be called synchronously. This causes // `GetSubscriptionCallback::OnPushSubscription` to deadlock when // it tries to acquire the lock.
MutexAutoLock lock(mProxy->Lock()); if (mProxy->CleanedUp()) { return NS_OK;
}
principal = mProxy->GetWorkerPrivate()->GetPrincipal();
}
MOZ_ASSERT(principal);
RefPtr<GetSubscriptionCallback> callback = new GetSubscriptionCallback(mProxy, mScope);
class PermissionStateRunnable final : public Runnable { public: explicit PermissionStateRunnable(PromiseWorkerProxy* aProxy)
: Runnable("dom::PermissionStateRunnable"), mProxy(aProxy) {}
RefPtr<PermissionResultRunnable> r = new PermissionResultRunnable(mProxy, rv, state);
// This can fail if the worker thread is already shutting down, but there's // nothing we can do in that case.
Unused << NS_WARN_IF(!r->Dispatch(mProxy->GetWorkerPrivate()));
PushManager::PushManager(const nsAString& aScope) : mScope(aScope) { #ifdef DEBUG // There's only one global on a worker, so we don't need to pass a global // object to the constructor.
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(worker);
worker->AssertIsOnWorkerThread(); #endif
}
nsTArray<nsString> encodings{u"aes128gcm"_ns}; if (StaticPrefs::dom_push_indicate_aesgcm_support_enabled()) { // The spec does not define orders, but Chrome is returning ["aes128gcm", // "aesgcm"] and there are a bunch of code like below, which is copypasted // from Minishlink/web-push-php-example endorsed by // web-push-libs/web-push-php. Which means practically the preferred // algorithm should go to the first place. // // (PushManager.supportedContentEncodings || ['aesgcm'])[0];
encodings.AppendElement(u"aesgcm"_ns);
}
JS::Rooted<JS::Value> encodingsValue(cx); if (!ToJSValue(cx, encodings, &encodingsValue)) { if (JS_IsThrowingOutOfMemory(cx)) {
MOZ_CRASH("Out of memory");
} else {
aRv.NoteJSContextException(cx); return;
}
};
JS::Rooted<JSObject*> object(cx, &encodingsValue.toObject()); if (!JS_FreezeObject(cx, object)) {
aRv.NoteJSContextException(cx); return;
}
aEncodings.set(object);
}
nsCOMPtr<nsIGlobalObject> global = worker->GlobalScope();
RefPtr<Promise> p = Promise::Create(global, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr;
}
nsCOMPtr<nsIGlobalObject> global = worker->GlobalScope();
RefPtr<Promise> p = Promise::Create(global, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr;
}
nsTArray<uint8_t> appServerKey; if (!aOptions.mApplicationServerKey.IsNull()) {
nsresult rv = NormalizeAppServerKey(aOptions.mApplicationServerKey.Value(),
appServerKey); if (NS_FAILED(rv)) {
p->MaybeReject(rv); return p.forget();
}
}
RefPtr<GetSubscriptionRunnable> r = new GetSubscriptionRunnable(
proxy, mScope, aAction, std::move(appServerKey));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(r));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.