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

Unified Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 2649323005: Cleanly detach XHR and other pending loader clients from Inspector. (Closed)
Patch Set: rebalance XHR disposal steps Created 3 years, 11 months 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
Index: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
index 5e72a29c9afc3c8ba06b9c108e09435ff03696a5..d86b35b94d482042a9dd30c287783a6c496416b9 100644
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -1094,10 +1094,9 @@ void XMLHttpRequest::abort() {
}
void XMLHttpRequest::dispose() {
- if (m_loader) {
- m_error = true;
- m_loader->cancel();
- }
+ InspectorInstrumentation::detachClientRequest(getExecutionContext(), this);
+ m_progressEventThrottle->stop();
+ internalAbort();
}
void XMLHttpRequest::clearVariablesForLoading() {
@@ -1118,6 +1117,12 @@ void XMLHttpRequest::clearVariablesForLoading() {
}
bool XMLHttpRequest::internalAbort() {
+ // Fast path for repeated internalAbort()s; this
+ // will happen if an XHR object is notified of context
+ // destruction followed by finalization.
+ if (m_error && !m_loader)
+ return true;
+
m_error = true;
if (m_responseDocumentParser && !m_responseDocumentParser->isStopped())
@@ -1808,10 +1813,7 @@ void XMLHttpRequest::resume() {
}
void XMLHttpRequest::contextDestroyed(ExecutionContext*) {
- InspectorInstrumentation::didFailXHRLoading(getExecutionContext(), this, this,
- m_method, m_url);
- m_progressEventThrottle->stop();
- internalAbort();
+ dispose();
// In case we are in the middle of send() function, unset the send flag to
// stop the operation.

Powered by Google App Engine
This is Rietveld 408576698