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

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

Issue 1140713005: [PresentationAPI] Implements send API for Blob data from WebPresentationClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit tests Created 5 years, 7 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: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index 29f5047f0b57ec0639ff4d9765a2c645beb807f9..24ecf099c1389f20eb95be748222b7a284374243 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -54,6 +54,21 @@ GURL GetPresentationURLFromFrame(content::RenderFrame* frame) {
return url.is_valid() ? url : GURL();
}
+presentation::SessionMessage* GetMojoSessionMessage(
+ const blink::WebString& presentationUrl,
+ const blink::WebString& presentationId,
+ const uint8* data,
+ size_t length) {
+ presentation::SessionMessage* session_message =
+ new presentation::SessionMessage();
+ session_message->presentation_url = presentationUrl.utf8();
+ session_message->presentation_id = presentationId.utf8();
+ const std::vector<uint8> vector(data, data + length);
+ session_message->data = mojo::Array<uint8>::From(vector);
+ // Fill session_message->type in the caller.
mark a. foltz 2015/06/02 23:51:02 Why not pass the type as an argument and fill it i
USE s.singapati at gmail.com 2015/06/03 15:03:50 Done. Well, Yes.
+ return session_message;
+}
+
} // namespace
namespace content {
@@ -165,15 +180,10 @@ void PresentationDispatcher::sendArrayBuffer(
return;
}
- const std::vector<uint8> vector(data, data + length);
presentation::SessionMessage* session_message =
- new presentation::SessionMessage();
- session_message->presentation_url = presentationUrl.utf8();
- session_message->presentation_id = presentationId.utf8();
+ GetMojoSessionMessage(presentationUrl, presentationId, data, length);
session_message->type = presentation::PresentationMessageType::
PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER;
- session_message->data = mojo::Array<uint8>::From(vector);
-
message_request_queue_.push(make_linked_ptr(session_message));
// Start processing request if only one in the queue.
if (message_request_queue_.size() == 1) {
@@ -183,6 +193,30 @@ void PresentationDispatcher::sendArrayBuffer(
}
}
+void PresentationDispatcher::sendBlobData(
+ const blink::WebString& presentationUrl,
+ const blink::WebString& presentationId,
+ const uint8* data,
+ size_t length) {
+ DCHECK(data);
+ if (length > kMaxPresentationSessionMessageSize) {
+ // TODO(crbug.com/459008): Same as in sendString().
+ LOG(WARNING) << "data size exceeded limit!";
+ return;
+ }
+
+ presentation::SessionMessage* session_message =
+ GetMojoSessionMessage(presentationUrl, presentationId, data, length);
+ session_message->type = presentation::PresentationMessageType::
+ PRESENTATION_MESSAGE_TYPE_BLOB;
+ message_request_queue_.push(make_linked_ptr(session_message));
+ if (message_request_queue_.size() == 1) {
+ const linked_ptr<presentation::SessionMessage>& request =
+ message_request_queue_.front();
+ DoSendMessage(*request);
+ }
+}
+
void PresentationDispatcher::DoSendMessage(
const presentation::SessionMessage& session_message) {
ConnectToPresentationServiceIfNeeded();
@@ -195,8 +229,8 @@ void PresentationDispatcher::DoSendMessage(
if (session_message.type == presentation::PresentationMessageType::
PRESENTATION_MESSAGE_TYPE_TEXT) {
message_request->message = session_message.message;
- } else if (session_message.type == presentation::PresentationMessageType::
- PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER) {
+ } else {
+ // ArrayBuffer or Blob types.
mark a. foltz 2015/06/02 23:51:02 Prefer seeing a switch { } statement here with a d
USE s.singapati at gmail.com 2015/06/03 15:03:50 Done.
message_request->data = mojo::Array<uint8>::From(
session_message.data.storage());
}

Powered by Google App Engine
This is Rietveld 408576698