| Index: third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
|
| diff --git a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
|
| index 011ddadef6d79bb5e181d30930495d8824bd4920..873ac3cf5896636b67082184f168712e1146eadf 100644
|
| --- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
|
| +++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
|
| @@ -80,7 +80,14 @@ public:
|
| void didReceiveData() override { }
|
| void didFinishLoading() override
|
| {
|
| - m_PresentationConnection->didFinishLoadingBlob(m_loader.arrayBufferResult());
|
| + RefPtr<DOMArrayBuffer> result = m_loader.arrayBufferResultOrNull();
|
| + // FIXME(crbug.com/536816):
|
| + // Is there a better way to handle an allocation failure instead
|
| + // of crashing? Would it be okay to fail silently by passing a nullptr?
|
| + // Should we call didFailLoadingBlob? If so, with which ErrorCode?
|
| + // Spec may need to be ammended for this.
|
| + RELEASE_ASSERT(result); // This is essentially an out-of-memory crash.
|
| + m_PresentationConnection->didFinishLoadingBlob(result.release());
|
| }
|
| void didFail(FileError::ErrorCode errorCode) override
|
| {
|
| @@ -207,7 +214,9 @@ void PresentationConnection::send(PassRefPtr<DOMArrayBufferView> arrayBufferView
|
| if (!canSendMessage(exceptionState))
|
| return;
|
|
|
| - m_messages.append(adoptPtr(new Message(arrayBufferView->buffer())));
|
| + RefPtr<DOMArrayBuffer> buffer = arrayBufferView->bufferOrNull();
|
| + RELEASE_ASSERT(buffer); // crbug.com/536816
|
| + m_messages.append(adoptPtr(new Message(buffer)));
|
| handleMessageQueue();
|
| }
|
|
|
| @@ -304,9 +313,14 @@ void PresentationConnection::didReceiveBinaryMessage(const uint8_t* data, size_t
|
| return;
|
| }
|
| case BinaryTypeArrayBuffer:
|
| - RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, length);
|
| + // FIXME(crbug.com/536816):
|
| + // Use createOrNull instead of deprecatedCReateOrCrash. Requires
|
| + // determing an accepatble alternative to crashing when buffer
|
| + // allocation fails. Should we just drop the event? Dispatch
|
| + // an event with null data? Dispatch some kind of error code?
|
| + // Behavior needs to be defined in the spec.
|
| + RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::deprecatedCreateOrCrash(data, length);
|
| dispatchEvent(MessageEvent::create(buffer.release()));
|
| - return;
|
| }
|
| ASSERT_NOT_REACHED();
|
| }
|
|
|