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 40d0501da5ab3aa60b739c46df2ffcb1e77b7bed..f19c4daeb11a28b3794fde7c95694896352b4025 100644 |
| --- a/content/renderer/presentation/presentation_dispatcher.cc |
| +++ b/content/renderer/presentation/presentation_dispatcher.cc |
| @@ -14,12 +14,14 @@ |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "content/public/common/presentation_constants.h" |
| #include "content/public/renderer/render_frame.h" |
| +#include "content/renderer/presentation/presentation_connection_proxy.h" |
| #include "mojo/public/cpp/bindings/type_converter.h" |
| #include "services/service_manager/public/cpp/interface_provider.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| #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/WebPresentationConnection.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" |
| @@ -223,12 +225,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) |
|
mark a. foltz
2017/01/23 22:29:34
Is the static_cast necessary? I don't see where r
zhaobin
2017/01/24 19:28:46
It is declared in 4th patch as WebPresentationConn
|
| + ->SendConnectionMessage( |
| + std::move(request->message), |
| + base::Bind(&PresentationDispatcher::HandleSendMessageRequests, |
| + base::Unretained(this))); |
| } |
| void PresentationDispatcher::HandleSendMessageRequests(bool success) { |
| @@ -402,8 +404,15 @@ void PresentationDispatcher::OnDefaultSessionStarted( |
| if (!session_info.is_null()) { |
| presentation_service_->ListenForConnectionMessages(session_info.Clone()); |
| - controller_->didStartDefaultSession( |
| + auto* connection = controller_->didStartDefaultSession( |
| mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
| + |
| + auto* controller_connection_proxy = |
|
mark a. foltz
2017/01/23 22:29:34
This block of code is duplicated with L437-442. P
zhaobin
2017/01/24 19:28:46
Done.
|
| + new ControllerConnectionProxy(connection); |
| + connection->setProxy(base::WrapUnique(controller_connection_proxy)); |
| + presentation_service_->SetPresentationConnection( |
| + session_info.Clone(), controller_connection_proxy->Bind(), |
| + controller_connection_proxy->MakeRemoteRequest()); |
| } |
| } |
| @@ -424,16 +433,31 @@ void PresentationDispatcher::OnSessionCreated( |
| presentation_service_->ListenForConnectionMessages(session_info.Clone()); |
| callback->onSuccess( |
| mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
| + |
| + auto* connection = callback->getConnection(); |
| + auto* controller_connection_proxy = new ControllerConnectionProxy(connection); |
| + connection->setProxy(base::WrapUnique(controller_connection_proxy)); |
| + presentation_service_->SetPresentationConnection( |
| + session_info.Clone(), controller_connection_proxy->Bind(), |
| + controller_connection_proxy->MakeRemoteRequest()); |
| } |
| void PresentationDispatcher::OnReceiverConnectionAvailable( |
| blink::mojom::PresentationSessionInfoPtr session_info, |
| - blink::mojom::PresentationConnectionPtr, |
| - blink::mojom::PresentationConnectionRequest) { |
| - if (!receiver_) { |
| - receiver_->onReceiverConnectionAvailable( |
| - mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
| - } |
| + 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( |
| + mojo::ConvertTo<blink::WebPresentationSessionInfo>(session_info)); |
| + auto* receiver_connection_proxy = new ReceiverConnectionProxy(connection); |
| + connection->setProxy(base::WrapUnique(receiver_connection_proxy)); |
| + |
| + receiver_connection_proxy->Bind(std::move(receiver_connection_request)); |
| + receiver_connection_proxy->SetTargetConnection( |
| + std::move(controller_connection_ptr)); |
| } |
| void PresentationDispatcher::OnConnectionStateChanged( |