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 e7d005333b686f332fb64a173e789ece4d5ca05e..d120a7ace9262401d9f31cd9aafa1e8e7596f7fe 100644 |
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
@@ -152,12 +152,22 @@ PresentationConnection::PresentationConnection(LocalFrame* frame, |
m_id(id), |
m_url(url), |
m_state(WebPresentationConnectionState::Connecting), |
- m_binaryType(BinaryTypeBlob) {} |
+ m_binaryType(BinaryTypeBlob), |
+ m_proxy(nullptr) {} |
PresentationConnection::~PresentationConnection() { |
ASSERT(!m_blobLoader); |
} |
+void PresentationConnection::SetPresentationConnectionProxy( |
+ std::unique_ptr<WebPresentationConnectionProxy> proxy) { |
+ if (!proxy) |
+ return; |
+ |
+ m_proxy = std::move(proxy); |
+ m_proxy->SetSourceConnection(this); |
+} |
+ |
// static |
PresentationConnection* PresentationConnection::take( |
ScriptPromiseResolver* resolver, |
@@ -190,6 +200,8 @@ PresentationConnection* PresentationConnection::take( |
PresentationConnection* connection = new PresentationConnection( |
controller->frame(), client->getId(), client->getUrl()); |
+ connection->SetPresentationConnectionProxy(client->takeProxy()); |
+ |
controller->registerConnection(connection); |
request->dispatchEvent(PresentationConnectionAvailableEvent::create( |
EventTypeNames::connectionavailable, connection)); |
@@ -206,6 +218,8 @@ PresentationConnection* PresentationConnection::take( |
PresentationConnection* connection = new PresentationConnection( |
receiver->frame(), client->getId(), client->getUrl()); |
+ connection->SetPresentationConnectionProxy(client->takeProxy()); |
+ |
receiver->registerConnection(connection); |
return connection; |
@@ -307,13 +321,23 @@ void PresentationConnection::handleMessageQueue() { |
Message* message = m_messages.first().get(); |
switch (message->type) { |
case MessageTypeText: |
- client->sendString(m_url, m_id, message->text); |
+ if (m_proxy) |
+ m_proxy->SendString(message->text); |
+ else |
+ client->sendString(m_url, m_id, message->text); |
m_messages.removeFirst(); |
break; |
case MessageTypeArrayBuffer: |
- client->sendArrayBuffer(m_url, m_id, static_cast<const uint8_t*>( |
- message->arrayBuffer->data()), |
- message->arrayBuffer->byteLength()); |
+ if (m_proxy) { |
+ m_proxy->SendArrayBuffer( |
+ static_cast<const uint8_t*>(message->arrayBuffer->data()), |
+ message->arrayBuffer->byteLength()); |
+ } else { |
+ client->sendArrayBuffer( |
+ m_url, m_id, |
+ static_cast<const uint8_t*>(message->arrayBuffer->data()), |
+ message->arrayBuffer->byteLength()); |
+ } |
m_messages.removeFirst(); |
break; |
case MessageTypeBlob: |
@@ -347,7 +371,7 @@ void PresentationConnection::setBinaryType(const String& binaryType) { |
ASSERT_NOT_REACHED(); |
} |
-void PresentationConnection::didReceiveTextMessage(const String& message) { |
+void PresentationConnection::didReceiveTextMessage(const WebString& message) { |
if (m_state != WebPresentationConnectionState::Connected) |
return; |