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

Unified Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 2471263003: [Presentation API] (4th)(1-UA blink side) Add WebPresentationConnection and WebPresentationConnecti… (Closed)
Patch Set: PresentationConnectionProxy::Send() will be invoked from PresentationDispatcher Created 4 years, 1 month 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: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index 325cac65c7892474fdff2f974d21d4bd3557c4bf..c25efc23f8a27236a8d11127d8befba5b1ffc3b4 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -13,6 +13,7 @@
#include "content/public/common/presentation_constants.h"
#include "content/public/renderer/render_frame.h"
#include "content/renderer/presentation/presentation_connection_client.h"
+#include "content/renderer/presentation/presentation_connection_proxy.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
@@ -139,9 +140,11 @@ void PresentationDispatcher::joinSession(
base::Unretained(this), base::Owned(callback)));
}
-void PresentationDispatcher::sendString(const blink::WebURL& presentationUrl,
- const blink::WebString& presentationId,
- const blink::WebString& message) {
+void PresentationDispatcher::sendString(
+ const blink::WebURL& presentationUrl,
+ const blink::WebString& presentationId,
+ const blink::WebString& message,
+ const blink::WebPresentationConnectionProxy* connection_proxy) {
if (message.utf8().size() > kMaxPresentationSessionMessageSize) {
// TODO(crbug.com/459008): Limit the size of individual messages to 64k
// for now. Consider throwing DOMException or splitting bigger messages
@@ -154,14 +157,15 @@ void PresentationDispatcher::sendString(const blink::WebURL& presentationUrl,
CreateSendTextMessageRequest(presentationUrl, presentationId, message)));
// Start processing request if only one in the queue.
if (message_request_queue_.size() == 1)
- DoSendMessage(message_request_queue_.front().get());
+ DoSendMessage(message_request_queue_.front().get(), connection_proxy);
}
void PresentationDispatcher::sendArrayBuffer(
const blink::WebURL& presentationUrl,
const blink::WebString& presentationId,
const uint8_t* data,
- size_t length) {
+ size_t length,
+ const blink::WebPresentationConnectionProxy* connection_proxy) {
DCHECK(data);
if (length > kMaxPresentationSessionMessageSize) {
// TODO(crbug.com/459008): Same as in sendString().
@@ -174,14 +178,15 @@ void PresentationDispatcher::sendArrayBuffer(
blink::mojom::PresentationMessageType::ARRAY_BUFFER, data, length)));
// Start processing request if only one in the queue.
if (message_request_queue_.size() == 1)
- DoSendMessage(message_request_queue_.front().get());
+ DoSendMessage(message_request_queue_.front().get(), connection_proxy);
}
void PresentationDispatcher::sendBlobData(
const blink::WebURL& presentationUrl,
const blink::WebString& presentationId,
const uint8_t* data,
- size_t length) {
+ size_t length,
+ const blink::WebPresentationConnectionProxy* connection_proxy) {
DCHECK(data);
if (length > kMaxPresentationSessionMessageSize) {
// TODO(crbug.com/459008): Same as in sendString().
@@ -194,19 +199,23 @@ void PresentationDispatcher::sendBlobData(
blink::mojom::PresentationMessageType::BLOB, data, length)));
// Start processing request if only one in the queue.
if (message_request_queue_.size() == 1)
- DoSendMessage(message_request_queue_.front().get());
+ DoSendMessage(message_request_queue_.front().get(), connection_proxy);
}
-void PresentationDispatcher::DoSendMessage(SendMessageRequest* request) {
+void PresentationDispatcher::DoSendMessage(
+ SendMessageRequest* request,
+ const blink::WebPresentationConnectionProxy* connection_proxy) {
ConnectToPresentationServiceIfNeeded();
presentation_service_->SendSessionMessage(
std::move(request->session_info), std::move(request->message),
base::Bind(&PresentationDispatcher::HandleSendMessageRequests,
- base::Unretained(this)));
+ base::Unretained(this), nullptr));
}
-void PresentationDispatcher::HandleSendMessageRequests(bool success) {
+void PresentationDispatcher::HandleSendMessageRequests(
+ const blink::WebPresentationConnectionProxy* connection_proxy,
+ bool success) {
// In normal cases, message_request_queue_ should not be empty at this point
// of time, but when DidCommitProvisionalLoad() is invoked before receiving
// the callback for previous send mojo call, queue would have been emptied.
@@ -223,7 +232,7 @@ void PresentationDispatcher::HandleSendMessageRequests(bool success) {
message_request_queue_.pop();
if (!message_request_queue_.empty()) {
- DoSendMessage(message_request_queue_.front().get());
+ DoSendMessage(message_request_queue_.front().get(), connection_proxy);
}
}
@@ -446,7 +455,7 @@ void PresentationDispatcher::OnSessionMessagesReceived(
// Note: Passing batches of messages to the Blink layer would be more
// efficient.
std::unique_ptr<PresentationConnectionClient> session_client(
- new PresentationConnectionClient(session_info->url, session_info->id));
+ new PresentationConnectionClient(session_info.Clone()));
switch (messages[i]->type) {
case blink::mojom::PresentationMessageType::TEXT: {
// TODO(mfoltz): Do we need to DCHECK(messages[i]->message)?

Powered by Google App Engine
This is Rietveld 408576698