Chromium Code Reviews| 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..b8e1bb7571a15f20da5cd6bf77c97aab5f0a3e98 100644 |
| --- a/content/browser/presentation/presentation_service_impl.cc |
| +++ b/content/browser/presentation/presentation_service_impl.cc |
| @@ -22,6 +22,8 @@ namespace content { |
| namespace { |
| +using presentation::PresentationMessageType; |
|
jochen (gone - plz use gerrit)
2015/06/09 08:29:06
please don't use "using" other for helping for lar
USE s.singapati at gmail.com
2015/06/09 09:07:18
Acknowledged. Yes this is a small change from PS#3
USE s.singapati at gmail.com
2015/06/09 14:12:17
Done.
|
| + |
| const int kInvalidRequestSessionId = -1; |
| int GetNextRequestSessionId() { |
| @@ -37,13 +39,12 @@ presentation::SessionMessagePtr ToMojoSessionMessage( |
| output->presentation_id.Swap(&input->presentation_id); |
| if (input->is_binary()) { |
| // binary data |
| - output->type = presentation::PresentationMessageType:: |
| - PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; |
| + output->type = |
| + PresentationMessageType::PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; |
| output->data.Swap(input->data.get()); |
| } else { |
| // string message |
| - output->type = |
| - presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT; |
| + output->type = PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT; |
| output->message.Swap(input->message.get()); |
| } |
| return output.Pass(); |
| @@ -53,35 +54,47 @@ 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 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 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 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(); |
| } |