| Index: Source/modules/presentation/PresentationSession.cpp
|
| diff --git a/Source/modules/presentation/PresentationSession.cpp b/Source/modules/presentation/PresentationSession.cpp
|
| index dc665e2de1d2b3cb544a6e93db4f90f33a80c907..2a0d5b826432a21003c223459ee89d12a143a825 100644
|
| --- a/Source/modules/presentation/PresentationSession.cpp
|
| +++ b/Source/modules/presentation/PresentationSession.cpp
|
| @@ -219,11 +219,63 @@ void PresentationSession::handleMessageQueue()
|
| }
|
| }
|
|
|
| +String PresentationSession::binaryType() const
|
| +{
|
| + switch (m_binaryType) {
|
| + case BinaryTypeBlob:
|
| + return "blob";
|
| + case BinaryTypeArrayBuffer:
|
| + return "arraybuffer";
|
| + }
|
| + ASSERT_NOT_REACHED();
|
| + return String();
|
| +}
|
| +
|
| +void PresentationSession::setBinaryType(const String& binaryType)
|
| +{
|
| + if (binaryType == "blob") {
|
| + m_binaryType = BinaryTypeBlob;
|
| + return;
|
| + }
|
| + if (binaryType == "arraybuffer") {
|
| + m_binaryType = BinaryTypeArrayBuffer;
|
| + return;
|
| + }
|
| + ASSERT_NOT_REACHED();
|
| +}
|
| +
|
| void PresentationSession::didReceiveTextMessage(const String& message)
|
| {
|
| + if (m_state == WebPresentationSessionState::Disconnected)
|
| + return;
|
| +
|
| dispatchEvent(MessageEvent::create(message));
|
| }
|
|
|
| +void PresentationSession::didReceiveBinaryMessage(const uint8_t* data, size_t length)
|
| +{
|
| + if (m_state == WebPresentationSessionState::Disconnected)
|
| + return;
|
| +
|
| + switch (m_binaryType) {
|
| + case BinaryTypeBlob: {
|
| + RefPtr<RawData> rawData = RawData::create();
|
| + rawData->mutableData()->resize(length);
|
| + memcpy(rawData->mutableData()->data(), data, length);
|
| + OwnPtr<BlobData> blobData = BlobData::create();
|
| + blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile);
|
| + Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), length));
|
| + dispatchEvent(MessageEvent::create(blob));
|
| + return;
|
| + }
|
| + case BinaryTypeArrayBuffer:
|
| + RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, length);
|
| + dispatchEvent(MessageEvent::create(buffer.release()));
|
| + return;
|
| + }
|
| + ASSERT_NOT_REACHED();
|
| +}
|
| +
|
| void PresentationSession::close()
|
| {
|
| if (m_state != WebPresentationSessionState::Connected)
|
|
|