| 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 a7f9277425495cf896ebeef4e0b62b78a6cfe017..a3a48cd670d30d629092a0d15b32a1454f5006b0 100644
|
| --- a/content/browser/presentation/presentation_service_impl.cc
|
| +++ b/content/browser/presentation/presentation_service_impl.cc
|
| @@ -19,7 +19,6 @@
|
| #include "content/public/common/content_client.h"
|
| #include "content/public/common/frame_navigate_params.h"
|
| #include "content/public/common/presentation_connection_message.h"
|
| -#include "content/public/common/presentation_constants.h"
|
|
|
| namespace content {
|
|
|
| @@ -32,78 +31,6 @@ int GetNextRequestSessionId() {
|
| return ++next_request_session_id;
|
| }
|
|
|
| -// Converts a PresentationConnectionMessage |input| to a ConnectionMessage.
|
| -// |input|: The message to convert.
|
| -// |pass_ownership|: If true, function may reuse strings or buffers from
|
| -// |input| without copying. |input| can be freely modified.
|
| -blink::mojom::ConnectionMessagePtr ToMojoConnectionMessage(
|
| - content::PresentationConnectionMessage* input,
|
| - bool pass_ownership) {
|
| - DCHECK(input);
|
| - blink::mojom::ConnectionMessagePtr output(
|
| - blink::mojom::ConnectionMessage::New());
|
| - if (input->is_binary()) {
|
| - // binary data
|
| - DCHECK(input->data);
|
| - output->type = blink::mojom::PresentationMessageType::BINARY;
|
| - if (pass_ownership) {
|
| - output->data = std::move(*(input->data));
|
| - } else {
|
| - output->data = *(input->data);
|
| - }
|
| - } else {
|
| - // string message
|
| - output->type = blink::mojom::PresentationMessageType::TEXT;
|
| - if (pass_ownership) {
|
| - output->message = std::move(input->message);
|
| - } else {
|
| - output->message = input->message;
|
| - }
|
| - }
|
| - return output;
|
| -}
|
| -
|
| -std::unique_ptr<PresentationConnectionMessage> GetPresentationConnectionMessage(
|
| - blink::mojom::ConnectionMessagePtr input) {
|
| - std::unique_ptr<content::PresentationConnectionMessage> output;
|
| - if (input.is_null())
|
| - return output;
|
| -
|
| - switch (input->type) {
|
| - case blink::mojom::PresentationMessageType::TEXT: {
|
| - // Return nullptr PresentationConnectionMessage if invalid (unset
|
| - // |message|,
|
| - // set |data|, or size too large).
|
| - if (input->data || !input->message ||
|
| - input->message->size() >
|
| - content::kMaxPresentationConnectionMessageSize)
|
| - return output;
|
| -
|
| - output.reset(
|
| - new PresentationConnectionMessage(PresentationMessageType::TEXT));
|
| - output->message = std::move(input->message.value());
|
| - return output;
|
| - }
|
| - case blink::mojom::PresentationMessageType::BINARY: {
|
| - // Return nullptr PresentationConnectionMessage if invalid (unset |data|,
|
| - // set
|
| - // |message|, or size too large).
|
| - if (!input->data || input->message ||
|
| - input->data->size() > content::kMaxPresentationConnectionMessageSize)
|
| - return output;
|
| -
|
| - output.reset(
|
| - new PresentationConnectionMessage(PresentationMessageType::BINARY));
|
| - output->data.reset(
|
| - new std::vector<uint8_t>(std::move(input->data.value())));
|
| - return output;
|
| - }
|
| - }
|
| -
|
| - NOTREACHED() << "Invalid presentation message type " << input->type;
|
| - return output;
|
| -}
|
| -
|
| void InvokeNewSessionCallbackWithError(
|
| const PresentationServiceImpl::NewSessionCallback& callback) {
|
| callback.Run(base::nullopt,
|
| @@ -376,10 +303,9 @@ void PresentationServiceImpl::SetDefaultPresentationUrls(
|
|
|
| void PresentationServiceImpl::SendConnectionMessage(
|
| const PresentationSessionInfo& session_info,
|
| - blink::mojom::ConnectionMessagePtr connection_message,
|
| + const PresentationConnectionMessage& message,
|
| const SendConnectionMessageCallback& callback) {
|
| DVLOG(2) << "SendConnectionMessage [id]: " << session_info.presentation_id;
|
| - DCHECK(!connection_message.is_null());
|
| // send_message_callback_ should be null by now, otherwise resetting of
|
| // send_message_callback_ with new callback will drop the old callback.
|
| if (!controller_delegate_ || send_message_callback_) {
|
| @@ -389,8 +315,7 @@ void PresentationServiceImpl::SendConnectionMessage(
|
|
|
| send_message_callback_.reset(new SendConnectionMessageCallback(callback));
|
| controller_delegate_->SendMessage(
|
| - render_process_id_, render_frame_id_, session_info,
|
| - GetPresentationConnectionMessage(std::move(connection_message)),
|
| + render_process_id_, render_frame_id_, session_info, message,
|
| base::Bind(&PresentationServiceImpl::OnSendMessageCallback,
|
| weak_factory_.GetWeakPtr()));
|
| }
|
| @@ -480,21 +405,11 @@ void PresentationServiceImpl::SetPresentationConnection(
|
|
|
| void PresentationServiceImpl::OnConnectionMessages(
|
| const PresentationSessionInfo& session_info,
|
| - const std::vector<std::unique_ptr<PresentationConnectionMessage>>& messages,
|
| - bool pass_ownership) {
|
| + const std::vector<PresentationConnectionMessage>& messages) {
|
| DCHECK(client_);
|
|
|
| DVLOG(2) << "OnConnectionMessages [id]: " << session_info.presentation_id;
|
| - std::vector<blink::mojom::ConnectionMessagePtr> mojo_messages(
|
| - messages.size());
|
| - std::transform(
|
| - messages.begin(), messages.end(), mojo_messages.begin(),
|
| - [pass_ownership](
|
| - const std::unique_ptr<PresentationConnectionMessage>& message) {
|
| - return ToMojoConnectionMessage(message.get(), pass_ownership);
|
| - });
|
| -
|
| - client_->OnConnectionMessagesReceived(session_info, std::move(mojo_messages));
|
| + client_->OnConnectionMessagesReceived(session_info, messages);
|
| }
|
|
|
| void PresentationServiceImpl::OnReceiverConnectionAvailable(
|
| @@ -568,7 +483,7 @@ void PresentationServiceImpl::Reset() {
|
|
|
| if (on_connection_messages_callback_.get()) {
|
| on_connection_messages_callback_->Run(
|
| - std::vector<blink::mojom::ConnectionMessagePtr>());
|
| + std::vector<PresentationConnectionMessage>());
|
| on_connection_messages_callback_.reset();
|
| }
|
|
|
|
|