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

Side by Side 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 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 917
918 m_exceptionCode = 0; 918 m_exceptionCode = 0;
919 m_error = false; 919 m_error = false;
920 920
921 if (m_async) { 921 if (m_async) {
922 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestAsynchron ous); 922 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestAsynchron ous);
923 if (m_upload) 923 if (m_upload)
924 request.setReportUploadProgress(true); 924 request.setReportUploadProgress(true);
925 925
926 ASSERT(!m_loader); 926 ASSERT(!m_loader);
927 InspectorInstrumentation::scheduleAsyncTask(&executionContext, "XMLHttpR equest", this);
927 m_loader = ThreadableLoader::create(executionContext, this, options, res ourceLoaderOptions); 928 m_loader = ThreadableLoader::create(executionContext, this, options, res ourceLoaderOptions);
928 m_loader->start(request); 929 m_loader->start(request);
929 930
930 return; 931 return;
931 } 932 }
932 933
933 // Use count for XHR synchronous requests. 934 // Use count for XHR synchronous requests.
934 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous); 935 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
935 ThreadableLoader::loadResourceSynchronously(executionContext, request, *this , options, resourceLoaderOptions); 936 ThreadableLoader::loadResourceSynchronously(executionContext, request, *this , options, resourceLoaderOptions);
936 937
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 { 1064 {
1064 m_requestHeaders.clear(); 1065 m_requestHeaders.clear();
1065 } 1066 }
1066 1067
1067 void XMLHttpRequest::dispatchProgressEvent(const AtomicString& type, long long r eceivedLength, long long expectedLength) 1068 void XMLHttpRequest::dispatchProgressEvent(const AtomicString& type, long long r eceivedLength, long long expectedLength)
1068 { 1069 {
1069 bool lengthComputable = expectedLength > 0 && receivedLength <= expectedLeng th; 1070 bool lengthComputable = expectedLength > 0 && receivedLength <= expectedLeng th;
1070 unsigned long long loaded = receivedLength >= 0 ? static_cast<unsigned long long>(receivedLength) : 0; 1071 unsigned long long loaded = receivedLength >= 0 ? static_cast<unsigned long long>(receivedLength) : 0;
1071 unsigned long long total = lengthComputable ? static_cast<unsigned long long >(expectedLength) : 0; 1072 unsigned long long total = lengthComputable ? static_cast<unsigned long long >(expectedLength) : 0;
1072 1073
1074 Optional<InspectorInstrumentation::AsyncTask> asyncTask;
1075 if (type == EventTypeNames::loadend)
1076 InspectorInstrumentation::asyncTaskStarted(getExecutionContext(), this);
1073 m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loade d, total); 1077 m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loade d, total);
1074
1075 if (type == EventTypeNames::loadend) 1078 if (type == EventTypeNames::loadend)
1076 InspectorInstrumentation::didDispatchXHRLoadendEvent(getExecutionContext (), this); 1079 InspectorInstrumentation::asyncTaskFinished(getExecutionContext(), this) ;
1077 } 1080 }
1078 1081
1079 void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type) 1082 void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type)
1080 { 1083 {
1081 dispatchProgressEvent(type, m_receivedLength, m_response.expectedContentLeng th()); 1084 dispatchProgressEvent(type, m_receivedLength, m_response.expectedContentLeng th());
1082 } 1085 }
1083 1086
1084 void XMLHttpRequest::handleNetworkError() 1087 void XMLHttpRequest::handleNetworkError()
1085 { 1088 {
1086 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this); 1089 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this);
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 visitor->trace(m_responseDocumentParser); 1706 visitor->trace(m_responseDocumentParser);
1704 visitor->trace(m_progressEventThrottle); 1707 visitor->trace(m_progressEventThrottle);
1705 visitor->trace(m_upload); 1708 visitor->trace(m_upload);
1706 visitor->trace(m_blobLoader); 1709 visitor->trace(m_blobLoader);
1707 XMLHttpRequestEventTarget::trace(visitor); 1710 XMLHttpRequestEventTarget::trace(visitor);
1708 DocumentParserClient::trace(visitor); 1711 DocumentParserClient::trace(visitor);
1709 ActiveDOMObject::trace(visitor); 1712 ActiveDOMObject::trace(visitor);
1710 } 1713 }
1711 1714
1712 } // namespace blink 1715 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698