2002-08-27 23:47:25 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-08-27 23:47:25 +00:00
|
|
|
|
|
|
|
#ifndef nsUnicharStreamLoader_h__
|
|
|
|
#define nsUnicharStreamLoader_h__
|
|
|
|
|
2011-05-19 01:22:59 +00:00
|
|
|
#include "nsIChannel.h"
|
2002-08-27 23:47:25 +00:00
|
|
|
#include "nsIUnicharStreamLoader.h"
|
2011-05-19 01:22:59 +00:00
|
|
|
#include "nsIUnicodeDecoder.h"
|
2002-08-27 23:47:25 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
2011-05-19 01:22:59 +00:00
|
|
|
|
|
|
|
class nsIInputStream;
|
2002-08-27 23:47:25 +00:00
|
|
|
|
2006-10-24 21:47:40 +00:00
|
|
|
class nsUnicharStreamLoader : public nsIUnicharStreamLoader
|
2002-08-27 23:47:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIUNICHARSTREAMLOADER
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
|
2011-05-19 01:22:59 +00:00
|
|
|
nsUnicharStreamLoader() {}
|
2007-04-23 14:21:53 +00:00
|
|
|
virtual ~nsUnicharStreamLoader() {}
|
2002-08-27 23:47:25 +00:00
|
|
|
|
2011-05-19 01:22:59 +00:00
|
|
|
static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
2002-08-27 23:47:25 +00:00
|
|
|
|
|
|
|
protected:
|
2011-05-19 01:22:59 +00:00
|
|
|
nsresult DetermineCharset();
|
|
|
|
|
2002-08-27 23:47:25 +00:00
|
|
|
/**
|
|
|
|
* callback method used for ReadSegments
|
|
|
|
*/
|
|
|
|
static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t, uint32_t, uint32_t *);
|
2002-08-27 23:47:25 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIUnicharStreamLoaderObserver> mObserver;
|
2011-05-19 01:22:59 +00:00
|
|
|
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
|
|
|
nsCOMPtr<nsISupports> mContext;
|
2002-08-27 23:47:25 +00:00
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
2011-05-19 01:22:59 +00:00
|
|
|
nsCString mCharset;
|
|
|
|
|
|
|
|
// This holds the first up-to-512 bytes of the raw stream.
|
|
|
|
// It will be passed to the OnDetermineCharset callback.
|
|
|
|
nsCString mRawData;
|
|
|
|
|
|
|
|
// This holds the complete contents of the stream so far, after
|
|
|
|
// decoding to UTF-16. It will be passed to the OnStreamComplete
|
|
|
|
// callback.
|
|
|
|
nsString mBuffer;
|
2002-08-27 23:47:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsUnicharStreamLoader_h__
|