From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- dom/workers/WorkerLoadInfo.cpp | 507 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 507 insertions(+) create mode 100644 dom/workers/WorkerLoadInfo.cpp (limited to 'dom/workers/WorkerLoadInfo.cpp') diff --git a/dom/workers/WorkerLoadInfo.cpp b/dom/workers/WorkerLoadInfo.cpp new file mode 100644 index 0000000000..6fc0632b54 --- /dev/null +++ b/dom/workers/WorkerLoadInfo.cpp @@ -0,0 +1,507 @@ +/* -*- 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/. */ + +#include "WorkerLoadInfo.h" +#include "WorkerPrivate.h" + +#include "mozilla/BasePrincipal.h" +#include "mozilla/dom/nsCSPUtils.h" +#include "mozilla/dom/BrowserChild.h" +#include "mozilla/dom/ReferrerInfo.h" +#include "mozilla/ipc/BackgroundUtils.h" +#include "mozilla/ipc/PBackgroundSharedTypes.h" +#include "mozilla/LoadContext.h" +#include "mozilla/StorageAccess.h" +#include "mozilla/StoragePrincipalHelper.h" +#include "nsContentUtils.h" +#include "nsIContentSecurityPolicy.h" +#include "nsICookieJarSettings.h" +#include "nsINetworkInterceptController.h" +#include "nsIProtocolHandler.h" +#include "nsIReferrerInfo.h" +#include "nsIBrowserChild.h" +#include "nsScriptSecurityManager.h" +#include "nsNetUtil.h" + +namespace mozilla { + +using namespace ipc; + +namespace dom { + +namespace { + +class MainThreadReleaseRunnable final : public Runnable { + nsTArray> mDoomed; + nsCOMPtr mLoadGroupToCancel; + + public: + MainThreadReleaseRunnable(nsTArray>&& aDoomed, + nsCOMPtr&& aLoadGroupToCancel) + : mozilla::Runnable("MainThreadReleaseRunnable"), + mDoomed(std::move(aDoomed)), + mLoadGroupToCancel(std::move(aLoadGroupToCancel)) {} + + NS_INLINE_DECL_REFCOUNTING_INHERITED(MainThreadReleaseRunnable, Runnable) + + NS_IMETHOD + Run() override { + if (mLoadGroupToCancel) { + mLoadGroupToCancel->CancelWithReason( + NS_BINDING_ABORTED, "WorkerLoadInfo::MainThreadReleaseRunnable"_ns); + mLoadGroupToCancel = nullptr; + } + + mDoomed.Clear(); + return NS_OK; + } + + private: + ~MainThreadReleaseRunnable() = default; +}; + +// Specialize this if there's some class that has multiple nsISupports bases. +template +struct ISupportsBaseInfo { + using ISupportsBase = T; +}; + +template