Source code

Revision control

Other Tools

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/. */
5
6
#ifndef nsIncrementalStreamLoader_h__
7
#define nsIncrementalStreamLoader_h__
8
9
#include "nsIThreadRetargetableStreamListener.h"
10
#include "nsIIncrementalStreamLoader.h"
11
#include "nsCOMPtr.h"
12
#include "mozilla/Attributes.h"
13
#include "mozilla/Vector.h"
14
15
class nsIRequest;
16
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
26
27
nsIncrementalStreamLoader();
28
29
static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
30
31
protected:
32
~nsIncrementalStreamLoader() = default;
33
34
static nsresult WriteSegmentFun(nsIInputStream*, void*, const char*, uint32_t,
35
uint32_t, uint32_t*);
36
37
// Utility method to free mData, if present, and update other state to
38
// reflect that no data has been allocated.
39
void ReleaseData();
40
41
nsCOMPtr<nsIIncrementalStreamLoaderObserver> mObserver;
42
nsCOMPtr<nsISupports> mContext; // the observer's context
43
nsCOMPtr<nsIRequest> mRequest;
44
45
// Buffer to accumulate incoming data. We preallocate if contentSize is
46
// available.
47
mozilla::Vector<uint8_t, 0> mData;
48
49
// Number of consumed bytes from the mData.
50
size_t mBytesConsumed;
51
};
52
53
#endif // nsIncrementalStreamLoader_h__