netwerk/base/src/nsUnicharStreamLoader.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/src/nsUnicharStreamLoader.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; 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 nsUnicharStreamLoader_h__
    1.10 +#define nsUnicharStreamLoader_h__
    1.11 +
    1.12 +#include "nsIChannel.h"
    1.13 +#include "nsIUnicharStreamLoader.h"
    1.14 +#include "nsIUnicodeDecoder.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsString.h"
    1.17 +
    1.18 +class nsIInputStream;
    1.19 +
    1.20 +class nsUnicharStreamLoader : public nsIUnicharStreamLoader
    1.21 +{
    1.22 +public:
    1.23 +  NS_DECL_ISUPPORTS
    1.24 +  NS_DECL_NSIUNICHARSTREAMLOADER
    1.25 +  NS_DECL_NSIREQUESTOBSERVER
    1.26 +  NS_DECL_NSISTREAMLISTENER
    1.27 +
    1.28 +  nsUnicharStreamLoader() {}
    1.29 +  virtual ~nsUnicharStreamLoader() {}
    1.30 +
    1.31 +  static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
    1.32 +
    1.33 +protected:
    1.34 +  nsresult DetermineCharset();
    1.35 +
    1.36 +  /**
    1.37 +   * callback method used for ReadSegments
    1.38 +   */
    1.39 +  static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *,
    1.40 +                                   uint32_t, uint32_t, uint32_t *);
    1.41 +
    1.42 +  nsCOMPtr<nsIUnicharStreamLoaderObserver> mObserver;
    1.43 +  nsCOMPtr<nsIUnicodeDecoder>              mDecoder;
    1.44 +  nsCOMPtr<nsISupports>                    mContext;
    1.45 +  nsCOMPtr<nsIChannel>                     mChannel;
    1.46 +  nsCString                                mCharset;
    1.47 +
    1.48 +  // This holds the first up-to-512 bytes of the raw stream.
    1.49 +  // It will be passed to the OnDetermineCharset callback.
    1.50 +  nsCString                                mRawData;
    1.51 +
    1.52 +  // This holds the complete contents of the stream so far, after
    1.53 +  // decoding to UTF-16.  It will be passed to the OnStreamComplete
    1.54 +  // callback.
    1.55 +  nsString                                 mBuffer;
    1.56 +};
    1.57 +
    1.58 +#endif // nsUnicharStreamLoader_h__

mercurial