|
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 nsStreamLoader_h__ |
|
7 #define nsStreamLoader_h__ |
|
8 |
|
9 #include "nsIStreamLoader.h" |
|
10 #include "nsCOMPtr.h" |
|
11 #include "mozilla/Attributes.h" |
|
12 |
|
13 class nsIRequest; |
|
14 |
|
15 class nsStreamLoader MOZ_FINAL : public nsIStreamLoader |
|
16 { |
|
17 public: |
|
18 NS_DECL_ISUPPORTS |
|
19 NS_DECL_NSISTREAMLOADER |
|
20 NS_DECL_NSIREQUESTOBSERVER |
|
21 NS_DECL_NSISTREAMLISTENER |
|
22 |
|
23 nsStreamLoader(); |
|
24 ~nsStreamLoader(); |
|
25 |
|
26 static nsresult |
|
27 Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); |
|
28 |
|
29 protected: |
|
30 static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *, |
|
31 uint32_t, uint32_t, uint32_t *); |
|
32 |
|
33 // Utility method to free mData, if present, and update other state to |
|
34 // reflect that no data has been allocated. |
|
35 void ReleaseData(); |
|
36 |
|
37 nsCOMPtr<nsIStreamLoaderObserver> mObserver; |
|
38 nsCOMPtr<nsISupports> mContext; // the observer's context |
|
39 nsCOMPtr<nsIRequest> mRequest; |
|
40 |
|
41 uint8_t *mData; // buffer to accumulate incoming data |
|
42 uint32_t mAllocated; // allocated size of data buffer (we preallocate if |
|
43 // contentSize is available) |
|
44 uint32_t mLength; // actual length of data in buffer |
|
45 // (must be <= mAllocated) |
|
46 }; |
|
47 |
|
48 #endif // nsStreamLoader_h__ |