michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsStreamLoader_h__ michael@0: #define nsStreamLoader_h__ michael@0: michael@0: #include "nsIStreamLoader.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsIRequest; michael@0: michael@0: class nsStreamLoader MOZ_FINAL : public nsIStreamLoader michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSISTREAMLOADER michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: michael@0: nsStreamLoader(); michael@0: ~nsStreamLoader(); michael@0: michael@0: static nsresult michael@0: Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); michael@0: michael@0: protected: michael@0: static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *, michael@0: uint32_t, uint32_t, uint32_t *); michael@0: michael@0: // Utility method to free mData, if present, and update other state to michael@0: // reflect that no data has been allocated. michael@0: void ReleaseData(); michael@0: michael@0: nsCOMPtr mObserver; michael@0: nsCOMPtr mContext; // the observer's context michael@0: nsCOMPtr mRequest; michael@0: michael@0: uint8_t *mData; // buffer to accumulate incoming data michael@0: uint32_t mAllocated; // allocated size of data buffer (we preallocate if michael@0: // contentSize is available) michael@0: uint32_t mLength; // actual length of data in buffer michael@0: // (must be <= mAllocated) michael@0: }; michael@0: michael@0: #endif // nsStreamLoader_h__