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

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

Issue 1857713004: DevTools: simplify the async instrumentation harness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 e1ff6b8ca52763a045eb6654ec6b267bfc60ea12..ed385f434241bf5d07c73495fa1c4c8716af01c8 100644
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -856,11 +856,15 @@ void XMLHttpRequest::createRequest(PassRefPtr<EncodedFormData> httpBody, Excepti
return;
}
+ ASSERT(getExecutionContext());
+ ExecutionContext& executionContext = *this->getExecutionContext();
+
// The presence of upload event listeners forces us to use preflighting because POSTing to an URL that does not
// permit cross origin requests should look exactly like POSTing to an URL that does not respond at all.
// Also, only async requests support upload progress events.
bool uploadEvents = false;
if (m_async) {
+ InspectorInstrumentation::asyncTaskScheduled(&executionContext, "XMLHttpRequest.send", this, true);
dispatchProgressEvent(EventTypeNames::loadstart, 0, 0);
if (httpBody && m_upload) {
uploadEvents = m_upload->hasEventListeners();
@@ -874,9 +878,6 @@ void XMLHttpRequest::createRequest(PassRefPtr<EncodedFormData> httpBody, Excepti
// added after the request is started.
m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !FetchUtils::isSimpleRequest(m_method, m_requestHeaders);
- ASSERT(getExecutionContext());
- ExecutionContext& executionContext = *this->getExecutionContext();
-
ResourceRequest request(m_url);
request.setHTTPMethod(m_method);
request.setRequestContext(WebURLRequest::RequestContextXMLHttpRequest);
@@ -1068,10 +1069,11 @@ void XMLHttpRequest::dispatchProgressEvent(const AtomicString& type, long long r
unsigned long long loaded = receivedLength >= 0 ? static_cast<unsigned long long>(receivedLength) : 0;
unsigned long long total = lengthComputable ? static_cast<unsigned long long>(expectedLength) : 0;
+ ExecutionContext* context = getExecutionContext();
+ InspectorInstrumentation::AsyncTask asyncTask(context, this, m_async);
m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loaded, total);
-
- if (type == EventTypeNames::loadend)
- InspectorInstrumentation::didDispatchXHRLoadendEvent(getExecutionContext(), this);
+ if (m_async && type == EventTypeNames::loadend)
+ InspectorInstrumentation::asyncTaskCanceled(context, this);
}
void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type)

Powered by Google App Engine
This is Rietveld 408576698