Chromium Code Reviews| 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 0d8b3b2d609eece6c65b98351d926e6a939aa070..ba9f7855f5fc2e02e802a986527f6dbbc90e6968 100644 |
| --- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
| +++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
| @@ -149,12 +149,20 @@ PresentationConnection::PresentationConnection(LocalFrame* frame, |
| m_id(id), |
| m_url(url), |
| m_state(WebPresentationConnectionState::Connected), |
| - m_binaryType(BinaryTypeBlob) {} |
| + m_binaryType(BinaryTypeBlob), |
| + m_proxy(nullptr) {} |
| PresentationConnection::~PresentationConnection() { |
| ASSERT(!m_blobLoader); |
| } |
| +void PresentationConnection::SetPresentationConnectionProxy( |
| + std::unique_ptr<WebPresentationConnectionProxy> proxy) { |
| + DCHECK(proxy); |
| + m_proxy = std::move(proxy); |
| + m_proxy->SetSourceConnection(this); |
| +} |
| + |
| // static |
| PresentationConnection* PresentationConnection::take( |
| ScriptPromiseResolver* resolver, |
| @@ -187,6 +195,10 @@ PresentationConnection* PresentationConnection::take( |
| PresentationConnection* connection = new PresentationConnection( |
| controller->frame(), client->getId(), client->getUrl()); |
| + |
| + if (auto proxy = client->takeProxy()) |
|
imcheng
2016/11/01 17:20:30
this check is not needed? std::move should work on
zhaobin
2016/11/02 03:55:48
Done.
|
| + connection->SetPresentationConnectionProxy(std::move(proxy)); |
| + |
| controller->registerConnection(connection); |
| request->dispatchEvent(PresentationConnectionAvailableEvent::create( |
| EventTypeNames::connectionavailable, connection)); |
| @@ -203,6 +215,10 @@ PresentationConnection* PresentationConnection::take( |
| PresentationConnection* connection = new PresentationConnection( |
| receiver->frame(), client->getId(), client->getUrl()); |
| + |
| + if (auto proxy = client->takeProxy()) |
|
imcheng
2016/11/01 17:20:30
this should always be non-null, right?
zhaobin
2016/11/02 03:55:48
Done.
|
| + connection->SetPresentationConnectionProxy(std::move(proxy)); |
| + |
| receiver->registerConnection(connection); |
| return connection; |
| @@ -304,13 +320,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: |
| @@ -344,7 +370,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; |