| Index: sky/engine/core/html/parser/BackgroundHTMLParser.cpp
|
| diff --git a/sky/engine/core/html/parser/BackgroundHTMLParser.cpp b/sky/engine/core/html/parser/BackgroundHTMLParser.cpp
|
| index ea8a43ace04a4959fded4fdd28be0a38b5446162..8c1c8547bd2d8067207f9e7c2b6f20b85dc4ecd9 100644
|
| --- a/sky/engine/core/html/parser/BackgroundHTMLParser.cpp
|
| +++ b/sky/engine/core/html/parser/BackgroundHTMLParser.cpp
|
| @@ -62,6 +62,7 @@ BackgroundHTMLParser::BackgroundHTMLParser(PassOwnPtr<Configuration> config)
|
| , m_parser(config->parser)
|
| , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream))
|
| , m_decoder(TextResourceDecoder::create())
|
| + , m_source(config->source.Pass())
|
| , m_weakFactory(this)
|
| {
|
| }
|
| @@ -70,42 +71,37 @@ BackgroundHTMLParser::~BackgroundHTMLParser()
|
| {
|
| }
|
|
|
| -void BackgroundHTMLParser::appendRawBytesFromMainThread(PassOwnPtr<Vector<char> > buffer)
|
| +void BackgroundHTMLParser::start()
|
| {
|
| - updateDocument(m_decoder->decode(buffer->data(), buffer->size()));
|
| + m_drainer = adoptPtr(new DataPipeDrainer(this, m_source.Pass()));
|
| }
|
|
|
| -void BackgroundHTMLParser::appendDecodedBytes(const String& input)
|
| +void BackgroundHTMLParser::stop()
|
| {
|
| - ASSERT(!m_input.isClosed());
|
| - m_input.append(SegmentedString(input));
|
| - pumpTokenizer();
|
| + delete this;
|
| }
|
|
|
| -void BackgroundHTMLParser::flush()
|
| +void BackgroundHTMLParser::OnDataAvailable(const void* data, size_t numberOfBytes)
|
| {
|
| - updateDocument(m_decoder->flush());
|
| + ASSERT(!m_input.isClosed());
|
| + String input = m_decoder->decode(static_cast<const char*>(data), numberOfBytes);
|
| + m_input.append(SegmentedString(input));
|
| + pumpTokenizer();
|
| }
|
|
|
| -void BackgroundHTMLParser::updateDocument(const String& decodedData)
|
| +void BackgroundHTMLParser::OnDataComplete()
|
| {
|
| - if (decodedData.isEmpty())
|
| - return;
|
| -
|
| - appendDecodedBytes(decodedData);
|
| + ASSERT(!m_input.isClosed());
|
| + finish();
|
| }
|
|
|
| void BackgroundHTMLParser::finish()
|
| {
|
| + m_input.append(SegmentedString(m_decoder->flush()));
|
| markEndOfFile();
|
| pumpTokenizer();
|
| }
|
|
|
| -void BackgroundHTMLParser::stop()
|
| -{
|
| - delete this;
|
| -}
|
| -
|
| void BackgroundHTMLParser::markEndOfFile()
|
| {
|
| ASSERT(!m_input.isClosed());
|
|
|