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

Unified Diff: content/browser/presentation/presentation_service_impl.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: reverted "using presentation::PresentationMessageType" Created 5 years, 6 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
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/presentation/presentation_service_impl.cc
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc
index 916ddedd356548c9607c8a1ca4b26fba513c95ed..a3299c7843a7094f0e536f6246c39211bda5bcc4 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -53,35 +53,50 @@ scoped_ptr<content::PresentationSessionMessage> GetPresentationSessionMessage(
presentation::SessionMessagePtr input) {
DCHECK(!input.is_null());
scoped_ptr<content::PresentationSessionMessage> output;
- if (input->type == presentation::PresentationMessageType::
- PRESENTATION_MESSAGE_TYPE_TEXT) {
- DCHECK(!input->message.is_null());
- DCHECK(input->data.is_null());
- // Return null PresentationSessionMessage if size exceeds.
- if (input->message.size() > content::kMaxPresentationSessionMessageSize)
+ switch (input->type) {
+ case presentation::PresentationMessageType::
+ PRESENTATION_MESSAGE_TYPE_TEXT: {
+ DCHECK(!input->message.is_null());
+ DCHECK(input->data.is_null());
+ // Return null PresentationSessionMessage if size exceeds.
+ if (input->message.size() > content::kMaxPresentationSessionMessageSize)
+ return output.Pass();
+
+ output = content::PresentationSessionMessage::CreateStringMessage(
+ input->presentation_url, input->presentation_id,
+ make_scoped_ptr(new std::string));
+ input->message.Swap(output->message.get());
return output.Pass();
-
- output = content::PresentationSessionMessage::CreateStringMessage(
- input->presentation_url,
- input->presentation_id,
- make_scoped_ptr(new std::string));
- input->message.Swap(output->message.get());
-
- } else if (input->type == presentation::PresentationMessageType::
- PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER) {
- DCHECK(!input->data.is_null());
- DCHECK(input->message.is_null());
- // Return null PresentationSessionMessage if size exceeds.
- if (input->data.size() > content::kMaxPresentationSessionMessageSize)
+ }
+ case presentation::PresentationMessageType::
+ PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER: {
+ DCHECK(!input->data.is_null());
+ DCHECK(input->message.is_null());
+ if (input->data.size() > content::kMaxPresentationSessionMessageSize)
+ return output.Pass();
+
+ output = content::PresentationSessionMessage::CreateArrayBufferMessage(
+ input->presentation_url, input->presentation_id,
+ make_scoped_ptr(new std::vector<uint8_t>));
+ input->data.Swap(output->data.get());
return output.Pass();
-
- output = content::PresentationSessionMessage::CreateBinaryMessage(
- input->presentation_url,
- input->presentation_id,
- make_scoped_ptr(new std::vector<uint8_t>));
- input->data.Swap(output->data.get());
+ }
+ case presentation::PresentationMessageType::
+ PRESENTATION_MESSAGE_TYPE_BLOB: {
+ DCHECK(!input->data.is_null());
+ DCHECK(input->message.is_null());
+ if (input->data.size() > content::kMaxPresentationSessionMessageSize)
+ return output.Pass();
+
+ output = content::PresentationSessionMessage::CreateBlobMessage(
+ input->presentation_url, input->presentation_id,
+ make_scoped_ptr(new std::vector<uint8_t>));
+ input->data.Swap(output->data.get());
+ return output.Pass();
+ }
}
+ NOTREACHED() << "Invalid presentation message type " << input->type;
return output.Pass();
}
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698