| Index: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| index f3efdfc5fa6f02cc035f7e2117616d3a56184313..ace101a652f0a9721e2a0968451baf07025c3f33 100644
|
| --- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| +++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| @@ -213,9 +213,27 @@ void BodyStreamBuffer::processData()
|
| WebDataConsumerHandle::Result result = m_reader->beginRead(&buffer, WebDataConsumerHandle::FlagNone, &available);
|
| switch (result) {
|
| case WebDataConsumerHandle::Ok:
|
| - m_streamNeedsMore = m_stream->enqueue(DOMUint8Array::create(static_cast<const unsigned char*>(buffer), available));
|
| - m_reader->endRead(available);
|
| - break;
|
| + {
|
| + // FIXME(crbug.com/536816):
|
| + // Use createOrNull instead of deprecatedCreateOrCrash in order to
|
| + // fail gracefully when allocation fails. It would probably be
|
| + // appropriate to do something like this to handle the failure:
|
| + //
|
| + // if (!domArray) {
|
| + // m_reader = nullptr;
|
| + // m_stream->error(DOMException::create(V8RangeError, "Out of Memory."));
|
| + // m_handle.clear();
|
| + // }
|
| + //
|
| + // The spec would need to be amended to support that behavior.
|
| + // Alternately, we could just proceed with domArray being null if it
|
| + // is ascertained that silently droping data is acceptable when the
|
| + // alternative is to crash with an out-of-memory exception.
|
| + RefPtr<DOMUint8Array> domArray = DOMUint8Array::deprecatedCreateOrCrash(static_cast<const unsigned char*>(buffer), available);
|
| + m_streamNeedsMore = m_stream->enqueue(domArray);
|
| + m_reader->endRead(available);
|
| + }
|
| + return;
|
|
|
| case WebDataConsumerHandle::Done:
|
| close();
|
|
|