| 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } else { | 724 } else { |
| 725 // TODO(crbug.com/627655): Handle multiple URLs. | 725 // TODO(crbug.com/627655): Handle multiple URLs. |
| 726 frame_manager_->SetDefaultPresentationUrl( | 726 frame_manager_->SetDefaultPresentationUrl( |
| 727 render_frame_host_id, default_presentation_urls[0], callback); | 727 render_frame_host_id, default_presentation_urls[0], callback); |
| 728 } | 728 } |
| 729 } | 729 } |
| 730 | 730 |
| 731 void PresentationServiceDelegateImpl::OnJoinRouteResponse( | 731 void PresentationServiceDelegateImpl::OnJoinRouteResponse( |
| 732 int render_process_id, | 732 int render_process_id, |
| 733 int render_frame_id, | 733 int render_frame_id, |
| 734 const content::PresentationSessionInfo& session, | 734 const GURL& presentation_url, |
| 735 const std::string& presentation_id, |
| 735 const content::PresentationSessionStartedCallback& success_cb, | 736 const content::PresentationSessionStartedCallback& success_cb, |
| 736 const content::PresentationSessionErrorCallback& error_cb, | 737 const content::PresentationSessionErrorCallback& error_cb, |
| 737 const RouteRequestResult& result) { | 738 const RouteRequestResult& result) { |
| 738 if (!result.route()) { | 739 if (!result.route()) { |
| 739 error_cb.Run(content::PresentationError( | 740 error_cb.Run(content::PresentationError( |
| 740 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, result.error())); | 741 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, result.error())); |
| 741 } else { | 742 } else { |
| 742 DVLOG(1) << "OnJoinRouteResponse: " | 743 DVLOG(1) << "OnJoinRouteResponse: " |
| 743 << "route_id: " << result.route()->media_route_id() | 744 << "route_id: " << result.route()->media_route_id() |
| 744 << ", presentation URL: " << session.presentation_url | 745 << ", presentation URL: " << presentation_url |
| 745 << ", presentation ID: " << session.presentation_id; | 746 << ", presentation ID: " << presentation_id; |
| 746 DCHECK_EQ(session.presentation_id, result.presentation_id()); | 747 DCHECK_EQ(presentation_id, result.presentation_id()); |
| 748 content::PresentationSessionInfo session(presentation_url, |
| 749 result.presentation_id()); |
| 747 frame_manager_->OnPresentationSessionStarted( | 750 frame_manager_->OnPresentationSessionStarted( |
| 748 RenderFrameHostId(render_process_id, render_frame_id), session, | 751 RenderFrameHostId(render_process_id, render_frame_id), session, |
| 749 result.route()->media_route_id()); | 752 result.route()->media_route_id()); |
| 750 success_cb.Run(session); | 753 success_cb.Run(session); |
| 751 } | 754 } |
| 752 } | 755 } |
| 753 | 756 |
| 754 void PresentationServiceDelegateImpl::OnStartSessionSucceeded( | 757 void PresentationServiceDelegateImpl::OnStartSessionSucceeded( |
| 755 int render_process_id, | 758 int render_process_id, |
| 756 int render_frame_id, | 759 int render_frame_id, |
| 757 const content::PresentationSessionStartedCallback& success_cb, | 760 const content::PresentationSessionStartedCallback& success_cb, |
| 758 const content::PresentationSessionInfo& new_session, | 761 const content::PresentationSessionInfo& new_session, |
| 759 const MediaRoute::Id& route_id) { | 762 const MediaRoute& route) { |
| 763 const MediaRoute::Id& route_id = route.media_route_id(); |
| 760 DVLOG(1) << "OnStartSessionSucceeded: " | 764 DVLOG(1) << "OnStartSessionSucceeded: " |
| 761 << "route_id: " << route_id | 765 << "route_id: " << route_id |
| 762 << ", presentation URL: " << new_session.presentation_url | 766 << ", presentation URL: " << new_session.presentation_url |
| 763 << ", presentation ID: " << new_session.presentation_id; | 767 << ", presentation ID: " << new_session.presentation_id; |
| 764 frame_manager_->OnPresentationSessionStarted( | 768 frame_manager_->OnPresentationSessionStarted( |
| 765 RenderFrameHostId(render_process_id, render_frame_id), new_session, | 769 RenderFrameHostId(render_process_id, render_frame_id), new_session, |
| 766 route_id); | 770 route_id); |
| 767 success_cb.Run(new_session); | 771 success_cb.Run(new_session); |
| 768 } | 772 } |
| 769 | 773 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 if (presentation_urls.empty()) { | 821 if (presentation_urls.empty()) { |
| 818 error_cb.Run(content::PresentationError( | 822 error_cb.Run(content::PresentationError( |
| 819 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, | 823 content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, |
| 820 "Invalid presentation arguments.")); | 824 "Invalid presentation arguments.")); |
| 821 } | 825 } |
| 822 | 826 |
| 823 // TODO(crbug.com/627655): Handle multiple URLs. | 827 // TODO(crbug.com/627655): Handle multiple URLs. |
| 824 const GURL& presentation_url = presentation_urls[0]; | 828 const GURL& presentation_url = presentation_urls[0]; |
| 825 bool incognito = web_contents_->GetBrowserContext()->IsOffTheRecord(); | 829 bool incognito = web_contents_->GetBrowserContext()->IsOffTheRecord(); |
| 826 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 830 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 827 route_response_callbacks.push_back(base::Bind( | 831 route_response_callbacks.push_back( |
| 828 &PresentationServiceDelegateImpl::OnJoinRouteResponse, | 832 base::Bind(&PresentationServiceDelegateImpl::OnJoinRouteResponse, |
| 829 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, | 833 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, |
| 830 content::PresentationSessionInfo(presentation_url, presentation_id), | 834 presentation_url, presentation_id, success_cb, error_cb)); |
| 831 success_cb, error_cb)); | |
| 832 router_->JoinRoute( | 835 router_->JoinRoute( |
| 833 MediaSourceForPresentationUrl(presentation_url).id(), presentation_id, | 836 MediaSourceForPresentationUrl(presentation_url).id(), presentation_id, |
| 834 GetLastCommittedURLForFrame( | 837 GetLastCommittedURLForFrame( |
| 835 RenderFrameHostId(render_process_id, render_frame_id)) | 838 RenderFrameHostId(render_process_id, render_frame_id)) |
| 836 .GetOrigin(), | 839 .GetOrigin(), |
| 837 web_contents_, route_response_callbacks, base::TimeDelta(), incognito); | 840 web_contents_, route_response_callbacks, base::TimeDelta(), incognito); |
| 838 } | 841 } |
| 839 | 842 |
| 840 void PresentationServiceDelegateImpl::CloseConnection( | 843 void PresentationServiceDelegateImpl::CloseConnection( |
| 841 int render_process_id, | 844 int render_process_id, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( | 964 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
| 962 int render_process_id, | 965 int render_process_id, |
| 963 int render_frame_id, | 966 int render_frame_id, |
| 964 const MediaSource::Id& source_id) const { | 967 const MediaSource::Id& source_id) const { |
| 965 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 968 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| 966 return frame_manager_->HasScreenAvailabilityListenerForTest( | 969 return frame_manager_->HasScreenAvailabilityListenerForTest( |
| 967 render_frame_host_id, source_id); | 970 render_frame_host_id, source_id); |
| 968 } | 971 } |
| 969 | 972 |
| 970 } // namespace media_router | 973 } // namespace media_router |
| OLD | NEW |