intl/uconv/ucvko/nsISO2022KRToUnicode.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.

michael@0 1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5 #ifndef nsISO2022KRToUnicode_h__
michael@0 6 #define nsISO2022KRToUnicode_h__
michael@0 7 #include "nsUCSupport.h"
michael@0 8 #include "mozilla/Telemetry.h"
michael@0 9
michael@0 10 class nsISO2022KRToUnicode : public nsBasicDecoderSupport
michael@0 11 {
michael@0 12 public:
michael@0 13 nsISO2022KRToUnicode()
michael@0 14 {
michael@0 15 mState = mState_Init;
michael@0 16 mLastLegalState = mState_ASCII;
michael@0 17 mData = 0;
michael@0 18 mEUCKRDecoder = nullptr;
michael@0 19 mRunLength = 0;
michael@0 20 mozilla::Telemetry::Accumulate(
michael@0 21 mozilla::Telemetry::DECODER_INSTANTIATED_ISO2022KR, true);
michael@0 22 }
michael@0 23
michael@0 24 virtual ~nsISO2022KRToUnicode()
michael@0 25 {
michael@0 26 NS_IF_RELEASE(mEUCKRDecoder);
michael@0 27 }
michael@0 28
michael@0 29 NS_IMETHOD Convert(const char * aSrc, int32_t * aSrcLength,
michael@0 30 char16_t * aDest, int32_t * aDestLength) ;
michael@0 31
michael@0 32 NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
michael@0 33 int32_t * aDestLength)
michael@0 34 {
michael@0 35 *aDestLength = aSrcLength;
michael@0 36 return NS_OK;
michael@0 37 }
michael@0 38
michael@0 39 NS_IMETHOD Reset()
michael@0 40 {
michael@0 41 mState = mState_Init;
michael@0 42 mLastLegalState = mState_ASCII;
michael@0 43 mRunLength = 0;
michael@0 44 return NS_OK;
michael@0 45 }
michael@0 46
michael@0 47 private:
michael@0 48 enum {
michael@0 49 mState_Init,
michael@0 50 mState_ASCII,
michael@0 51 mState_ESC,
michael@0 52 mState_ESC_24,
michael@0 53 mState_ESC_24_29,
michael@0 54 mState_KSX1001_1992,
michael@0 55 mState_KSX1001_1992_2ndbyte,
michael@0 56 mState_ERROR
michael@0 57 } mState, mLastLegalState;
michael@0 58
michael@0 59 uint8_t mData;
michael@0 60
michael@0 61 // Length of non-ASCII run
michael@0 62 uint32_t mRunLength;
michael@0 63
michael@0 64 nsIUnicodeDecoder *mEUCKRDecoder;
michael@0 65 };
michael@0 66 #endif // nsISO2022KRToUnicode_h__

mercurial