Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsStreamLoader_h__ |
michael@0 | 7 | #define nsStreamLoader_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIStreamLoader.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | |
michael@0 | 13 | class nsIRequest; |
michael@0 | 14 | |
michael@0 | 15 | class nsStreamLoader MOZ_FINAL : public nsIStreamLoader |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | NS_DECL_ISUPPORTS |
michael@0 | 19 | NS_DECL_NSISTREAMLOADER |
michael@0 | 20 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 21 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 22 | |
michael@0 | 23 | nsStreamLoader(); |
michael@0 | 24 | ~nsStreamLoader(); |
michael@0 | 25 | |
michael@0 | 26 | static nsresult |
michael@0 | 27 | Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); |
michael@0 | 28 | |
michael@0 | 29 | protected: |
michael@0 | 30 | static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *, |
michael@0 | 31 | uint32_t, uint32_t, uint32_t *); |
michael@0 | 32 | |
michael@0 | 33 | // Utility method to free mData, if present, and update other state to |
michael@0 | 34 | // reflect that no data has been allocated. |
michael@0 | 35 | void ReleaseData(); |
michael@0 | 36 | |
michael@0 | 37 | nsCOMPtr<nsIStreamLoaderObserver> mObserver; |
michael@0 | 38 | nsCOMPtr<nsISupports> mContext; // the observer's context |
michael@0 | 39 | nsCOMPtr<nsIRequest> mRequest; |
michael@0 | 40 | |
michael@0 | 41 | uint8_t *mData; // buffer to accumulate incoming data |
michael@0 | 42 | uint32_t mAllocated; // allocated size of data buffer (we preallocate if |
michael@0 | 43 | // contentSize is available) |
michael@0 | 44 | uint32_t mLength; // actual length of data in buffer |
michael@0 | 45 | // (must be <= mAllocated) |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | #endif // nsStreamLoader_h__ |