michael@0: /* -*- Mode: C++; tab-width: 4; 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 nsUnicharStreamLoader_h__ michael@0: #define nsUnicharStreamLoader_h__ michael@0: michael@0: #include "nsIChannel.h" michael@0: #include "nsIUnicharStreamLoader.h" michael@0: #include "nsIUnicodeDecoder.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsIInputStream; michael@0: michael@0: class nsUnicharStreamLoader : public nsIUnicharStreamLoader michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIUNICHARSTREAMLOADER michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: michael@0: nsUnicharStreamLoader() {} michael@0: virtual ~nsUnicharStreamLoader() {} michael@0: michael@0: static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); michael@0: michael@0: protected: michael@0: nsresult DetermineCharset(); michael@0: michael@0: /** michael@0: * callback method used for ReadSegments michael@0: */ michael@0: static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *, michael@0: uint32_t, uint32_t, uint32_t *); michael@0: michael@0: nsCOMPtr mObserver; michael@0: nsCOMPtr mDecoder; michael@0: nsCOMPtr mContext; michael@0: nsCOMPtr mChannel; michael@0: nsCString mCharset; michael@0: michael@0: // This holds the first up-to-512 bytes of the raw stream. michael@0: // It will be passed to the OnDetermineCharset callback. michael@0: nsCString mRawData; michael@0: michael@0: // This holds the complete contents of the stream so far, after michael@0: // decoding to UTF-16. It will be passed to the OnStreamComplete michael@0: // callback. michael@0: nsString mBuffer; michael@0: }; michael@0: michael@0: #endif // nsUnicharStreamLoader_h__