Bug 1838739 - Initialize result of SetAsGPUOutOfMemoryError. r=webgpu-reviewers,nical
[gecko.git] / netwerk / base / nsIncrementalStreamLoader.h
blobd04af4002a61b349ba9685a83ba0f504f52886ea
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIncrementalStreamLoader_h__
7 #define nsIncrementalStreamLoader_h__
9 #include "nsIThreadRetargetableStreamListener.h"
10 #include "nsIIncrementalStreamLoader.h"
11 #include "nsCOMPtr.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/Vector.h"
15 class nsIRequest;
17 class nsIncrementalStreamLoader final
18 : public nsIIncrementalStreamLoader,
19 public nsIThreadRetargetableStreamListener {
20 public:
21 NS_DECL_THREADSAFE_ISUPPORTS
22 NS_DECL_NSIINCREMENTALSTREAMLOADER
23 NS_DECL_NSIREQUESTOBSERVER
24 NS_DECL_NSISTREAMLISTENER
25 NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
27 nsIncrementalStreamLoader();
29 static nsresult Create(REFNSIID aIID, void** aResult);
31 protected:
32 ~nsIncrementalStreamLoader() = default;
34 static nsresult WriteSegmentFun(nsIInputStream*, void*, const char*, uint32_t,
35 uint32_t, uint32_t*);
37 // Utility method to free mData, if present, and update other state to
38 // reflect that no data has been allocated.
39 void ReleaseData();
41 nsCOMPtr<nsIIncrementalStreamLoaderObserver> mObserver;
42 nsCOMPtr<nsISupports> mContext; // the observer's context
43 nsCOMPtr<nsIRequest> mRequest;
45 // Buffer to accumulate incoming data. We preallocate if contentSize is
46 // available.
47 mozilla::Vector<uint8_t, 0> mData;
49 // Number of bytes read, which may not match the number of bytes in mData at
50 // all, as we incrementally remove from there.
51 mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed> mBytesRead;
54 #endif // nsIncrementalStreamLoader_h__