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

Unified Diff: third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp

Issue 2171843002: Use array<uint8> rather than string to pass BroadcastChannel messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/broadcastchannel/BroadcastChannel.cpp
diff --git a/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp b/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp
index 676b82350874c1fa2f0589241ac0d461aeeba4c6..28fffa8ba2037b1fb698a0c0bf9ed95c6c4b7185 100644
--- a/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp
+++ b/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp
@@ -63,8 +63,11 @@ void BroadcastChannel::postMessage(const ScriptValue& message, ExceptionState& e
if (exceptionState.hadException())
return;
- String data = value->toWireString();
- m_remoteClient->OnMessage(data);
+ Vector<char> data;
esprehn 2016/07/23 08:53:50 you want to call reserveInitialCapacity on both of
Marijn Kruisselbrink 2016/07/23 19:14:18 Not sure what resized and copies that would avoid?
+ value->toWireBytes(data);
+ Vector<uint8_t> mojoData;
+ mojoData.appendVector(data);
dcheng 2016/07/22 02:33:03 It's sad that this results in copying the data now
Marijn Kruisselbrink 2016/07/22 03:23:12 Yeah... but reinterpret_casting a Vector didn't se
+ m_remoteClient->OnMessage(std::move(mojoData));
}
void BroadcastChannel::close()
@@ -95,10 +98,10 @@ DEFINE_TRACE(BroadcastChannel)
EventTargetWithInlineData::trace(visitor);
}
-void BroadcastChannel::OnMessage(const String& message)
+void BroadcastChannel::OnMessage(mojo::WTFArray<uint8_t> message)
{
// Queue a task to dispatch the event.
- RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(message);
+ RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(reinterpret_cast<const char*>(&message.front()), message.size());
MessageEvent* event = MessageEvent::create(nullptr, value.release(), getExecutionContext()->getSecurityOrigin()->toString());
event->setTarget(this);
bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event);

Powered by Google App Engine
This is Rietveld 408576698