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/browser/presentation/presentation_service_impl.h" | 5 #include "content/browser/presentation/presentation_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 render_process_id_, render_frame_id_, presentation_urls, | 382 render_process_id_, render_frame_id_, presentation_urls, |
383 base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted, | 383 base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted, |
384 weak_factory_.GetWeakPtr())); | 384 weak_factory_.GetWeakPtr())); |
385 } | 385 } |
386 | 386 |
387 void PresentationServiceImpl::SendConnectionMessage( | 387 void PresentationServiceImpl::SendConnectionMessage( |
388 blink::mojom::PresentationSessionInfoPtr session, | 388 blink::mojom::PresentationSessionInfoPtr session, |
389 blink::mojom::ConnectionMessagePtr connection_message, | 389 blink::mojom::ConnectionMessagePtr connection_message, |
390 const SendConnectionMessageCallback& callback) { | 390 const SendConnectionMessageCallback& callback) { |
391 DVLOG(2) << "SendConnectionMessage" | 391 DVLOG(2) << "SendConnectionMessage" |
392 << " [id]: " << session->id; | 392 << " [presentation id]: " << session->id; |
393 DCHECK(!connection_message.is_null()); | 393 DCHECK(!connection_message.is_null()); |
394 // send_message_callback_ should be null by now, otherwise resetting of | 394 // send_message_callback_ should be null by now, otherwise resetting of |
395 // send_message_callback_ with new callback will drop the old callback. | 395 // send_message_callback_ with new callback will drop the old callback. |
396 if (!controller_delegate_ || send_message_callback_) { | 396 if (!controller_delegate_ || send_message_callback_) { |
397 callback.Run(false); | 397 callback.Run(false); |
398 return; | 398 return; |
399 } | 399 } |
400 | 400 |
401 send_message_callback_.reset(new SendConnectionMessageCallback(callback)); | 401 send_message_callback_.reset(new SendConnectionMessageCallback(callback)); |
402 controller_delegate_->SendMessage( | 402 controller_delegate_->SendMessage( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 void PresentationServiceImpl::SetPresentationConnection( | 484 void PresentationServiceImpl::SetPresentationConnection( |
485 blink::mojom::PresentationSessionInfoPtr session, | 485 blink::mojom::PresentationSessionInfoPtr session, |
486 blink::mojom::PresentationConnectionPtr controller_connection_ptr, | 486 blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
487 blink::mojom::PresentationConnectionRequest receiver_connection_request) { | 487 blink::mojom::PresentationConnectionRequest receiver_connection_request) { |
488 DVLOG(2) << "SetPresentationConnection"; | 488 DVLOG(2) << "SetPresentationConnection"; |
489 | 489 |
490 if (!controller_delegate_) | 490 if (!controller_delegate_) |
491 return; | 491 return; |
492 | 492 |
493 PresentationSessionInfo session_info(session.To<PresentationSessionInfo>()); | 493 PresentationSessionInfo session_info(session.To<PresentationSessionInfo>()); |
494 controller_delegate_->ConnectToOffscreenPresentation( | 494 controller_delegate_->ConnectToPresentation( |
495 render_process_id_, render_frame_id_, session_info, | 495 render_process_id_, render_frame_id_, session_info, |
496 std::move(controller_connection_ptr), | 496 std::move(controller_connection_ptr), |
497 std::move(receiver_connection_request)); | 497 std::move(receiver_connection_request)); |
498 } | 498 } |
499 | 499 |
500 void PresentationServiceImpl::OnConnectionMessages( | 500 void PresentationServiceImpl::OnConnectionMessages( |
501 const PresentationSessionInfo& session, | 501 const PresentationSessionInfo& session, |
502 const std::vector<std::unique_ptr<PresentationConnectionMessage>>& messages, | 502 const std::vector<std::unique_ptr<PresentationConnectionMessage>>& messages, |
503 bool pass_ownership) { | 503 bool pass_ownership) { |
504 DCHECK(client_); | 504 DCHECK(client_); |
505 | 505 |
506 DVLOG(2) << "OnConnectionMessages" | 506 DVLOG(2) << "OnConnectionMessages" |
507 << " [id]: " << session.presentation_id; | 507 << " [presentation_id]: " << session.presentation_id; |
508 std::vector<blink::mojom::ConnectionMessagePtr> mojo_messages( | 508 std::vector<blink::mojom::ConnectionMessagePtr> mojo_messages( |
509 messages.size()); | 509 messages.size()); |
510 std::transform( | 510 std::transform( |
511 messages.begin(), messages.end(), mojo_messages.begin(), | 511 messages.begin(), messages.end(), mojo_messages.begin(), |
512 [pass_ownership]( | 512 [pass_ownership]( |
513 const std::unique_ptr<PresentationConnectionMessage>& message) { | 513 const std::unique_ptr<PresentationConnectionMessage>& message) { |
514 return ToMojoConnectionMessage(message.get(), pass_ownership); | 514 return ToMojoConnectionMessage(message.get(), pass_ownership); |
515 }); | 515 }); |
516 | 516 |
517 client_->OnConnectionMessagesReceived( | 517 client_->OnConnectionMessagesReceived( |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 658 |
659 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( | 659 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( |
660 blink::mojom::PresentationSessionInfoPtr session, | 660 blink::mojom::PresentationSessionInfoPtr session, |
661 blink::mojom::PresentationErrorPtr error) { | 661 blink::mojom::PresentationErrorPtr error) { |
662 DCHECK(!callback_.is_null()); | 662 DCHECK(!callback_.is_null()); |
663 callback_.Run(std::move(session), std::move(error)); | 663 callback_.Run(std::move(session), std::move(error)); |
664 callback_.Reset(); | 664 callback_.Reset(); |
665 } | 665 } |
666 | 666 |
667 } // namespace content | 667 } // namespace content |
OLD | NEW |