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_ByteStreamHelpers_h
8 #define mozilla_dom_ByteStreamHelpers_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/ErrorResult.h"
12 #include "UnderlyingSourceCallbackHelpers.h"
14 namespace mozilla::dom
{
17 class BodyStreamHolder
;
19 // https://streams.spec.whatwg.org/#transfer-array-buffer
21 // As some parts of the specifcation want to use the abrupt completion value,
22 // this function may leave a pending exception if it returns nullptr.
23 JSObject
* TransferArrayBuffer(JSContext
* aCx
, JS::Handle
<JSObject
*> aObject
);
25 bool CanTransferArrayBuffer(JSContext
* aCx
, JS::Handle
<JSObject
*> aObject
,
28 // If this returns null, it will leave a pending exception on aCx which
29 // must be handled by the caller (in the spec this is always the case
31 JSObject
* CloneAsUint8Array(JSContext
* aCx
, JS::Handle
<JSObject
*> aObject
);
33 MOZ_CAN_RUN_SCRIPT
void
34 SetUpReadableByteStreamControllerFromBodyStreamUnderlyingSource(
35 JSContext
* aCx
, ReadableStream
* aStream
,
36 BodyStreamHolder
* aUnderlyingSource
, ErrorResult
& aRv
);
38 } // namespace mozilla::dom