Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(701)

Unified Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
diff --git a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
index d833cf38afc67928b282e188d9f1a499bbda6e5f..25a282a876770d37c1db07e879c9b56e9f92bc47 100644
--- a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
+++ b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
@@ -83,6 +83,31 @@ private:
FileReaderLoader m_loader;
};
+class DocumentWebSocketChannel::Message : public GarbageCollectedFinalized<DocumentWebSocketChannel::Message> {
+public:
+ explicit Message(const CString&);
+ explicit Message(PassRefPtr<BlobDataHandle>);
+ explicit Message(DOMArrayBuffer*);
+ // For WorkerWebSocketChannel
+ explicit Message(PassOwnPtr<Vector<char>>, MessageType);
+ // Close message
+ Message(unsigned short code, const String& reason);
+
+ DEFINE_INLINE_TRACE()
+ {
+ visitor->trace(arrayBuffer);
+ }
+
+ MessageType type;
+
+ CString text;
+ RefPtr<BlobDataHandle> blobDataHandle;
+ Member<DOMArrayBuffer> arrayBuffer;
+ OwnPtr<Vector<char>> vectorData;
+ unsigned short code;
+ String reason;
+};
+
DocumentWebSocketChannel::BlobLoader::BlobLoader(PassRefPtr<BlobDataHandle> blobDataHandle, DocumentWebSocketChannel* channel)
: m_channel(channel)
, m_loader(FileReaderLoader::ReadAsArrayBuffer, this)
@@ -172,7 +197,7 @@ void DocumentWebSocketChannel::send(const CString& message)
// FIXME: Change the inspector API to show the entire message instead
// of individual frames.
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeText, true, message.data(), message.length());
- m_messages.append(adoptPtr(new Message(message)));
+ m_messages.append(new Message(message));
processSendQueue();
}
@@ -185,7 +210,7 @@ void DocumentWebSocketChannel::send(PassRefPtr<BlobDataHandle> blobDataHandle)
// Since Binary data are not displayed in Inspector, this does not
// affect actual behavior.
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeBinary, true, "", 0);
- m_messages.append(adoptPtr(new Message(blobDataHandle)));
+ m_messages.append(new Message(blobDataHandle));
processSendQueue();
}
@@ -198,7 +223,7 @@ void DocumentWebSocketChannel::send(const DOMArrayBuffer& buffer, unsigned byteO
// buffer.slice copies its contents.
// FIXME: Reduce copy by sending the data immediately when we don't need to
// queue the data.
- m_messages.append(adoptPtr(new Message(buffer.slice(byteOffset, byteOffset + byteLength))));
+ m_messages.append(new Message(buffer.slice(byteOffset, byteOffset + byteLength)));
processSendQueue();
}
@@ -208,7 +233,7 @@ void DocumentWebSocketChannel::sendTextAsCharVector(PassOwnPtr<Vector<char>> dat
// FIXME: Change the inspector API to show the entire message instead
// of individual frames.
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeText, true, data->data(), data->size());
- m_messages.append(adoptPtr(new Message(data, MessageTypeTextAsCharVector)));
+ m_messages.append(new Message(data, MessageTypeTextAsCharVector));
processSendQueue();
}
@@ -218,7 +243,7 @@ void DocumentWebSocketChannel::sendBinaryAsCharVector(PassOwnPtr<Vector<char>> d
// FIXME: Change the inspector API to show the entire message instead
// of individual frames.
InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, WebSocketFrame::OpCodeBinary, true, data->data(), data->size());
- m_messages.append(adoptPtr(new Message(data, MessageTypeBinaryAsCharVector)));
+ m_messages.append(new Message(data, MessageTypeBinaryAsCharVector));
processSendQueue();
}
@@ -227,7 +252,7 @@ void DocumentWebSocketChannel::close(int code, const String& reason)
WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, reason.utf8().data());
ASSERT(m_handle);
unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCodeNotSpecified ? CloseEventCodeNoStatusRcvd : code);
- m_messages.append(adoptPtr(new Message(codeToSend, reason)));
+ m_messages.append(new Message(codeToSend, reason));
processSendQueue();
}
@@ -269,7 +294,7 @@ DocumentWebSocketChannel::Message::Message(PassRefPtr<BlobDataHandle> blobDataHa
: type(MessageTypeBlob)
, blobDataHandle(blobDataHandle) { }
-DocumentWebSocketChannel::Message::Message(PassRefPtr<DOMArrayBuffer> arrayBuffer)
+DocumentWebSocketChannel::Message::Message(DOMArrayBuffer* arrayBuffer)
: type(MessageTypeArrayBuffer)
, arrayBuffer(arrayBuffer) { }
@@ -529,14 +554,14 @@ void DocumentWebSocketChannel::didStartClosingHandshake(WebSocketHandle* handle)
m_client->didStartClosingHandshake();
}
-void DocumentWebSocketChannel::didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer> buffer)
+void DocumentWebSocketChannel::didFinishLoadingBlob(DOMArrayBuffer* buffer)
{
m_blobLoader.clear();
ASSERT(m_handle);
// The loaded blob is always placed on m_messages[0].
ASSERT(m_messages.size() > 0 && m_messages.first()->type == MessageTypeBlob);
// We replace it with the loaded blob.
- m_messages.first() = adoptPtr(new Message(buffer));
+ m_messages.first() = new Message(buffer);
processSendQueue();
}
@@ -555,6 +580,7 @@ void DocumentWebSocketChannel::didFailLoadingBlob(FileError::ErrorCode errorCode
DEFINE_TRACE(DocumentWebSocketChannel)
{
visitor->trace(m_blobLoader);
+ visitor->trace(m_messages);
visitor->trace(m_client);
WebSocketChannel::trace(visitor);
ContextLifecycleObserver::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698