Index: content/renderer/presentation/presentation_dispatcher.cc |
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc |
index 89fd11db4175e96f998dda9824aa2e26707e4c9c..ee4d7733d669d4c66fa0d464302bdae2502becee 100644 |
--- a/content/renderer/presentation/presentation_dispatcher.cc |
+++ b/content/renderer/presentation/presentation_dispatcher.cc |
@@ -224,12 +224,12 @@ void PresentationDispatcher::sendBlobData( |
} |
void PresentationDispatcher::DoSendMessage(SendMessageRequest* request) { |
- ConnectToPresentationServiceIfNeeded(); |
- |
- presentation_service_->SendConnectionMessage( |
- std::move(request->session_info), std::move(request->message), |
- base::Bind(&PresentationDispatcher::HandleSendMessageRequests, |
- base::Unretained(this))); |
+ DCHECK(request->connection_proxy); |
+ static_cast<const PresentationConnectionProxy*>(request->connection_proxy) |
+ ->SendConnectionMessage( |
+ std::move(request->message), |
+ base::Bind(&PresentationDispatcher::HandleSendMessageRequests, |
+ base::Unretained(this))); |
} |
void PresentationDispatcher::HandleSendMessageRequests(bool success) { |
@@ -253,6 +253,20 @@ void PresentationDispatcher::HandleSendMessageRequests(bool success) { |
} |
} |
+void PresentationDispatcher::SetControllerConnection( |
+ blink::mojom::PresentationSessionInfoPtr session_info, |
+ blink::WebPresentationConnection* connection) { |
+ DCHECK(connection); |
+ |
+ auto* controller_connection_proxy = new ControllerConnectionProxy(connection); |
+ connection->bindProxy(base::WrapUnique(controller_connection_proxy)); |
+ |
+ ConnectToPresentationServiceIfNeeded(); |
+ presentation_service_->SetPresentationConnection( |
+ session_info.Clone(), controller_connection_proxy->Bind(), |
+ controller_connection_proxy->MakeRemoteRequest()); |
+} |
+ |
void PresentationDispatcher::closeSession( |
const blink::WebURL& presentationUrl, |
const blink::WebString& presentationId) { |
@@ -488,9 +502,8 @@ void PresentationDispatcher::OnDefaultSessionStarted( |
presentation_service_->ListenForConnectionMessages(session_info.Clone()); |
auto* connection = controller_->didStartDefaultSession( |
mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
- auto* controller_connection_proxy = |
- new ControllerConnectionProxy(connection); |
- connection->bindProxy(base::WrapUnique(controller_connection_proxy)); |
+ if (connection) |
+ SetControllerConnection(session_info.Clone(), connection); |
} |
} |
@@ -511,11 +524,7 @@ void PresentationDispatcher::OnSessionCreated( |
presentation_service_->ListenForConnectionMessages(session_info.Clone()); |
callback->onSuccess( |
mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
- |
- auto* connection = callback->getConnection(); |
- DCHECK(connection); |
- auto* controller_connection_proxy = new ControllerConnectionProxy(connection); |
- connection->bindProxy(base::WrapUnique(controller_connection_proxy)); |
+ SetControllerConnection(session_info.Clone(), callback->getConnection()); |
} |
void PresentationDispatcher::OnReceiverConnectionAvailable( |
@@ -523,6 +532,7 @@ void PresentationDispatcher::OnReceiverConnectionAvailable( |
blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
blink::mojom::PresentationConnectionRequest receiver_connection_request) { |
DCHECK(receiver_); |
+ |
// Bind receiver_connection_proxy with PresentationConnection in receiver |
// page. |
auto* connection = receiver_->onReceiverConnectionAvailable( |