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

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

Issue 2471263003: [Presentation API] (4th)(1-UA blink side) Add WebPresentationConnection and WebPresentationConnecti… (Closed)
Patch Set: resolve code review comments from mlamouri Created 3 years, 11 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 be94c78b5cbe27f3800a4a7eeafc31a025dc6703..d1ce00eb0606f41865283137cb9ca94f7ef3cbe4 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp
@@ -153,12 +153,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::bindProxy(
+ std::unique_ptr<WebPresentationConnectionProxy> proxy) {
+ DCHECK(proxy);
+ // TODO(zhaobin): Restore to DCHECK(!m_proxy) when reconnect() is properly
+ // implemented.
+ if (!m_proxy)
+ m_proxy = std::move(proxy);
+}
+
// static
PresentationConnection* PresentationConnection::take(
ScriptPromiseResolver* resolver,
@@ -305,20 +315,21 @@ bool PresentationConnection::canSendMessage(ExceptionState& exceptionState) {
void PresentationConnection::handleMessageQueue() {
WebPresentationClient* client = presentationClient(getExecutionContext());
- if (!client)
+ if (!client || !m_proxy)
return;
while (!m_messages.isEmpty() && !m_blobLoader) {
Message* message = m_messages.first().get();
switch (message->type) {
case MessageTypeText:
- client->sendString(m_url, m_id, message->text);
+ client->sendString(m_url, m_id, message->text, m_proxy.get());
m_messages.removeFirst();
break;
case MessageTypeArrayBuffer:
- client->sendArrayBuffer(m_url, m_id, 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(), m_proxy.get());
m_messages.removeFirst();
break;
case MessageTypeBlob:
@@ -352,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;
@@ -456,10 +467,11 @@ void PresentationConnection::didFinishLoadingBlob(DOMArrayBuffer* buffer) {
ASSERT(buffer && buffer->buffer());
// Send the loaded blob immediately here and continue processing the queue.
WebPresentationClient* client = presentationClient(getExecutionContext());
- if (client)
+ if (client) {
client->sendBlobData(m_url, m_id,
static_cast<const uint8_t*>(buffer->data()),
- buffer->byteLength());
+ buffer->byteLength(), m_proxy.get());
+ }
m_messages.removeFirst();
m_blobLoader.clear();

Powered by Google App Engine
This is Rietveld 408576698