ByteStreamHelpers.h (1464B)
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/. */ 6 7 #ifndef mozilla_dom_ByteStreamHelpers_h 8 #define mozilla_dom_ByteStreamHelpers_h 9 10 #include "UnderlyingSourceCallbackHelpers.h" 11 #include "js/TypeDecls.h" 12 #include "mozilla/ErrorResult.h" 13 14 namespace mozilla::dom { 15 16 class ReadableStream; 17 class BodyStreamHolder; 18 19 // https://streams.spec.whatwg.org/#transfer-array-buffer 20 // 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); 24 25 bool CanTransferArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aObject, 26 ErrorResult& aRv); 27 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 30 // currently). 31 JSObject* CloneAsUint8Array(JSContext* aCx, JS::Handle<JSObject*> aObject); 32 33 MOZ_CAN_RUN_SCRIPT void 34 SetUpReadableByteStreamControllerFromBodyStreamUnderlyingSource( 35 JSContext* aCx, ReadableStream* aStream, 36 BodyStreamHolder* aUnderlyingSource, ErrorResult& aRv); 37 38 } // namespace mozilla::dom 39 40 #endif