Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / dom / streams / ReadIntoRequest.h
blob9be3d2c0278ebae1c531c2dab75a8032cfdfcb1d
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* vim:set ts=2 sw=2 sts=2 et cindent: */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef mozilla_dom_ReadIntoRequest_h
9 #define mozilla_dom_ReadIntoRequest_h
11 #include "js/TypeDecls.h"
12 #include "js/Value.h"
13 #include "mozilla/ErrorResult.h"
14 #include "mozilla/LinkedList.h"
15 #include "mozilla/RefPtr.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsISupportsImpl.h"
19 namespace mozilla::dom {
21 // This list element needs to be cycle collected by owning structures.
22 struct ReadIntoRequest : public nsISupports,
23 public LinkedListElement<RefPtr<ReadIntoRequest>> {
24 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
25 NS_DECL_CYCLE_COLLECTION_CLASS(ReadIntoRequest)
27 // An algorithm taking a chunk, called when a chunk is available for reading
28 virtual void ChunkSteps(JSContext* aCx, JS::Handle<JS::Value> aChunk,
29 ErrorResult& aRv) = 0;
31 // An algorithm taking a chunk or undefined, called when no chunks are
32 // available because the stream is closed
33 MOZ_CAN_RUN_SCRIPT
34 virtual void CloseSteps(JSContext* aCx, JS::Handle<JS::Value> aChunk,
35 ErrorResult& aRv) = 0;
37 // An algorithm taking a JavaScript value, called when no chunks are available
38 // because the stream is errored
39 virtual void ErrorSteps(JSContext* aCx, JS::Handle<JS::Value> e,
40 ErrorResult& aRv) = 0;
42 protected:
43 virtual ~ReadIntoRequest() = default;
46 } // namespace mozilla::dom
48 #endif