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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 } | 381 } |
382 | 382 |
383 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() { | 383 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() { |
384 DCHECK_EQ(m_responseTypeCode, ResponseTypeArrayBuffer); | 384 DCHECK_EQ(m_responseTypeCode, ResponseTypeArrayBuffer); |
385 | 385 |
386 if (m_error || m_state != kDone) | 386 if (m_error || m_state != kDone) |
387 return nullptr; | 387 return nullptr; |
388 | 388 |
389 if (!m_responseArrayBuffer) { | 389 if (!m_responseArrayBuffer) { |
390 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { | 390 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { |
391 DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitialized( | 391 DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitializedOrNull( |
392 m_binaryResponseBuilder->size(), 1); | 392 m_binaryResponseBuilder->size(), 1); |
393 m_binaryResponseBuilder->getAsBytes( | 393 if (buffer) { |
394 buffer->data(), static_cast<size_t>(buffer->byteLength())); | 394 m_binaryResponseBuilder->getAsBytes( |
395 m_responseArrayBuffer = buffer; | 395 buffer->data(), static_cast<size_t>(buffer->byteLength())); |
396 m_responseArrayBuffer = buffer; | |
397 } | |
398 // https://xhr.spec.whatwg.org/#arraybuffer-response allows clearing | |
399 // of the 'received bytes' payload when the response buffer allocation | |
400 // fails. | |
396 m_binaryResponseBuilder.clear(); | 401 m_binaryResponseBuilder.clear(); |
397 } else { | 402 } else { |
398 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); | 403 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); |
yhirano
2017/03/06 09:19:53
This getter returns null for the first time, and w
sof
2017/03/06 09:29:16
Hmm, yes. It implements the spec by doing so, I'd
| |
399 } | 404 } |
400 } | 405 } |
401 | 406 |
402 return m_responseArrayBuffer; | 407 return m_responseArrayBuffer; |
403 } | 408 } |
404 | 409 |
405 void XMLHttpRequest::setTimeout(unsigned timeout, | 410 void XMLHttpRequest::setTimeout(unsigned timeout, |
406 ExceptionState& exceptionState) { | 411 ExceptionState& exceptionState) { |
407 // FIXME: Need to trigger or update the timeout Timer here, if needed. | 412 // FIXME: Need to trigger or update the timeout Timer here, if needed. |
408 // http://webkit.org/b/98156 | 413 // http://webkit.org/b/98156 |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 visitor->traceWrappers(m_responseDocument); | 1894 visitor->traceWrappers(m_responseDocument); |
1890 visitor->traceWrappers(m_responseArrayBuffer); | 1895 visitor->traceWrappers(m_responseArrayBuffer); |
1891 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1896 XMLHttpRequestEventTarget::traceWrappers(visitor); |
1892 } | 1897 } |
1893 | 1898 |
1894 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1899 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
1895 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1900 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
1896 } | 1901 } |
1897 | 1902 |
1898 } // namespace blink | 1903 } // namespace blink |
OLD | NEW |