1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/src/nsStreamLoader.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsStreamLoader_h__ 1.10 +#define nsStreamLoader_h__ 1.11 + 1.12 +#include "nsIStreamLoader.h" 1.13 +#include "nsCOMPtr.h" 1.14 +#include "mozilla/Attributes.h" 1.15 + 1.16 +class nsIRequest; 1.17 + 1.18 +class nsStreamLoader MOZ_FINAL : public nsIStreamLoader 1.19 +{ 1.20 +public: 1.21 + NS_DECL_ISUPPORTS 1.22 + NS_DECL_NSISTREAMLOADER 1.23 + NS_DECL_NSIREQUESTOBSERVER 1.24 + NS_DECL_NSISTREAMLISTENER 1.25 + 1.26 + nsStreamLoader(); 1.27 + ~nsStreamLoader(); 1.28 + 1.29 + static nsresult 1.30 + Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); 1.31 + 1.32 +protected: 1.33 + static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *, 1.34 + uint32_t, uint32_t, uint32_t *); 1.35 + 1.36 + // Utility method to free mData, if present, and update other state to 1.37 + // reflect that no data has been allocated. 1.38 + void ReleaseData(); 1.39 + 1.40 + nsCOMPtr<nsIStreamLoaderObserver> mObserver; 1.41 + nsCOMPtr<nsISupports> mContext; // the observer's context 1.42 + nsCOMPtr<nsIRequest> mRequest; 1.43 + 1.44 + uint8_t *mData; // buffer to accumulate incoming data 1.45 + uint32_t mAllocated; // allocated size of data buffer (we preallocate if 1.46 + // contentSize is available) 1.47 + uint32_t mLength; // actual length of data in buffer 1.48 + // (must be <= mAllocated) 1.49 +}; 1.50 + 1.51 +#endif // nsStreamLoader_h__