Index: Source/core/xml/XMLHttpRequest.cpp |
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp |
index 5d1979176606a13ed6a09d9ed92e6b2ea6dbbf97..63dbcd717f610a94342eac65d6ea75eeb4cf8830 100644 |
--- a/Source/core/xml/XMLHttpRequest.cpp |
+++ b/Source/core/xml/XMLHttpRequest.cpp |
@@ -131,6 +131,13 @@ private: |
RawPtrWillBeMember<XMLHttpRequest> m_owner; |
}; |
+HashMap<Document*, XMLHttpRequest*>& xhrPendingDocumentParseMap() |
+{ |
+ typedef HashMap<Document*, XMLHttpRequest*> XHRPendingDocumentParseMap; |
+ DEFINE_STATIC_LOCAL(XHRPendingDocumentParseMap, map, ()); |
+ return map; |
+} |
+ |
} // namespace |
PassRefPtrWillBeRawPtr<XMLHttpRequest> XMLHttpRequest::create(ExecutionContext* context, PassRefPtr<SecurityOrigin> securityOrigin) |
@@ -144,6 +151,7 @@ PassRefPtrWillBeRawPtr<XMLHttpRequest> XMLHttpRequest::create(ExecutionContext* |
XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, PassRefPtr<SecurityOrigin> securityOrigin) |
: ActiveDOMObject(context) |
, m_timeoutMilliseconds(0) |
+ , m_loaderIdentifier(0) |
, m_state(UNSENT) |
, m_downloadedBlobLength(0) |
, m_receivedLength(0) |
@@ -249,8 +257,9 @@ Document* XMLHttpRequest::responseXML(ExceptionState& exceptionState) |
return nullptr; |
m_responseDocument->setContent(m_responseText.flattenToString()); |
- if (!m_responseDocument->wellFormed()) |
+ if (!m_responseDocument->wellFormed()) { |
tyoshino (SeeGerritForStatus)
2014/09/01 05:28:02
maybe you left this after removing additional line
kouhei (in TOK)
2014/09/01 20:44:28
Done.
|
m_responseDocument = nullptr; |
+ } |
m_parsedResponse = true; |
} |
@@ -935,6 +944,15 @@ bool XMLHttpRequest::internalAbort() |
InspectorInstrumentation::didFailXHRLoading(executionContext(), this, this); |
+ // FIXME: abort parser |
kouhei (in TOK)
2014/09/01 20:44:28
Removed this comment, as this is addressed in the
|
+ HashMap<Document*, XMLHttpRequest*>& map = xhrPendingDocumentParseMap(); |
+ for (HashMap<Document*, XMLHttpRequest*>::iterator it = map.begin(), itEnd = map.end(); it != itEnd; ++it) { |
+ if (it->value == this) { |
+ map.remove(it); |
+ break; |
+ } |
+ } |
+ |
if (m_responseLegacyStream && m_state != DONE) |
m_responseLegacyStream->abort(); |
@@ -1283,19 +1301,21 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) |
if (m_state < HEADERS_RECEIVED) |
changeState(HEADERS_RECEIVED); |
+ m_loaderIdentifier = identifier; |
+ |
if (m_responseDocumentParser) { |
m_responseDocumentParser->finish(); |
- m_responseDocumentParser = nullptr; |
- |
- m_responseDocument->implicitClose(); |
+ ASSERT(m_responseDocument); |
- if (!m_responseDocument->wellFormed()) |
- m_responseDocument = nullptr; |
+ HashMap<Document*, XMLHttpRequest*>& map = xhrPendingDocumentParseMap(); |
+ HashMap<Document*, XMLHttpRequest*>::AddResult result = map.set(m_responseDocument.get(), this); |
+ ASSERT_UNUSED(result, result.isNewEntry); |
+ // progress state in didFinishParsingDocument |
+ return; |
+ } |
- m_parsedResponse = true; |
- } else if (m_decoder) { |
+ if (m_decoder) |
m_responseText = m_responseText.concatenateWith(m_decoder->flush()); |
- } |
if (m_responseLegacyStream) |
m_responseLegacyStream->finalize(); |
@@ -1303,12 +1323,42 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) |
if (m_responseStream) |
m_responseStream->close(); |
+ endLoading(); |
+} |
+ |
+XMLHttpRequest* XMLHttpRequest::findInstancePendingDocumentParse(Document* document) |
+{ |
+ return xhrPendingDocumentParseMap().get(document); |
+} |
+ |
+void XMLHttpRequest::didFinishParsingDocument() |
+{ |
+ // This should only be called when response document is asynchronous parsed. |
tyoshino (SeeGerritForStatus)
2014/09/01 05:28:03
asynchronously
|
+ ASSERT(m_responseDocumentParser); |
+ ASSERT(!m_responseDocumentParser->isParsing()); |
+ ASSERT(!m_responseLegacyStream); |
+ ASSERT(!m_responseStream); |
+ |
+ m_responseDocumentParser = nullptr; |
+ m_responseDocument->implicitClose(); |
+ |
+ if (!m_responseDocument->wellFormed()) |
+ m_responseDocument = nullptr; |
+ |
+ m_parsedResponse = true; |
+ |
+ endLoading(); |
+} |
+ |
+void XMLHttpRequest::endLoading() |
+{ |
clearVariablesForLoading(); |
- InspectorInstrumentation::didFinishXHRLoading(executionContext(), this, this, identifier, m_responseText, m_method, m_url, m_lastSendURL, m_lastSendLineNumber); |
+ InspectorInstrumentation::didFinishXHRLoading(executionContext(), this, this, m_loaderIdentifier, m_responseText, m_method, m_url, m_lastSendURL, m_lastSendLineNumber); |
if (m_loader) |
m_loader = nullptr; |
+ m_loaderIdentifier = 0; |
changeState(DONE); |
} |