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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 render_frame_host->GetRoutingID() == render_frame_id_; | 349 render_frame_host->GetRoutingID() == render_frame_id_; |
350 } | 350 } |
351 | 351 |
352 PresentationServiceDelegate* | 352 PresentationServiceDelegate* |
353 PresentationServiceImpl::GetPresentationServiceDelegate() { | 353 PresentationServiceImpl::GetPresentationServiceDelegate() { |
354 return receiver_delegate_ | 354 return receiver_delegate_ |
355 ? static_cast<PresentationServiceDelegate*>(receiver_delegate_) | 355 ? static_cast<PresentationServiceDelegate*>(receiver_delegate_) |
356 : static_cast<PresentationServiceDelegate*>(controller_delegate_); | 356 : static_cast<PresentationServiceDelegate*>(controller_delegate_); |
357 } | 357 } |
358 | 358 |
359 void PresentationServiceImpl::ListenForConnectionMessages( | |
360 const PresentationInfo& presentation_info) { | |
361 DVLOG(2) << "ListenForConnectionMessages"; | |
362 if (!controller_delegate_) | |
363 return; | |
364 | |
365 controller_delegate_->ListenForConnectionMessages( | |
366 render_process_id_, render_frame_id_, presentation_info, | |
367 base::Bind(&PresentationServiceImpl::OnConnectionMessages, | |
368 weak_factory_.GetWeakPtr(), presentation_info)); | |
369 } | |
370 | |
371 void PresentationServiceImpl::SetPresentationConnection( | 359 void PresentationServiceImpl::SetPresentationConnection( |
372 const PresentationInfo& presentation_info, | 360 const PresentationInfo& presentation_info, |
373 blink::mojom::PresentationConnectionPtr controller_connection_ptr, | 361 blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
374 blink::mojom::PresentationConnectionRequest receiver_connection_request) { | 362 blink::mojom::PresentationConnectionRequest receiver_connection_request) { |
375 DVLOG(2) << "SetPresentationConnection"; | 363 DVLOG(2) << "SetPresentationConnection"; |
376 | 364 |
377 if (!controller_delegate_) | 365 if (!controller_delegate_) |
378 return; | 366 return; |
379 | 367 |
380 controller_delegate_->ConnectToPresentation( | 368 controller_delegate_->ConnectToPresentation( |
381 render_process_id_, render_frame_id_, presentation_info, | 369 render_process_id_, render_frame_id_, presentation_info, |
382 std::move(controller_connection_ptr), | 370 std::move(controller_connection_ptr), |
383 std::move(receiver_connection_request)); | 371 std::move(receiver_connection_request)); |
384 } | 372 } |
385 | 373 |
386 void PresentationServiceImpl::OnConnectionMessages( | |
387 const PresentationInfo& presentation_info, | |
388 std::vector<PresentationConnectionMessage> messages) { | |
389 DCHECK(client_); | |
390 | |
391 DVLOG(2) << "OnConnectionMessages [id]: " | |
392 << presentation_info.presentation_id; | |
393 client_->OnConnectionMessagesReceived(presentation_info, std::move(messages)); | |
394 } | |
395 | |
396 void PresentationServiceImpl::OnReceiverConnectionAvailable( | 374 void PresentationServiceImpl::OnReceiverConnectionAvailable( |
397 const content::PresentationInfo& presentation_info, | 375 const content::PresentationInfo& presentation_info, |
398 PresentationConnectionPtr controller_connection_ptr, | 376 PresentationConnectionPtr controller_connection_ptr, |
399 PresentationConnectionRequest receiver_connection_request) { | 377 PresentationConnectionRequest receiver_connection_request) { |
400 DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable"; | 378 DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable"; |
401 | 379 |
402 client_->OnReceiverConnectionAvailable( | 380 client_->OnReceiverConnectionAvailable( |
403 presentation_info, std::move(controller_connection_ptr), | 381 presentation_info, std::move(controller_connection_ptr), |
404 std::move(receiver_connection_request)); | 382 std::move(receiver_connection_request)); |
405 } | 383 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 } | 496 } |
519 | 497 |
520 void PresentationServiceImpl::NewPresentationCallbackWrapper::Run( | 498 void PresentationServiceImpl::NewPresentationCallbackWrapper::Run( |
521 const base::Optional<PresentationInfo>& presentation_info, | 499 const base::Optional<PresentationInfo>& presentation_info, |
522 const base::Optional<PresentationError>& error) { | 500 const base::Optional<PresentationError>& error) { |
523 DCHECK(!callback_.is_null()); | 501 DCHECK(!callback_.is_null()); |
524 std::move(callback_).Run(presentation_info, error); | 502 std::move(callback_).Run(presentation_info, error); |
525 } | 503 } |
526 | 504 |
527 } // namespace content | 505 } // namespace content |
OLD | NEW |