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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: resolve code review comments from Mark Created 4 years, 2 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/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..d65423992a573d7f6aca45f5d0f27ad26ab3baa9 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
@@ -142,14 +142,20 @@ 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,
+ WebPresentationConnectionProxy* proxy)
mark a. foltz 2016/10/10 18:28:52 For a 2-UA presentation (e.g. a Cast app) why is a
zhaobin 2016/10/12 02:27:34 Done.
: DOMWindowProperty(frame),
m_id(id),
m_url(url),
m_state(WebPresentationConnectionState::Connected),
- m_binaryType(BinaryTypeBlob) {}
+ m_binaryType(BinaryTypeBlob),
+ m_proxy(proxy) {
+ DCHECK(m_proxy);
+ m_proxy->SetConnection(this);
+}
PresentationConnection::~PresentationConnection() {
ASSERT(!m_blobLoader);
@@ -185,8 +191,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->getOrCreateProxy());
controller->registerConnection(connection);
request->dispatchEvent(PresentationConnectionAvailableEvent::create(
EventTypeNames::connectionavailable, connection));
@@ -201,8 +208,9 @@ PresentationConnection* PresentationConnection::take(
DCHECK(receiver);
DCHECK(client);
- PresentationConnection* connection = new PresentationConnection(
- receiver->frame(), client->getId(), client->getUrl());
+ PresentationConnection* connection =
+ new PresentationConnection(receiver->frame(), client->getId(),
+ client->getUrl(), client->getOrCreateProxy());
receiver->registerConnection(connection);
return connection;
@@ -304,10 +312,14 @@ void PresentationConnection::handleMessageQueue() {
Message* message = m_messages.first().get();
switch (message->type) {
case MessageTypeText:
+ m_proxy->SendString(message->text);
imcheng 2016/10/12 02:22:55 Same question as mark: looks like we are sending m
client->sendString(m_url, m_id, message->text);
m_messages.removeFirst();
break;
case MessageTypeArrayBuffer:
+ m_proxy->SendArrayBuffer(
+ 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 +356,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;

Powered by Google App Engine
This is Rietveld 408576698