Bug 1861709 replace AudioCallbackDriver::ThreadRunning() assertions that mean to...
[gecko.git] / netwerk / base / nsIncrementalStreamLoader.h
blob97d4277c28c37c45d64074a6f423399452a39876
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 : public nsIIncrementalStreamLoader {
18 public:
19 NS_DECL_THREADSAFE_ISUPPORTS
20 NS_DECL_NSIINCREMENTALSTREAMLOADER
21 NS_DECL_NSIREQUESTOBSERVER
22 NS_DECL_NSISTREAMLISTENER
23 NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
25 nsIncrementalStreamLoader();
27 static nsresult Create(REFNSIID aIID, void** aResult);
29 protected:
30 ~nsIncrementalStreamLoader() = default;
32 static nsresult WriteSegmentFun(nsIInputStream*, void*, const char*, uint32_t,
33 uint32_t, uint32_t*);
35 // Utility method to free mData, if present, and update other state to
36 // reflect that no data has been allocated.
37 void ReleaseData();
39 nsCOMPtr<nsIIncrementalStreamLoaderObserver> mObserver;
40 nsCOMPtr<nsISupports> mContext; // the observer's context
41 nsCOMPtr<nsIRequest> mRequest;
43 // Buffer to accumulate incoming data. We preallocate if contentSize is
44 // available.
45 mozilla::Vector<uint8_t, 0> mData;
47 // Number of bytes read, which may not match the number of bytes in mData at
48 // all, as we incrementally remove from there.
49 mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed> mBytesRead;
52 #endif // nsIncrementalStreamLoader_h__