| OLD | NEW |
| 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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 if (!m_loader) | 971 if (!m_loader) |
| 972 return true; | 972 return true; |
| 973 | 973 |
| 974 // Cancelling the ThreadableLoader m_loader may result in calling | 974 // Cancelling the ThreadableLoader m_loader may result in calling |
| 975 // window.onload synchronously. If such an onload handler contains open() | 975 // window.onload synchronously. If such an onload handler contains open() |
| 976 // call on the same XMLHttpRequest object, reentry happens. | 976 // call on the same XMLHttpRequest object, reentry happens. |
| 977 // | 977 // |
| 978 // If, window.onload contains open() and send(), m_loader will be set to | 978 // If, window.onload contains open() and send(), m_loader will be set to |
| 979 // non 0 value. So, we cannot continue the outer open(). In such case, | 979 // non 0 value. So, we cannot continue the outer open(). In such case, |
| 980 // just abort the outer open() by returning false. | 980 // just abort the outer open() by returning false. |
| 981 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); | |
| 982 RefPtr<ThreadableLoader> loader = m_loader.release(); | 981 RefPtr<ThreadableLoader> loader = m_loader.release(); |
| 983 loader->cancel(); | 982 loader->cancel(); |
| 984 | 983 |
| 985 // If abort() called internalAbort() and a nested open() ended up | 984 // If abort() called internalAbort() and a nested open() ended up |
| 986 // clearing the error flag, but didn't send(), make sure the error | 985 // clearing the error flag, but didn't send(), make sure the error |
| 987 // flag is still set. | 986 // flag is still set. |
| 988 bool newLoadStarted = hasPendingActivity(); | 987 bool newLoadStarted = hasPendingActivity(); |
| 989 if (!newLoadStarted) | 988 if (!newLoadStarted) |
| 990 m_error = true; | 989 m_error = true; |
| 991 | 990 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 } | 1041 } |
| 1043 | 1042 |
| 1044 void XMLHttpRequest::handleNetworkError() | 1043 void XMLHttpRequest::handleNetworkError() |
| 1045 { | 1044 { |
| 1046 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this); | 1045 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this); |
| 1047 | 1046 |
| 1048 // Response is cleared next, save needed progress event data. | 1047 // Response is cleared next, save needed progress event data. |
| 1049 long long expectedLength = m_response.expectedContentLength(); | 1048 long long expectedLength = m_response.expectedContentLength(); |
| 1050 long long receivedLength = m_receivedLength; | 1049 long long receivedLength = m_receivedLength; |
| 1051 | 1050 |
| 1051 // Prevent the XMLHttpRequest instance from being destoryed during |
| 1052 // |internalAbort()|. |
| 1053 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); |
| 1054 |
| 1052 if (!internalAbort()) | 1055 if (!internalAbort()) |
| 1053 return; | 1056 return; |
| 1054 | 1057 |
| 1055 handleRequestError(NetworkError, EventTypeNames::error, receivedLength, expe
ctedLength); | 1058 handleRequestError(NetworkError, EventTypeNames::error, receivedLength, expe
ctedLength); |
| 1056 } | 1059 } |
| 1057 | 1060 |
| 1058 void XMLHttpRequest::handleDidCancel() | 1061 void XMLHttpRequest::handleDidCancel() |
| 1059 { | 1062 { |
| 1060 WTF_LOG(Network, "XMLHttpRequest %p handleDidCancel()", this); | 1063 WTF_LOG(Network, "XMLHttpRequest %p handleDidCancel()", this); |
| 1061 | 1064 |
| 1062 // Response is cleared next, save needed progress event data. | 1065 // Response is cleared next, save needed progress event data. |
| 1063 long long expectedLength = m_response.expectedContentLength(); | 1066 long long expectedLength = m_response.expectedContentLength(); |
| 1064 long long receivedLength = m_receivedLength; | 1067 long long receivedLength = m_receivedLength; |
| 1065 | 1068 |
| 1069 // Prevent the XMLHttpRequest instance from being destoryed during |
| 1070 // |internalAbort()|. |
| 1071 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); |
| 1072 |
| 1066 if (!internalAbort()) | 1073 if (!internalAbort()) |
| 1067 return; | 1074 return; |
| 1068 | 1075 |
| 1069 handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expect
edLength); | 1076 handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expect
edLength); |
| 1070 } | 1077 } |
| 1071 | 1078 |
| 1072 void XMLHttpRequest::handleRequestError(ExceptionCode exceptionCode, const Atomi
cString& type, long long receivedLength, long long expectedLength) | 1079 void XMLHttpRequest::handleRequestError(ExceptionCode exceptionCode, const Atomi
cString& type, long long receivedLength, long long expectedLength) |
| 1073 { | 1080 { |
| 1074 WTF_LOG(Network, "XMLHttpRequest %p handleRequestError()", this); | 1081 WTF_LOG(Network, "XMLHttpRequest %p handleRequestError()", this); |
| 1075 | 1082 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 void XMLHttpRequest::didFail(const ResourceError& error) | 1269 void XMLHttpRequest::didFail(const ResourceError& error) |
| 1263 { | 1270 { |
| 1264 WTF_LOG(Network, "XMLHttpRequest %p didFail()", this); | 1271 WTF_LOG(Network, "XMLHttpRequest %p didFail()", this); |
| 1265 | 1272 |
| 1266 // If we are already in an error state, for instance we called abort(), bail
out early. | 1273 // If we are already in an error state, for instance we called abort(), bail
out early. |
| 1267 if (m_error) | 1274 if (m_error) |
| 1268 return; | 1275 return; |
| 1269 | 1276 |
| 1270 if (error.isCancellation()) { | 1277 if (error.isCancellation()) { |
| 1271 handleDidCancel(); | 1278 handleDidCancel(); |
| 1279 // Now the XMLHttpRequest instance may be dead. |
| 1272 return; | 1280 return; |
| 1273 } | 1281 } |
| 1274 | 1282 |
| 1275 if (error.isTimeout()) { | 1283 if (error.isTimeout()) { |
| 1276 handleDidTimeout(); | 1284 handleDidTimeout(); |
| 1285 // Now the XMLHttpRequest instance may be dead. |
| 1277 return; | 1286 return; |
| 1278 } | 1287 } |
| 1279 | 1288 |
| 1280 // Network failures are already reported to Web Inspector by ResourceLoader. | 1289 // Network failures are already reported to Web Inspector by ResourceLoader. |
| 1281 if (error.domain() == errorDomainBlinkInternal) | 1290 if (error.domain() == errorDomainBlinkInternal) |
| 1282 logConsoleError(executionContext(), "XMLHttpRequest cannot load " + erro
r.failingURL() + ". " + error.localizedDescription()); | 1291 logConsoleError(executionContext(), "XMLHttpRequest cannot load " + erro
r.failingURL() + ". " + error.localizedDescription()); |
| 1283 | 1292 |
| 1284 handleNetworkError(); | 1293 handleNetworkError(); |
| 1294 // Now the XMLHttpRequest instance may be dead. |
| 1285 } | 1295 } |
| 1286 | 1296 |
| 1287 void XMLHttpRequest::didFailRedirectCheck() | 1297 void XMLHttpRequest::didFailRedirectCheck() |
| 1288 { | 1298 { |
| 1289 WTF_LOG(Network, "XMLHttpRequest %p didFailRedirectCheck()", this); | 1299 WTF_LOG(Network, "XMLHttpRequest %p didFailRedirectCheck()", this); |
| 1290 | 1300 |
| 1291 handleNetworkError(); | 1301 handleNetworkError(); |
| 1302 // Now the XMLHttpRequest instance may be dead. |
| 1292 } | 1303 } |
| 1293 | 1304 |
| 1294 void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) | 1305 void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) |
| 1295 { | 1306 { |
| 1296 WTF_LOG(Network, "XMLHttpRequest %p didFinishLoading(%lu)", this, identifier
); | 1307 WTF_LOG(Network, "XMLHttpRequest %p didFinishLoading(%lu)", this, identifier
); |
| 1297 | 1308 |
| 1298 if (m_error) | 1309 if (m_error) |
| 1299 return; | 1310 return; |
| 1300 | 1311 |
| 1301 if (m_state < HEADERS_RECEIVED) | 1312 if (m_state < HEADERS_RECEIVED) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 } | 1519 } |
| 1509 | 1520 |
| 1510 void XMLHttpRequest::handleDidTimeout() | 1521 void XMLHttpRequest::handleDidTimeout() |
| 1511 { | 1522 { |
| 1512 WTF_LOG(Network, "XMLHttpRequest %p handleDidTimeout()", this); | 1523 WTF_LOG(Network, "XMLHttpRequest %p handleDidTimeout()", this); |
| 1513 | 1524 |
| 1514 // Response is cleared next, save needed progress event data. | 1525 // Response is cleared next, save needed progress event data. |
| 1515 long long expectedLength = m_response.expectedContentLength(); | 1526 long long expectedLength = m_response.expectedContentLength(); |
| 1516 long long receivedLength = m_receivedLength; | 1527 long long receivedLength = m_receivedLength; |
| 1517 | 1528 |
| 1529 // Prevent the XMLHttpRequest instance from being destoryed during |
| 1530 // |internalAbort()|. |
| 1531 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); |
| 1532 |
| 1518 if (!internalAbort()) | 1533 if (!internalAbort()) |
| 1519 return; | 1534 return; |
| 1520 | 1535 |
| 1521 handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, ex
pectedLength); | 1536 handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, ex
pectedLength); |
| 1522 } | 1537 } |
| 1523 | 1538 |
| 1524 void XMLHttpRequest::suspend() | 1539 void XMLHttpRequest::suspend() |
| 1525 { | 1540 { |
| 1526 m_progressEventThrottle.suspend(); | 1541 m_progressEventThrottle.suspend(); |
| 1527 } | 1542 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 visitor->trace(m_responseStream); | 1585 visitor->trace(m_responseStream); |
| 1571 visitor->trace(m_streamSource); | 1586 visitor->trace(m_streamSource); |
| 1572 visitor->trace(m_responseDocument); | 1587 visitor->trace(m_responseDocument); |
| 1573 visitor->trace(m_responseDocumentParser); | 1588 visitor->trace(m_responseDocumentParser); |
| 1574 visitor->trace(m_progressEventThrottle); | 1589 visitor->trace(m_progressEventThrottle); |
| 1575 visitor->trace(m_upload); | 1590 visitor->trace(m_upload); |
| 1576 XMLHttpRequestEventTarget::trace(visitor); | 1591 XMLHttpRequestEventTarget::trace(visitor); |
| 1577 } | 1592 } |
| 1578 | 1593 |
| 1579 } // namespace blink | 1594 } // namespace blink |
| OLD | NEW |