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

Side by Side Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 2746333002: DevTools: move recurring flag into AsyncTask, control cancelation from embedder only. (Closed)
Patch Set: using _END now Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 DCHECK(getExecutionContext()); 951 DCHECK(getExecutionContext());
952 ExecutionContext& executionContext = *getExecutionContext(); 952 ExecutionContext& executionContext = *getExecutionContext();
953 953
954 m_sendFlag = true; 954 m_sendFlag = true;
955 // The presence of upload event listeners forces us to use preflighting 955 // The presence of upload event listeners forces us to use preflighting
956 // because POSTing to an URL that does not permit cross origin requests should 956 // because POSTing to an URL that does not permit cross origin requests should
957 // look exactly like POSTing to an URL that does not respond at all. 957 // look exactly like POSTing to an URL that does not respond at all.
958 // Also, only async requests support upload progress events. 958 // Also, only async requests support upload progress events.
959 bool uploadEvents = false; 959 bool uploadEvents = false;
960 if (m_async) { 960 if (m_async) {
961 probe::asyncTaskScheduled(&executionContext, "XMLHttpRequest.send", this, 961 probe::asyncTaskScheduled(&executionContext, "XMLHttpRequest.send", this);
962 true);
963 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); 962 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0);
964 // Event handler could have invalidated this send operation, 963 // Event handler could have invalidated this send operation,
965 // (re)setting the send flag and/or initiating another send 964 // (re)setting the send flag and/or initiating another send
966 // operation; leave quietly if so. 965 // operation; leave quietly if so.
967 if (!m_sendFlag || m_loader) 966 if (!m_sendFlag || m_loader)
968 return; 967 return;
969 if (httpBody && m_upload) { 968 if (httpBody && m_upload) {
970 uploadEvents = m_upload->hasEventListeners(); 969 uploadEvents = m_upload->hasEventListeners();
971 m_upload->dispatchEvent( 970 m_upload->dispatchEvent(
972 ProgressEvent::create(EventTypeNames::loadstart, false, 0, 0)); 971 ProgressEvent::create(EventTypeNames::loadstart, false, 0, 0));
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 long long receivedLength, 1208 long long receivedLength,
1210 long long expectedLength) { 1209 long long expectedLength) {
1211 bool lengthComputable = 1210 bool lengthComputable =
1212 expectedLength > 0 && receivedLength <= expectedLength; 1211 expectedLength > 0 && receivedLength <= expectedLength;
1213 unsigned long long loaded = 1212 unsigned long long loaded =
1214 receivedLength >= 0 ? static_cast<unsigned long long>(receivedLength) : 0; 1213 receivedLength >= 0 ? static_cast<unsigned long long>(receivedLength) : 0;
1215 unsigned long long total = 1214 unsigned long long total =
1216 lengthComputable ? static_cast<unsigned long long>(expectedLength) : 0; 1215 lengthComputable ? static_cast<unsigned long long>(expectedLength) : 0;
1217 1216
1218 ExecutionContext* context = getExecutionContext(); 1217 ExecutionContext* context = getExecutionContext();
1219 probe::AsyncTask asyncTask(context, this, m_async); 1218 probe::AsyncTask asyncTask(
1219 context, this, type == EventTypeNames::loadend ? nullptr : "progress",
1220 m_async);
1220 m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loaded, 1221 m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loaded,
1221 total); 1222 total);
1222 if (m_async && type == EventTypeNames::loadend)
1223 probe::asyncTaskCanceled(context, this);
1224 } 1223 }
1225 1224
1226 void XMLHttpRequest::dispatchProgressEventFromSnapshot( 1225 void XMLHttpRequest::dispatchProgressEventFromSnapshot(
1227 const AtomicString& type) { 1226 const AtomicString& type) {
1228 dispatchProgressEvent(type, m_receivedLength, 1227 dispatchProgressEvent(type, m_receivedLength,
1229 m_response.expectedContentLength()); 1228 m_response.expectedContentLength());
1230 } 1229 }
1231 1230
1232 void XMLHttpRequest::handleNetworkError() { 1231 void XMLHttpRequest::handleNetworkError() {
1233 NETWORK_DVLOG(1) << this << " handleNetworkError()"; 1232 NETWORK_DVLOG(1) << this << " handleNetworkError()";
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 visitor->traceWrappers(m_responseDocument); 1893 visitor->traceWrappers(m_responseDocument);
1895 visitor->traceWrappers(m_responseArrayBuffer); 1894 visitor->traceWrappers(m_responseArrayBuffer);
1896 XMLHttpRequestEventTarget::traceWrappers(visitor); 1895 XMLHttpRequestEventTarget::traceWrappers(visitor);
1897 } 1896 }
1898 1897
1899 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { 1898 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) {
1900 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); 1899 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr);
1901 } 1900 }
1902 1901
1903 } // namespace blink 1902 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698