From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../extensions/webrequest/StreamFilter.h | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 toolkit/components/extensions/webrequest/StreamFilter.h (limited to 'toolkit/components/extensions/webrequest/StreamFilter.h') diff --git a/toolkit/components/extensions/webrequest/StreamFilter.h b/toolkit/components/extensions/webrequest/StreamFilter.h new file mode 100644 index 0000000000..e5df536167 --- /dev/null +++ b/toolkit/components/extensions/webrequest/StreamFilter.h @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; 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/. */ + +#ifndef mozilla_extensions_StreamFilter_h +#define mozilla_extensions_StreamFilter_h + +#include "mozilla/dom/BindingDeclarations.h" +#include "mozilla/dom/StreamFilterBinding.h" + +#include "mozilla/DOMEventTargetHelper.h" +#include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" +#include "nsAtom.h" + +namespace mozilla { + +namespace ipc { +template +class Endpoint; +} + +namespace extensions { + +class PStreamFilterChild; +class StreamFilterChild; + +class StreamFilter : public DOMEventTargetHelper { + friend class StreamFilterChild; + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(StreamFilter, + DOMEventTargetHelper) + + static already_AddRefed Create(dom::GlobalObject& global, + uint64_t aRequestId, + const nsAString& aAddonId); + + explicit StreamFilter(nsIGlobalObject* aParent, uint64_t aRequestId, + const nsAString& aAddonId); + + IMPL_EVENT_HANDLER(start); + IMPL_EVENT_HANDLER(stop); + IMPL_EVENT_HANDLER(data); + IMPL_EVENT_HANDLER(error); + + void Write(const dom::ArrayBufferOrUint8Array& aData, ErrorResult& aRv); + + void GetError(nsAString& aError) { aError = mError; } + + dom::StreamFilterStatus Status() const; + void Suspend(ErrorResult& aRv); + void Resume(ErrorResult& aRv); + void Disconnect(ErrorResult& aRv); + void Close(ErrorResult& aRv); + + nsISupports* GetParentObject() const { return mParent; } + + virtual JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + + static bool IsAllowedInContext(JSContext* aCx, JSObject* aObj); + + protected: + virtual ~StreamFilter(); + + void FireEvent(const nsAString& aType); + + void FireDataEvent(const nsTArray& aData); + + void FireErrorEvent(const nsAString& aError); + + bool CheckAlive(); + + private: + void Connect(); + + void FinishConnect(mozilla::ipc::Endpoint&& aEndpoint); + + void ForgetActor(); + + nsCOMPtr mParent; + RefPtr mActor; + + nsString mError; + + const uint64_t mChannelId; + const RefPtr mAddonId; +}; + +} // namespace extensions +} // namespace mozilla + +#endif // mozilla_extensions_StreamFilter_h -- cgit v1.2.3