| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "platform/network/ResourceRequest.h" | 53 #include "platform/network/ResourceRequest.h" |
| 54 #include "public/platform/Platform.h" | 54 #include "public/platform/Platform.h" |
| 55 #include "wtf/ArrayBuffer.h" | 55 #include "wtf/ArrayBuffer.h" |
| 56 #include "wtf/ArrayBufferView.h" | 56 #include "wtf/ArrayBufferView.h" |
| 57 #include "wtf/RefCountedLeakCounter.h" | 57 #include "wtf/RefCountedLeakCounter.h" |
| 58 #include "wtf/StdLibExtras.h" | 58 #include "wtf/StdLibExtras.h" |
| 59 #include "wtf/text/CString.h" | 59 #include "wtf/text/CString.h" |
| 60 | 60 |
| 61 namespace WebCore { | 61 namespace WebCore { |
| 62 | 62 |
| 63 DEFINE_GC_INFO(XMLHttpRequest); |
| 64 |
| 63 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XM
LHttpRequest")); | 65 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XM
LHttpRequest")); |
| 64 | 66 |
| 65 // Histogram enum to see when we can deprecate xhr.send(ArrayBuffer). | 67 // Histogram enum to see when we can deprecate xhr.send(ArrayBuffer). |
| 66 enum XMLHttpRequestSendArrayBufferOrView { | 68 enum XMLHttpRequestSendArrayBufferOrView { |
| 67 XMLHttpRequestSendArrayBuffer, | 69 XMLHttpRequestSendArrayBuffer, |
| 68 XMLHttpRequestSendArrayBufferView, | 70 XMLHttpRequestSendArrayBufferView, |
| 69 XMLHttpRequestSendArrayBufferOrViewMax, | 71 XMLHttpRequestSendArrayBufferOrViewMax, |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 struct XMLHttpRequestStaticData { | 74 struct XMLHttpRequestStaticData { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 148 |
| 147 static void logConsoleError(ExecutionContext* context, const String& message) | 149 static void logConsoleError(ExecutionContext* context, const String& message) |
| 148 { | 150 { |
| 149 if (!context) | 151 if (!context) |
| 150 return; | 152 return; |
| 151 // FIXME: It's not good to report the bad usage without indicating what sour
ce line it came from. | 153 // FIXME: It's not good to report the bad usage without indicating what sour
ce line it came from. |
| 152 // We should pass additional parameters so we can tell the console where the
mistake occurred. | 154 // We should pass additional parameters so we can tell the console where the
mistake occurred. |
| 153 context->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message); | 155 context->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message); |
| 154 } | 156 } |
| 155 | 157 |
| 156 PassRefPtr<XMLHttpRequest> XMLHttpRequest::create(ExecutionContext* context, Pas
sRefPtr<SecurityOrigin> securityOrigin) | 158 PassRefPtrWillBeRawPtr<XMLHttpRequest> XMLHttpRequest::create(ExecutionContext*
context, PassRefPtr<SecurityOrigin> securityOrigin) |
| 157 { | 159 { |
| 158 RefPtr<XMLHttpRequest> xmlHttpRequest(adoptRef(new XMLHttpRequest(context, s
ecurityOrigin))); | 160 RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = adoptRefCountedWillBeRef
CountedGarbageCollected(new XMLHttpRequest(context, securityOrigin)); |
| 159 xmlHttpRequest->suspendIfNeeded(); | 161 xmlHttpRequest->suspendIfNeeded(); |
| 160 | 162 |
| 161 return xmlHttpRequest.release(); | 163 return xmlHttpRequest.release(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, PassRefPtr<SecurityOri
gin> securityOrigin) | 166 XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, PassRefPtr<SecurityOri
gin> securityOrigin) |
| 165 : ActiveDOMObject(context) | 167 : ActiveDOMObject(context) |
| 166 , m_async(true) | 168 , m_async(true) |
| 167 , m_includeCredentials(false) | 169 , m_includeCredentials(false) |
| 168 , m_timeoutMilliseconds(0) | 170 , m_timeoutMilliseconds(0) |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 m_exceptionCode = NetworkError; | 865 m_exceptionCode = NetworkError; |
| 864 if (m_exceptionCode) | 866 if (m_exceptionCode) |
| 865 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m
_url.elidedString() + "'."); | 867 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m
_url.elidedString() + "'."); |
| 866 } | 868 } |
| 867 | 869 |
| 868 void XMLHttpRequest::abort() | 870 void XMLHttpRequest::abort() |
| 869 { | 871 { |
| 870 WTF_LOG(Network, "XMLHttpRequest %p abort()", this); | 872 WTF_LOG(Network, "XMLHttpRequest %p abort()", this); |
| 871 | 873 |
| 872 // internalAbort() calls dropProtection(), which may release the last refere
nce. | 874 // internalAbort() calls dropProtection(), which may release the last refere
nce. |
| 873 RefPtr<XMLHttpRequest> protect(this); | 875 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); |
| 874 | 876 |
| 875 bool sendFlag = m_loader; | 877 bool sendFlag = m_loader; |
| 876 | 878 |
| 877 // Response is cleared next, save needed progress event data. | 879 // Response is cleared next, save needed progress event data. |
| 878 long long expectedLength = m_response.expectedContentLength(); | 880 long long expectedLength = m_response.expectedContentLength(); |
| 879 long long receivedLength = m_receivedLength; | 881 long long receivedLength = m_receivedLength; |
| 880 | 882 |
| 881 if (!internalAbort()) | 883 if (!internalAbort()) |
| 882 return; | 884 return; |
| 883 | 885 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 m_responseText = m_responseText.concatenateWith(m_decoder->flush()); | 1259 m_responseText = m_responseText.concatenateWith(m_decoder->flush()); |
| 1258 | 1260 |
| 1259 if (m_responseStream) | 1261 if (m_responseStream) |
| 1260 m_responseStream->finalize(); | 1262 m_responseStream->finalize(); |
| 1261 | 1263 |
| 1262 clearVariablesForLoading(); | 1264 clearVariablesForLoading(); |
| 1263 | 1265 |
| 1264 InspectorInstrumentation::didFinishXHRLoading(executionContext(), this, this
, identifier, m_responseText, m_method, m_url, m_lastSendURL, m_lastSendLineNumb
er); | 1266 InspectorInstrumentation::didFinishXHRLoading(executionContext(), this, this
, identifier, m_responseText, m_method, m_url, m_lastSendURL, m_lastSendLineNumb
er); |
| 1265 | 1267 |
| 1266 // Prevent dropProtection releasing the last reference, and retain |this| un
til the end of this method. | 1268 // Prevent dropProtection releasing the last reference, and retain |this| un
til the end of this method. |
| 1267 RefPtr<XMLHttpRequest> protect(this); | 1269 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); |
| 1268 | 1270 |
| 1269 if (m_loader) { | 1271 if (m_loader) { |
| 1270 m_loader = 0; | 1272 m_loader = 0; |
| 1271 dropProtection(); | 1273 dropProtection(); |
| 1272 } | 1274 } |
| 1273 | 1275 |
| 1274 changeState(DONE); | 1276 changeState(DONE); |
| 1275 } | 1277 } |
| 1276 | 1278 |
| 1277 void XMLHttpRequest::didSendData(unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) | 1279 void XMLHttpRequest::didSendData(unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 | 1378 |
| 1377 m_downloadedBlobLength += dataLength; | 1379 m_downloadedBlobLength += dataLength; |
| 1378 trackProgress(dataLength); | 1380 trackProgress(dataLength); |
| 1379 } | 1381 } |
| 1380 | 1382 |
| 1381 void XMLHttpRequest::handleDidTimeout() | 1383 void XMLHttpRequest::handleDidTimeout() |
| 1382 { | 1384 { |
| 1383 WTF_LOG(Network, "XMLHttpRequest %p handleDidTimeout()", this); | 1385 WTF_LOG(Network, "XMLHttpRequest %p handleDidTimeout()", this); |
| 1384 | 1386 |
| 1385 // internalAbort() calls dropProtection(), which may release the last refere
nce. | 1387 // internalAbort() calls dropProtection(), which may release the last refere
nce. |
| 1386 RefPtr<XMLHttpRequest> protect(this); | 1388 RefPtrWillBeRawPtr<XMLHttpRequest> protect(this); |
| 1387 | 1389 |
| 1388 // Response is cleared next, save needed progress event data. | 1390 // Response is cleared next, save needed progress event data. |
| 1389 long long expectedLength = m_response.expectedContentLength(); | 1391 long long expectedLength = m_response.expectedContentLength(); |
| 1390 long long receivedLength = m_receivedLength; | 1392 long long receivedLength = m_receivedLength; |
| 1391 | 1393 |
| 1392 if (!internalAbort()) | 1394 if (!internalAbort()) |
| 1393 return; | 1395 return; |
| 1394 | 1396 |
| 1395 handleDidFailGeneric(); | 1397 handleDidFailGeneric(); |
| 1396 handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, ex
pectedLength); | 1398 handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, ex
pectedLength); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1421 { | 1423 { |
| 1422 return EventTargetNames::XMLHttpRequest; | 1424 return EventTargetNames::XMLHttpRequest; |
| 1423 } | 1425 } |
| 1424 | 1426 |
| 1425 ExecutionContext* XMLHttpRequest::executionContext() const | 1427 ExecutionContext* XMLHttpRequest::executionContext() const |
| 1426 { | 1428 { |
| 1427 return ActiveDOMObject::executionContext(); | 1429 return ActiveDOMObject::executionContext(); |
| 1428 } | 1430 } |
| 1429 | 1431 |
| 1430 } // namespace WebCore | 1432 } // namespace WebCore |
| OLD | NEW |