Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/presentation/presentation_dispatcher.h" | 5 #include "content/renderer/presentation/presentation_dispatcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 namespace content { | 79 namespace content { |
| 80 | 80 |
| 81 PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) | 81 PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame) |
| 82 : RenderFrameObserver(render_frame), | 82 : RenderFrameObserver(render_frame), |
| 83 controller_(nullptr), | 83 controller_(nullptr), |
| 84 binding_(this) { | 84 receiver_(nullptr), |
| 85 } | 85 binding_(this) {} |
| 86 | 86 |
| 87 PresentationDispatcher::~PresentationDispatcher() { | 87 PresentationDispatcher::~PresentationDispatcher() { |
| 88 // Controller should be destroyed before the dispatcher when frame is | 88 // Controller should be destroyed before the dispatcher when frame is |
| 89 // destroyed. | 89 // destroyed. |
| 90 DCHECK(!controller_); | 90 DCHECK(!controller_); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void PresentationDispatcher::setController( | 93 void PresentationDispatcher::setController( |
| 94 blink::WebPresentationController* controller) { | 94 blink::WebPresentationController* controller) { |
| 95 // There shouldn't be any swapping from one non-null controller to another. | 95 // There shouldn't be any swapping from one non-null controller to another. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 if (!error.is_null()) { | 387 if (!error.is_null()) { |
| 388 DCHECK(session_info.is_null()); | 388 DCHECK(session_info.is_null()); |
| 389 callback->onError(blink::WebPresentationError( | 389 callback->onError(blink::WebPresentationError( |
| 390 GetWebPresentationErrorTypeFromMojo(error->error_type), | 390 GetWebPresentationErrorTypeFromMojo(error->error_type), |
| 391 blink::WebString::fromUTF8(error->message))); | 391 blink::WebString::fromUTF8(error->message))); |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 | 394 |
| 395 DCHECK(!session_info.is_null()); | 395 DCHECK(!session_info.is_null()); |
| 396 presentation_service_->ListenForSessionMessages(session_info.Clone()); | 396 presentation_service_->ListenForSessionMessages(session_info.Clone()); |
| 397 callback->onSuccess( | 397 |
| 398 base::MakeUnique<PresentationConnectionClient>(std::move(session_info))); | 398 RendererPresentationConnection* controller_connection_proxy = |
|
mark a. foltz
2016/10/10 18:28:52
How do you know this connection is for an offscree
zhaobin
2016/10/12 02:27:33
Done.
| |
| 399 new RendererPresentationConnection(); | |
| 400 // Bind controller_connection_proxy with PresentationConnection | |
| 401 // in controller page. | |
| 402 callback->onSuccess(base::MakeUnique<PresentationConnectionClient>( | |
|
imcheng
2016/10/12 02:22:55
It looks like we don't need the 2-argument Present
zhaobin
2016/10/13 02:33:52
Did some changes in new patch so we use 2-argument
| |
| 403 session_info.Clone(), controller_connection_proxy)); | |
| 404 | |
| 405 // Pass controller_connection_proxy to PSImpl and register | |
| 406 // it with OffscreenPresentationManager. | |
| 407 presentation_service_->SetPresentationConnection( | |
| 408 session_info.Clone(), controller_connection_proxy->Bind()); | |
|
imcheng
2016/10/12 02:22:54
|controller_connection_proxy| might have already b
zhaobin
2016/10/13 02:33:52
Done.
| |
| 399 } | 409 } |
| 400 | 410 |
| 401 void PresentationDispatcher::OnReceiverConnectionAvailable( | 411 void PresentationDispatcher::OnReceiverConnectionAvailable( |
| 402 blink::mojom::PresentationSessionInfoPtr session_info) { | 412 blink::mojom::PresentationSessionInfoPtr session_info, |
| 403 if (receiver_) { | 413 blink::mojom::PresentationConnectionPtr controller) { |
| 404 receiver_->onReceiverConnectionAvailable( | 414 if (!receiver_) |
| 405 new PresentationConnectionClient(std::move(session_info))); | 415 return; |
| 406 } | 416 |
| 417 RendererPresentationConnection* receiver_connection_proxy = | |
| 418 new RendererPresentationConnection(); | |
| 419 // Bind receiver_connection_proxy with PresentationConnection | |
| 420 // in receiver page. | |
| 421 receiver_->onReceiverConnectionAvailable(new PresentationConnectionClient( | |
| 422 std::move(session_info), receiver_connection_proxy)); | |
| 423 | |
| 424 controller->SetTargetConnection(receiver_connection_proxy->Bind()); | |
| 425 receiver_connection_proxy->SetTargetConnection(std::move(controller)); | |
| 407 } | 426 } |
| 408 | 427 |
| 409 void PresentationDispatcher::OnConnectionStateChanged( | 428 void PresentationDispatcher::OnConnectionStateChanged( |
| 410 blink::mojom::PresentationSessionInfoPtr connection, | 429 blink::mojom::PresentationSessionInfoPtr connection, |
| 411 blink::mojom::PresentationConnectionState state) { | 430 blink::mojom::PresentationConnectionState state) { |
| 412 if (!controller_) | 431 if (!controller_) |
| 413 return; | 432 return; |
| 414 | 433 |
| 415 DCHECK(!connection.is_null()); | 434 DCHECK(!connection.is_null()); |
| 416 controller_->didChangeSessionState( | 435 controller_->didChangeSessionState( |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( | 562 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( |
| 544 const GURL& availability_url) | 563 const GURL& availability_url) |
| 545 : url(availability_url), | 564 : url(availability_url), |
| 546 last_known_availability(false), | 565 last_known_availability(false), |
| 547 listening_state(ListeningState::INACTIVE) {} | 566 listening_state(ListeningState::INACTIVE) {} |
| 548 | 567 |
| 549 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { | 568 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { |
| 550 } | 569 } |
| 551 | 570 |
| 552 } // namespace content | 571 } // namespace content |
| OLD | NEW |