Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: Source/core/dom/DecodedDataDocumentParser.cpp

Issue 69823002: Move ownership of the TextResourceDecoder to DecodedDataDocumentParser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review fixes Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/DecodedDataDocumentParser.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DecodedDataDocumentParser.cpp
diff --git a/Source/core/dom/DecodedDataDocumentParser.cpp b/Source/core/dom/DecodedDataDocumentParser.cpp
index c7345802679b21dac20c0f7e65112e52d94d6bf5..d6c8f89b45f03f82afd6d2866967a03d1b4dbfc9 100644
--- a/Source/core/dom/DecodedDataDocumentParser.cpp
+++ b/Source/core/dom/DecodedDataDocumentParser.cpp
@@ -27,6 +27,7 @@
#include "core/dom/DecodedDataDocumentParser.h"
#include "core/dom/Document.h"
+#include "core/dom/DocumentEncodingData.h"
#include "core/fetch/TextResourceDecoder.h"
namespace WebCore {
@@ -36,6 +37,20 @@ DecodedDataDocumentParser::DecodedDataDocumentParser(Document* document)
{
}
+DecodedDataDocumentParser::~DecodedDataDocumentParser()
+{
+}
+
+void DecodedDataDocumentParser::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
+{
+ m_decoder = decoder;
+}
+
+PassRefPtr<TextResourceDecoder> DecodedDataDocumentParser::decoder()
+{
+ return m_decoder;
+}
+
size_t DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
{
if (!length)
@@ -47,8 +62,8 @@ size_t DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
if (isDetached())
return 0;
- String decoded = document()->decoder()->decode(data, length);
- document()->setEncoding(document()->decoder()->encoding());
+ String decoded = m_decoder->decode(data, length);
+ updateDocumentEncoding();
if (decoded.isEmpty())
return 0;
@@ -69,11 +84,11 @@ size_t DecodedDataDocumentParser::flush()
// null decoder indicates there is no data received.
// We have nothing to do in that case.
- TextResourceDecoder* decoder = document()->decoder();
- if (!decoder)
+ if (!m_decoder)
return 0;
- String remainingData = decoder->flush();
- document()->setEncoding(document()->decoder()->encoding());
+ String remainingData = m_decoder->flush();
+ updateDocumentEncoding();
+
if (remainingData.isEmpty())
return 0;
@@ -83,4 +98,13 @@ size_t DecodedDataDocumentParser::flush()
return consumedChars;
}
+void DecodedDataDocumentParser::updateDocumentEncoding()
+{
+ DocumentEncodingData encodingData;
+ encodingData.encoding = m_decoder->encoding();
+ encodingData.wasDetectedHeuristically = m_decoder->encodingWasDetectedHeuristically();
+ encodingData.sawDecodingError = m_decoder->sawError();
+ document()->setEncodingData(encodingData);
+}
+
};
« no previous file with comments | « Source/core/dom/DecodedDataDocumentParser.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698