| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/core/html/parser/TextResourceDecoder.h" | |
| 6 | |
| 7 #include "sky/engine/wtf/text/TextCodec.h" | |
| 8 #include "sky/engine/wtf/text/TextEncodingRegistry.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 TextResourceDecoder::TextResourceDecoder() | |
| 13 : m_sawError(false) | |
| 14 { | |
| 15 } | |
| 16 | |
| 17 TextResourceDecoder::~TextResourceDecoder() | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 const WTF::TextEncoding& TextResourceDecoder::encoding() const | |
| 22 { | |
| 23 return WTF::UTF8Encoding(); | |
| 24 } | |
| 25 | |
| 26 String TextResourceDecoder::decode(const char* data, size_t len) | |
| 27 { | |
| 28 if (!m_codec) | |
| 29 m_codec = newTextCodec(encoding()); | |
| 30 return m_codec->decode(data, len, WTF::DoNotFlush, false, m_sawError); | |
| 31 } | |
| 32 | |
| 33 String TextResourceDecoder::flush() | |
| 34 { | |
| 35 if (!m_codec) | |
| 36 m_codec = newTextCodec(encoding()); | |
| 37 | |
| 38 String result = m_codec->decode(0, 0, WTF::FetchEOF, false, m_sawError); | |
| 39 m_codec.clear(); | |
| 40 return result; | |
| 41 } | |
| 42 | |
| 43 } | |
| OLD | NEW |