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 0bd16cc977916ae94c57afae27f0f6b822450f8f..84da834a16b44a23eb366b73c8dcb26d9ad102c6 100644 |
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
@@ -88,37 +88,6 @@ |
} // namespace |
-class PresentationConnection::Message final : public GarbageCollectedFinalized<PresentationConnection::Message> { |
-public: |
- Message(const String& text) |
- : type(MessageTypeText) |
- , text(text) |
- { |
- } |
- |
- Message(DOMArrayBuffer* arrayBuffer) |
- : type(MessageTypeArrayBuffer) |
- , arrayBuffer(arrayBuffer) |
- { |
- } |
- |
- Message(PassRefPtr<BlobDataHandle> blobDataHandle) |
- : type(MessageTypeBlob) |
- , blobDataHandle(blobDataHandle) |
- { |
- } |
- |
- DEFINE_INLINE_TRACE() |
- { |
- visitor->trace(arrayBuffer); |
- } |
- |
- MessageType type; |
- String text; |
- Member<DOMArrayBuffer> arrayBuffer; |
- RefPtr<BlobDataHandle> blobDataHandle; |
-}; |
- |
class PresentationConnection::BlobLoader final : public GarbageCollectedFinalized<PresentationConnection::BlobLoader>, public FileReaderLoaderClient { |
public: |
BlobLoader(PassRefPtr<BlobDataHandle> blobDataHandle, PresentationConnection* PresentationConnection) |
@@ -233,7 +202,6 @@ |
DEFINE_TRACE(PresentationConnection) |
{ |
visitor->trace(m_blobLoader); |
- visitor->trace(m_messages); |
RefCountedGarbageCollectedEventTargetWithInlineData<PresentationConnection>::trace(visitor); |
DOMWindowProperty::trace(visitor); |
} |
@@ -248,27 +216,27 @@ |
if (!canSendMessage(exceptionState)) |
return; |
- m_messages.append(new Message(message)); |
- handleMessageQueue(); |
-} |
- |
-void PresentationConnection::send(DOMArrayBuffer* arrayBuffer, ExceptionState& exceptionState) |
+ m_messages.append(adoptPtr(new Message(message))); |
+ handleMessageQueue(); |
+} |
+ |
+void PresentationConnection::send(PassRefPtr<DOMArrayBuffer> arrayBuffer, ExceptionState& exceptionState) |
{ |
ASSERT(arrayBuffer && arrayBuffer->buffer()); |
if (!canSendMessage(exceptionState)) |
return; |
- m_messages.append(new Message(arrayBuffer)); |
- handleMessageQueue(); |
-} |
- |
-void PresentationConnection::send(DOMArrayBufferView* arrayBufferView, ExceptionState& exceptionState) |
+ m_messages.append(adoptPtr(new Message(arrayBuffer))); |
+ handleMessageQueue(); |
+} |
+ |
+void PresentationConnection::send(PassRefPtr<DOMArrayBufferView> arrayBufferView, ExceptionState& exceptionState) |
{ |
ASSERT(arrayBufferView); |
if (!canSendMessage(exceptionState)) |
return; |
- m_messages.append(new Message(arrayBufferView->buffer())); |
+ m_messages.append(adoptPtr(new Message(arrayBufferView->buffer()))); |
handleMessageQueue(); |
} |
@@ -278,7 +246,7 @@ |
if (!canSendMessage(exceptionState)) |
return; |
- m_messages.append(new Message(data->blobDataHandle())); |
+ m_messages.append(adoptPtr(new Message(data->blobDataHandle()))); |
handleMessageQueue(); |
} |
@@ -365,8 +333,8 @@ |
return; |
} |
case BinaryTypeArrayBuffer: |
- DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, length); |
- dispatchEvent(MessageEvent::create(buffer)); |
+ RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, length); |
+ dispatchEvent(MessageEvent::create(buffer.release())); |
return; |
} |
ASSERT_NOT_REACHED(); |
@@ -429,7 +397,7 @@ |
dispatchEvent(PresentationConnectionCloseEvent::create(EventTypeNames::close, connectionCloseReasonToString(reason), message)); |
} |
-void PresentationConnection::didFinishLoadingBlob(DOMArrayBuffer* buffer) |
+void PresentationConnection::didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer> buffer) |
{ |
ASSERT(!m_messages.isEmpty() && m_messages.first()->type == MessageTypeBlob); |
ASSERT(buffer && buffer->buffer()); |
@@ -460,7 +428,10 @@ |
m_blobLoader->cancel(); |
m_blobLoader.clear(); |
} |
- m_messages.clear(); |
+ |
+ // Clear message queue. |
+ Deque<OwnPtr<Message>> empty; |
+ m_messages.swap(empty); |
} |
} // namespace blink |