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..5b3f6a3f9ac0525e6d873aa69b2f5236365dbc4d 100644 |
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp |
@@ -142,14 +142,25 @@ class PresentationConnection::BlobLoader final |
std::unique_ptr<FileReaderLoader> m_loader; |
}; |
-PresentationConnection::PresentationConnection(LocalFrame* frame, |
- const String& id, |
- const KURL& url) |
+PresentationConnection::PresentationConnection( |
+ LocalFrame* frame, |
+ const String& id, |
+ const KURL& url, |
+ std::unique_ptr<WebPresentationConnectionProxy> proxy) |
: DOMWindowProperty(frame), |
m_id(id), |
m_url(url), |
m_state(WebPresentationConnectionState::Connected), |
- m_binaryType(BinaryTypeBlob) {} |
+ m_binaryType(BinaryTypeBlob) { |
+ // proxy != nullptr if presentation connection is |
mark a. foltz
2016/10/21 00:53:03
Can you wrap this comment at 80 columns?
zhaobin
2016/10/22 02:44:13
Done.
|
+ // offscreen presentation connection (1-UA); |
+ // proxy == nullptr in other cases. |
+ if (!proxy) |
mark a. foltz
2016/10/21 00:53:03
Since the proxy is optional, I have a slight prefe
zhaobin
2016/10/22 02:44:13
Done.
|
+ return; |
+ |
+ m_proxy = std::move(proxy); |
+ m_proxy->SetSourceConnection(this); |
+} |
PresentationConnection::~PresentationConnection() { |
ASSERT(!m_blobLoader); |
@@ -185,8 +196,9 @@ PresentationConnection* PresentationConnection::take( |
ASSERT(controller); |
ASSERT(request); |
- PresentationConnection* connection = new PresentationConnection( |
- controller->frame(), client->getId(), client->getUrl()); |
+ PresentationConnection* connection = |
+ new PresentationConnection(controller->frame(), client->getId(), |
+ client->getUrl(), client->getProxy()); |
controller->registerConnection(connection); |
request->dispatchEvent(PresentationConnectionAvailableEvent::create( |
EventTypeNames::connectionavailable, connection)); |
@@ -202,7 +214,7 @@ PresentationConnection* PresentationConnection::take( |
DCHECK(client); |
PresentationConnection* connection = new PresentationConnection( |
- receiver->frame(), client->getId(), client->getUrl()); |
+ receiver->frame(), client->getId(), client->getUrl(), client->getProxy()); |
receiver->registerConnection(connection); |
return connection; |
@@ -304,10 +316,17 @@ void PresentationConnection::handleMessageQueue() { |
Message* message = m_messages.first().get(); |
switch (message->type) { |
case MessageTypeText: |
+ if (m_proxy) |
+ m_proxy->SendString(message->text); |
mark a. foltz
2016/10/21 00:53:03
Do we want to send the string to both |m_proxy| an
zhaobin
2016/10/22 02:44:14
Done.
|
client->sendString(m_url, m_id, message->text); |
m_messages.removeFirst(); |
break; |
case MessageTypeArrayBuffer: |
+ if (m_proxy) { |
+ m_proxy->SendArrayBuffer( |
mark a. foltz
2016/10/21 00:53:03
Same comment applies here.
zhaobin
2016/10/22 02:44:14
Done.
|
+ static_cast<const uint8_t*>(message->arrayBuffer->data()), |
+ message->arrayBuffer->byteLength()); |
+ } |
client->sendArrayBuffer(m_url, m_id, static_cast<const uint8_t*>( |
message->arrayBuffer->data()), |
message->arrayBuffer->byteLength()); |
@@ -344,7 +363,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; |