Chromium Code Reviews| Index: content/renderer/presentation/presentation_dispatcher.cc |
| diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
| index 3d18e10a30a50942721b25bbc21e37315c027ead..f48a9f2234d27bdb324f69f41f566575c54796b2 100644 |
| --- a/content/renderer/presentation/presentation_dispatcher.cc |
| +++ b/content/renderer/presentation/presentation_dispatcher.cc |
| @@ -20,6 +20,7 @@ |
| #include "third_party/WebKit/public/platform/WebURL.h" |
| #include "third_party/WebKit/public/platform/WebVector.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationAvailabilityObserver.h" |
| +#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationConnectionCallbacks.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationError.h" |
| #include "third_party/WebKit/public/platform/modules/presentation/WebPresentationReceiver.h" |
| @@ -100,8 +101,8 @@ namespace content { |
| PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) |
| : RenderFrameObserver(render_frame), |
| controller_(nullptr), |
| - binding_(this) { |
| -} |
| + receiver_(nullptr), |
| + binding_(this) {} |
| PresentationDispatcher::~PresentationDispatcher() { |
| // Controller should be destroyed before the dispatcher when frame is |
| @@ -121,7 +122,7 @@ void PresentationDispatcher::setController( |
| void PresentationDispatcher::startSession( |
| const blink::WebVector<blink::WebURL>& presentationUrls, |
| - std::unique_ptr<blink::WebPresentationConnectionCallback> callback) { |
| + std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback) { |
| DCHECK(callback); |
| ConnectToPresentationServiceIfNeeded(); |
| @@ -140,7 +141,7 @@ void PresentationDispatcher::startSession( |
| void PresentationDispatcher::joinSession( |
| const blink::WebVector<blink::WebURL>& presentationUrls, |
| const blink::WebString& presentationId, |
| - std::unique_ptr<blink::WebPresentationConnectionCallback> callback) { |
| + std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback) { |
| DCHECK(callback); |
| ConnectToPresentationServiceIfNeeded(); |
| @@ -157,9 +158,11 @@ void PresentationDispatcher::joinSession( |
| base::Unretained(this), base::Passed(&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() > kMaxPresentationConnectionMessageSize) { |
| // TODO(crbug.com/459008): Limit the size of individual messages to 64k |
| // for now. Consider throwing DOMException or splitting bigger messages |
| @@ -168,8 +171,8 @@ void PresentationDispatcher::sendString(const blink::WebURL& presentationUrl, |
| return; |
| } |
| - message_request_queue_.push(base::WrapUnique( |
| - CreateSendTextMessageRequest(presentationUrl, presentationId, message))); |
| + message_request_queue_.push(base::WrapUnique(CreateSendTextMessageRequest( |
| + presentationUrl, presentationId, message, connection_proxy))); |
| // Start processing request if only one in the queue. |
| if (message_request_queue_.size() == 1) |
| DoSendMessage(message_request_queue_.front().get()); |
| @@ -179,7 +182,8 @@ 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 > kMaxPresentationConnectionMessageSize) { |
| // TODO(crbug.com/459008): Same as in sendString(). |
| @@ -189,7 +193,8 @@ void PresentationDispatcher::sendArrayBuffer( |
| message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest( |
| presentationUrl, presentationId, |
| - blink::mojom::PresentationMessageType::BINARY, data, length))); |
| + blink::mojom::PresentationMessageType::BINARY, data, length, |
| + connection_proxy))); |
| // Start processing request if only one in the queue. |
| if (message_request_queue_.size() == 1) |
| DoSendMessage(message_request_queue_.front().get()); |
| @@ -199,7 +204,8 @@ 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 > kMaxPresentationConnectionMessageSize) { |
| // TODO(crbug.com/459008): Same as in sendString(). |
| @@ -209,7 +215,8 @@ void PresentationDispatcher::sendBlobData( |
| message_request_queue_.push(base::WrapUnique(CreateSendBinaryMessageRequest( |
| presentationUrl, presentationId, |
| - blink::mojom::PresentationMessageType::BINARY, data, length))); |
| + blink::mojom::PresentationMessageType::BINARY, data, length, |
| + connection_proxy))); |
| // Start processing request if only one in the queue. |
| if (message_request_queue_.size() == 1) |
| DoSendMessage(message_request_queue_.front().get()); |
| @@ -407,7 +414,7 @@ void PresentationDispatcher::OnDefaultSessionStarted( |
| } |
| void PresentationDispatcher::OnSessionCreated( |
| - std::unique_ptr<blink::WebPresentationConnectionCallback> callback, |
| + std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback, |
| blink::mojom::PresentationSessionInfoPtr session_info, |
| blink::mojom::PresentationErrorPtr error) { |
| DCHECK(callback); |
| @@ -429,7 +436,7 @@ void PresentationDispatcher::OnReceiverConnectionAvailable( |
| blink::mojom::PresentationSessionInfoPtr session_info, |
| blink::mojom::PresentationConnectionPtr, |
| blink::mojom::PresentationConnectionRequest) { |
| - if (receiver_) { |
| + if (!receiver_) { |
|
imcheng
2017/01/20 20:15:43
revert?
zhaobin
2017/01/23 19:38:49
Done.
|
| receiver_->onReceiverConnectionAvailable( |
| mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
| } |
| @@ -521,8 +528,11 @@ void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { |
| PresentationDispatcher::SendMessageRequest::SendMessageRequest( |
| blink::mojom::PresentationSessionInfoPtr session_info, |
| - blink::mojom::ConnectionMessagePtr message) |
| - : session_info(std::move(session_info)), message(std::move(message)) {} |
| + blink::mojom::ConnectionMessagePtr message, |
| + const blink::WebPresentationConnectionProxy* connection_proxy) |
| + : session_info(std::move(session_info)), |
| + message(std::move(message)), |
| + connection_proxy(connection_proxy) {} |
| PresentationDispatcher::SendMessageRequest::~SendMessageRequest() {} |
| @@ -531,7 +541,8 @@ PresentationDispatcher::SendMessageRequest* |
| PresentationDispatcher::CreateSendTextMessageRequest( |
| const blink::WebURL& presentationUrl, |
| const blink::WebString& presentationId, |
| - const blink::WebString& message) { |
| + const blink::WebString& message, |
| + const blink::WebPresentationConnectionProxy* connection_proxy) { |
| blink::mojom::PresentationSessionInfoPtr session_info = |
| blink::mojom::PresentationSessionInfo::New(); |
| session_info->url = presentationUrl; |
| @@ -542,7 +553,7 @@ PresentationDispatcher::CreateSendTextMessageRequest( |
| session_message->type = blink::mojom::PresentationMessageType::TEXT; |
| session_message->message = message.utf8(); |
| return new SendMessageRequest(std::move(session_info), |
| - std::move(session_message)); |
| + std::move(session_message), connection_proxy); |
| } |
| // static |
| @@ -552,7 +563,8 @@ PresentationDispatcher::CreateSendBinaryMessageRequest( |
| const blink::WebString& presentationId, |
| blink::mojom::PresentationMessageType type, |
| const uint8_t* data, |
| - size_t length) { |
| + size_t length, |
| + const blink::WebPresentationConnectionProxy* connection_proxy) { |
| blink::mojom::PresentationSessionInfoPtr session_info = |
| blink::mojom::PresentationSessionInfo::New(); |
| session_info->url = presentationUrl; |
| @@ -563,7 +575,7 @@ PresentationDispatcher::CreateSendBinaryMessageRequest( |
| session_message->type = type; |
| session_message->data = std::vector<uint8_t>(data, data + length); |
| return new SendMessageRequest(std::move(session_info), |
| - std::move(session_message)); |
| + std::move(session_message), connection_proxy); |
| } |
| PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( |