Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / streams / ReadableStreamBYOBRequest.h
blobfb8ad62979aad1abc465f854820afec93c7c5e06
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_ReadableStreamBYOBRequest_h
8 #define mozilla_dom_ReadableStreamBYOBRequest_h
10 #include "js/RootingAPI.h"
11 #include "js/TypeDecls.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/ErrorResult.h"
14 #include "mozilla/HoldDropJSObjects.h"
15 #include "mozilla/dom/BindingDeclarations.h"
16 #include "mozilla/dom/TypedArray.h"
17 #include "nsCOMPtr.h"
18 #include "nsCycleCollectionParticipant.h"
19 #include "nsWrapperCache.h"
20 #include "nsIGlobalObject.h"
22 namespace mozilla::dom {
24 class ReadableByteStreamController;
26 class ReadableStreamBYOBRequest final : public nsISupports,
27 public nsWrapperCache {
28 public:
29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
30 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ReadableStreamBYOBRequest)
32 public:
33 explicit ReadableStreamBYOBRequest(nsIGlobalObject* aGlobal);
35 protected:
36 ~ReadableStreamBYOBRequest();
38 public:
39 nsIGlobalObject* GetParentObject() const { return mGlobal; }
41 JSObject* WrapObject(JSContext* aCx,
42 JS::Handle<JSObject*> aGivenProto) override;
44 void GetView(JSContext* cx, JS::MutableHandle<JSObject*> aRetVal) const;
46 MOZ_CAN_RUN_SCRIPT void Respond(JSContext* aCx, uint64_t bytesWritten,
47 ErrorResult& aRv);
49 MOZ_CAN_RUN_SCRIPT void RespondWithNewView(JSContext* aCx,
50 const ArrayBufferView& view,
51 ErrorResult& aRv);
53 ReadableByteStreamController* Controller() { return mController; }
54 void SetController(ReadableByteStreamController* aController);
56 JSObject* View() { return mView; }
57 void SetView(JS::Handle<JSObject*> aView) { mView = aView; }
59 private:
60 // Internal Slots
61 nsCOMPtr<nsIGlobalObject> mGlobal;
62 RefPtr<ReadableByteStreamController> mController;
63 JS::Heap<JSObject*> mView;
66 } // namespace mozilla::dom
68 #endif