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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 } | 380 } |
381 | 381 |
382 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() { | 382 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() { |
383 DCHECK_EQ(m_responseTypeCode, ResponseTypeArrayBuffer); | 383 DCHECK_EQ(m_responseTypeCode, ResponseTypeArrayBuffer); |
384 | 384 |
385 if (m_error || m_state != kDone) | 385 if (m_error || m_state != kDone) |
386 return nullptr; | 386 return nullptr; |
387 | 387 |
388 if (!m_responseArrayBuffer) { | 388 if (!m_responseArrayBuffer) { |
389 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { | 389 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { |
390 DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitialized( | 390 DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitializedOrNull( |
391 m_binaryResponseBuilder->size(), 1); | 391 m_binaryResponseBuilder->size(), 1); |
392 m_binaryResponseBuilder->getAsBytes( | 392 if (buffer) { |
393 buffer->data(), static_cast<size_t>(buffer->byteLength())); | 393 m_binaryResponseBuilder->getAsBytes( |
394 m_responseArrayBuffer = buffer; | 394 buffer->data(), static_cast<size_t>(buffer->byteLength())); |
395 m_responseArrayBuffer = buffer; | |
396 } | |
397 // https://xhr.spec.whatwg.org/#arraybuffer-response allows clearing | |
398 // of the 'received bytes' payload when the response buffer allocation | |
399 // fails. | |
haraken
2017/03/03 19:23:26
I guess it would be nicer to set an exception but
sof
2017/03/03 21:23:53
https://github.com/whatwg/xhr/issues/26 has some d
| |
395 m_binaryResponseBuilder.clear(); | 400 m_binaryResponseBuilder.clear(); |
396 } else { | 401 } else { |
397 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); | 402 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); |
398 } | 403 } |
399 } | 404 } |
400 | 405 |
401 return m_responseArrayBuffer; | 406 return m_responseArrayBuffer; |
402 } | 407 } |
403 | 408 |
404 void XMLHttpRequest::setTimeout(unsigned timeout, | 409 void XMLHttpRequest::setTimeout(unsigned timeout, |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1856 visitor->traceWrappers(m_responseDocument); | 1861 visitor->traceWrappers(m_responseDocument); |
1857 visitor->traceWrappers(m_responseArrayBuffer); | 1862 visitor->traceWrappers(m_responseArrayBuffer); |
1858 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1863 XMLHttpRequestEventTarget::traceWrappers(visitor); |
1859 } | 1864 } |
1860 | 1865 |
1861 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1866 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
1862 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1867 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
1863 } | 1868 } |
1864 | 1869 |
1865 } // namespace blink | 1870 } // namespace blink |
OLD | NEW |