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

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

Issue 1179903003: [DevTools] Log failed XHR requests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 { 335 {
336 RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = adoptRefWillBeNoop(new X MLHttpRequest(context, nullptr)); 336 RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = adoptRefWillBeNoop(new X MLHttpRequest(context, nullptr));
337 xmlHttpRequest->suspendIfNeeded(); 337 xmlHttpRequest->suspendIfNeeded();
338 338
339 return xmlHttpRequest.release(); 339 return xmlHttpRequest.release();
340 } 340 }
341 341
342 XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, PassRefPtr<SecurityOri gin> securityOrigin) 342 XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, PassRefPtr<SecurityOri gin> securityOrigin)
343 : ActiveDOMObject(context) 343 : ActiveDOMObject(context)
344 , m_timeoutMilliseconds(0) 344 , m_timeoutMilliseconds(0)
345 , m_loaderIdentifier(0)
346 , m_state(UNSENT) 345 , m_state(UNSENT)
347 , m_lengthDownloadedToFile(0) 346 , m_lengthDownloadedToFile(0)
348 , m_receivedLength(0) 347 , m_receivedLength(0)
349 , m_exceptionCode(0) 348 , m_exceptionCode(0)
350 , m_progressEventThrottle(this) 349 , m_progressEventThrottle(this)
351 , m_responseTypeCode(ResponseTypeDefault) 350 , m_responseTypeCode(ResponseTypeDefault)
352 , m_securityOrigin(securityOrigin) 351 , m_securityOrigin(securityOrigin)
353 , m_eventDispatchRecursionLevel(0) 352 , m_eventDispatchRecursionLevel(0)
354 , m_async(true) 353 , m_async(true)
355 , m_includeCredentials(false) 354 , m_includeCredentials(false)
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1140
1142 bool XMLHttpRequest::internalAbort() 1141 bool XMLHttpRequest::internalAbort()
1143 { 1142 {
1144 m_error = true; 1143 m_error = true;
1145 1144
1146 if (m_responseDocumentParser && !m_responseDocumentParser->isStopped()) 1145 if (m_responseDocumentParser && !m_responseDocumentParser->isStopped())
1147 m_responseDocumentParser->stopParsing(); 1146 m_responseDocumentParser->stopParsing();
1148 1147
1149 clearVariablesForLoading(); 1148 clearVariablesForLoading();
1150 1149
1151 InspectorInstrumentation::didFailXHRLoading(executionContext(), this, this);
1152
1153 if (m_responseLegacyStream && m_state != DONE) 1150 if (m_responseLegacyStream && m_state != DONE)
1154 m_responseLegacyStream->abort(); 1151 m_responseLegacyStream->abort();
1155 1152
1156 if (m_responseStream) { 1153 if (m_responseStream) {
1157 // When the stream is already closed (including canceled from the 1154 // When the stream is already closed (including canceled from the
1158 // user), |error| does nothing. 1155 // user), |error| does nothing.
1159 // FIXME: Create a more specific error. 1156 // FIXME: Create a more specific error.
1160 m_responseStream->error(DOMException::create(!m_async && m_exceptionCode ? m_exceptionCode : AbortError, "XMLHttpRequest::abort")); 1157 m_responseStream->error(DOMException::create(!m_async && m_exceptionCode ? m_exceptionCode : AbortError, "XMLHttpRequest::abort"));
1161 } 1158 }
1162 1159
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 if (!internalAbort()) 1258 if (!internalAbort())
1262 return; 1259 return;
1263 1260
1264 handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expect edLength); 1261 handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expect edLength);
1265 } 1262 }
1266 1263
1267 void XMLHttpRequest::handleRequestError(ExceptionCode exceptionCode, const Atomi cString& type, long long receivedLength, long long expectedLength) 1264 void XMLHttpRequest::handleRequestError(ExceptionCode exceptionCode, const Atomi cString& type, long long receivedLength, long long expectedLength)
1268 { 1265 {
1269 WTF_LOG(Network, "XMLHttpRequest %p handleRequestError()", this); 1266 WTF_LOG(Network, "XMLHttpRequest %p handleRequestError()", this);
1270 1267
1268 InspectorInstrumentation::didFailXHRLoading(executionContext(), this, this, m_method, m_url);
1269
1271 // The request error steps for event 'type' and exception 'exceptionCode'. 1270 // The request error steps for event 'type' and exception 'exceptionCode'.
1272 1271
1273 if (!m_async && exceptionCode) { 1272 if (!m_async && exceptionCode) {
1274 m_state = DONE; 1273 m_state = DONE;
1275 m_exceptionCode = exceptionCode; 1274 m_exceptionCode = exceptionCode;
1276 return; 1275 return;
1277 } 1276 }
1278 // With m_error set, the state change steps are minimal: any pending 1277 // With m_error set, the state change steps are minimal: any pending
1279 // progress event is flushed + a readystatechange is dispatched. 1278 // progress event is flushed + a readystatechange is dispatched.
1280 // No new progress events dispatched; as required, that happens at 1279 // No new progress events dispatched; as required, that happens at
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 { 1495 {
1497 WTF_LOG(Network, "XMLHttpRequest %p didFinishLoading(%lu)", this, identifier ); 1496 WTF_LOG(Network, "XMLHttpRequest %p didFinishLoading(%lu)", this, identifier );
1498 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1497 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1499 1498
1500 if (m_error) 1499 if (m_error)
1501 return; 1500 return;
1502 1501
1503 if (m_state < HEADERS_RECEIVED) 1502 if (m_state < HEADERS_RECEIVED)
1504 changeState(HEADERS_RECEIVED); 1503 changeState(HEADERS_RECEIVED);
1505 1504
1506 m_loaderIdentifier = identifier;
1507
1508 if (m_downloadingToFile && m_responseTypeCode != ResponseTypeBlob && m_lengt hDownloadedToFile) { 1505 if (m_downloadingToFile && m_responseTypeCode != ResponseTypeBlob && m_lengt hDownloadedToFile) {
1509 ASSERT(m_state == LOADING); 1506 ASSERT(m_state == LOADING);
1510 // In this case, we have sent the request with DownloadToFile true, 1507 // In this case, we have sent the request with DownloadToFile true,
1511 // but the user changed the response type after that. Hence we need to 1508 // but the user changed the response type after that. Hence we need to
1512 // read the response data and provide it to this object. 1509 // read the response data and provide it to this object.
1513 m_blobLoader = BlobLoader::create(this, createBlobDataHandleFromResponse ()); 1510 m_blobLoader = BlobLoader::create(this, createBlobDataHandleFromResponse ());
1514 } else { 1511 } else {
1515 didFinishLoadingInternal(); 1512 didFinishLoadingInternal();
1516 } 1513 }
1517 } 1514 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 if (!m_responseDocument->wellFormed()) 1598 if (!m_responseDocument->wellFormed())
1602 m_responseDocument = nullptr; 1599 m_responseDocument = nullptr;
1603 1600
1604 m_parsedResponse = true; 1601 m_parsedResponse = true;
1605 1602
1606 endLoading(); 1603 endLoading();
1607 } 1604 }
1608 1605
1609 void XMLHttpRequest::endLoading() 1606 void XMLHttpRequest::endLoading()
1610 { 1607 {
1611 InspectorInstrumentation::didFinishXHRLoading(executionContext(), this, this , m_loaderIdentifier, m_responseText, m_method, m_url); 1608 InspectorInstrumentation::didFinishXHRLoading(executionContext(), this, this , m_method, m_url);
1612 1609
1613 if (m_loader) 1610 if (m_loader)
1614 m_loader = nullptr; 1611 m_loader = nullptr;
1615 m_loaderIdentifier = 0;
1616 1612
1617 changeState(DONE); 1613 changeState(DONE);
1618 1614
1619 if (!executionContext()->isDocument() || !document() || !document()->frame() || !document()->frame()->page()) 1615 if (!executionContext()->isDocument() || !document() || !document()->frame() || !document()->frame()->page())
1620 return; 1616 return;
1621 1617
1622 if (status() >= 200 && status() < 300) 1618 if (status() >= 200 && status() < 300)
1623 document()->frame()->page()->chromeClient().xhrSucceeded(document()->fra me()); 1619 document()->frame()->page()->chromeClient().xhrSucceeded(document()->fra me());
1624 } 1620 }
1625 1621
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 m_progressEventThrottle.suspend(); 1810 m_progressEventThrottle.suspend();
1815 } 1811 }
1816 1812
1817 void XMLHttpRequest::resume() 1813 void XMLHttpRequest::resume()
1818 { 1814 {
1819 m_progressEventThrottle.resume(); 1815 m_progressEventThrottle.resume();
1820 } 1816 }
1821 1817
1822 void XMLHttpRequest::stop() 1818 void XMLHttpRequest::stop()
1823 { 1819 {
1820 InspectorInstrumentation::didFailXHRLoading(executionContext(), this, this, m_method, m_url);
1824 internalAbort(); 1821 internalAbort();
1825 } 1822 }
1826 1823
1827 bool XMLHttpRequest::hasPendingActivity() const 1824 bool XMLHttpRequest::hasPendingActivity() const
1828 { 1825 {
1829 // Neither this object nor the JavaScript wrapper should be deleted while 1826 // Neither this object nor the JavaScript wrapper should be deleted while
1830 // a request is in progress because we need to keep the listeners alive, 1827 // a request is in progress because we need to keep the listeners alive,
1831 // and they are referenced by the JavaScript wrapper. 1828 // and they are referenced by the JavaScript wrapper.
1832 // |m_loader| is non-null while request is active and ThreadableLoaderClient 1829 // |m_loader| is non-null while request is active and ThreadableLoaderClient
1833 // callbacks may be called, and |m_responseDocumentParser| is non-null while 1830 // callbacks may be called, and |m_responseDocumentParser| is non-null while
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 visitor->trace(m_responseDocumentParser); 1862 visitor->trace(m_responseDocumentParser);
1866 visitor->trace(m_progressEventThrottle); 1863 visitor->trace(m_progressEventThrottle);
1867 visitor->trace(m_upload); 1864 visitor->trace(m_upload);
1868 visitor->trace(m_blobLoader); 1865 visitor->trace(m_blobLoader);
1869 XMLHttpRequestEventTarget::trace(visitor); 1866 XMLHttpRequestEventTarget::trace(visitor);
1870 DocumentParserClient::trace(visitor); 1867 DocumentParserClient::trace(visitor);
1871 ActiveDOMObject::trace(visitor); 1868 ActiveDOMObject::trace(visitor);
1872 } 1869 }
1873 1870
1874 } // namespace blink 1871 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698