intl/uconv/ucvcn/nsGBKToUnicode.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef nsGBK2312ToUnicode_h___
     6 #define nsGBK2312ToUnicode_h___
     8 #include "nsCOMPtr.h"
     9 #include "nsIUnicodeDecoder.h"
    10 #include "nsUCSupport.h"
    11 #include "nsGBKConvUtil.h"
    13 //----------------------------------------------------------------------
    14 // Class nsGBKToUnicode [declaration]
    16 /**
    17  * A character set converter from GBK to Unicode.
    18  * 
    19  *
    20  * @created         07/Sept/1999
    21  * @author  Yueheng Xu, Yueheng.Xu@intel.com
    22  */
    23 class nsGBKToUnicode : public nsBufferDecoderSupport
    24 {
    25 public:
    27   /**
    28    * Class constructor.
    29    */
    30   nsGBKToUnicode() : nsBufferDecoderSupport(1)
    31   {
    32     mExtensionDecoder = nullptr;
    33     m4BytesDecoder = nullptr;
    34   }
    36 protected:
    38   //--------------------------------------------------------------------
    39   // Subclassing of nsDecoderSupport class [declaration]
    40   NS_IMETHOD ConvertNoBuff(const char* aSrc, int32_t * aSrcLength, char16_t *aDest, int32_t * aDestLength);
    42 protected:
    43   nsGBKConvUtil mUtil;
    44   nsCOMPtr<nsIUnicodeDecoder> mExtensionDecoder;
    45   nsCOMPtr<nsIUnicodeDecoder> m4BytesDecoder;
    47   virtual void CreateExtensionDecoder();
    48   virtual void Create4BytesDecoder();
    49   bool TryExtensionDecoder(const char* aSrc, char16_t* aDest);
    50   bool Try4BytesDecoder(const char* aSrc, char16_t* aDest);
    51   virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
    53 };
    56 class nsGB18030ToUnicode : public nsGBKToUnicode
    57 {
    58 public:
    59   nsGB18030ToUnicode() {}
    60   virtual ~nsGB18030ToUnicode() {}
    61 protected:
    62   virtual void CreateExtensionDecoder();
    63   virtual void Create4BytesDecoder();
    64   virtual bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
    65 };
    67 #endif /* nsGBK2312ToUnicode_h___ */

mercurial