ReadIntoRequest.h (1713B)
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_ReadIntoRequest_h 8 #define mozilla_dom_ReadIntoRequest_h 9 10 #include "js/TypeDecls.h" 11 #include "js/Value.h" 12 #include "mozilla/ErrorResult.h" 13 #include "mozilla/LinkedList.h" 14 #include "mozilla/RefPtr.h" 15 #include "nsCycleCollectionParticipant.h" 16 #include "nsISupportsImpl.h" 17 18 namespace mozilla::dom { 19 20 // This list element needs to be cycle collected by owning structures. 21 struct ReadIntoRequest : public nsISupports, 22 public LinkedListElement<RefPtr<ReadIntoRequest>> { 23 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 24 NS_DECL_CYCLE_COLLECTION_CLASS(ReadIntoRequest) 25 26 // An algorithm taking a chunk, called when a chunk is available for reading 27 virtual void ChunkSteps(JSContext* aCx, JS::Handle<JS::Value> aChunk, 28 ErrorResult& aRv) = 0; 29 30 // An algorithm taking a chunk or undefined, called when no chunks are 31 // available because the stream is closed 32 MOZ_CAN_RUN_SCRIPT 33 virtual void CloseSteps(JSContext* aCx, JS::Handle<JS::Value> aChunk, 34 ErrorResult& aRv) = 0; 35 36 // An algorithm taking a JavaScript value, called when no chunks are available 37 // because the stream is errored 38 virtual void ErrorSteps(JSContext* aCx, JS::Handle<JS::Value> e, 39 ErrorResult& aRv) = 0; 40 41 protected: 42 virtual ~ReadIntoRequest() = default; 43 }; 44 45 } // namespace mozilla::dom 46 47 #endif