| 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/mojo/media_router_mojo_impl.h" | 5 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 media_route_provider_->ConnectRouteByRouteId( | 679 media_route_provider_->ConnectRouteByRouteId( |
| 680 source_id, route_id, presentation_id, origin, tab_id, | 680 source_id, route_id, presentation_id, origin, tab_id, |
| 681 timeout > base::TimeDelta() ? timeout.InMilliseconds() : 0, | 681 timeout > base::TimeDelta() ? timeout.InMilliseconds() : 0, |
| 682 off_the_record, base::Bind(&MediaRouterMojoImpl::RouteResponseReceived, | 682 off_the_record, base::Bind(&MediaRouterMojoImpl::RouteResponseReceived, |
| 683 base::Unretained(this), presentation_id, | 683 base::Unretained(this), presentation_id, |
| 684 off_the_record, callbacks)); | 684 off_the_record, callbacks)); |
| 685 } | 685 } |
| 686 | 686 |
| 687 void MediaRouterMojoImpl::DoTerminateRoute(const MediaRoute::Id& route_id) { | 687 void MediaRouterMojoImpl::DoTerminateRoute(const MediaRoute::Id& route_id) { |
| 688 DVLOG_WITH_INSTANCE(1) << "DoTerminateRoute " << route_id; | 688 DVLOG_WITH_INSTANCE(1) << "DoTerminateRoute " << route_id; |
| 689 media_route_provider_->TerminateRoute(route_id); | 689 media_route_provider_->TerminateRoute( |
| 690 route_id, |
| 691 base::Bind(&MediaRouterMojoImpl::OnTerminateRouteResult, |
| 692 base::Unretained(this), route_id)); |
| 690 } | 693 } |
| 691 | 694 |
| 692 void MediaRouterMojoImpl::DoDetachRoute(const MediaRoute::Id& route_id) { | 695 void MediaRouterMojoImpl::DoDetachRoute(const MediaRoute::Id& route_id) { |
| 693 DVLOG_WITH_INSTANCE(1) << "DoDetachRoute " << route_id; | 696 DVLOG_WITH_INSTANCE(1) << "DoDetachRoute " << route_id; |
| 694 media_route_provider_->DetachRoute(route_id); | 697 media_route_provider_->DetachRoute(route_id); |
| 695 } | 698 } |
| 696 | 699 |
| 697 void MediaRouterMojoImpl::DoSendSessionMessage( | 700 void MediaRouterMojoImpl::DoSendSessionMessage( |
| 698 const MediaRoute::Id& route_id, | 701 const MediaRoute::Id& route_id, |
| 699 const std::string& message, | 702 const std::string& message, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 802 |
| 800 void MediaRouterMojoImpl::OnPresentationConnectionClosed( | 803 void MediaRouterMojoImpl::OnPresentationConnectionClosed( |
| 801 const mojo::String& route_id, | 804 const mojo::String& route_id, |
| 802 interfaces::MediaRouter::PresentationConnectionCloseReason reason, | 805 interfaces::MediaRouter::PresentationConnectionCloseReason reason, |
| 803 const mojo::String& message) { | 806 const mojo::String& message) { |
| 804 NotifyPresentationConnectionClose( | 807 NotifyPresentationConnectionClose( |
| 805 route_id, mojo::PresentationConnectionCloseReasonFromMojo(reason), | 808 route_id, mojo::PresentationConnectionCloseReasonFromMojo(reason), |
| 806 message); | 809 message); |
| 807 } | 810 } |
| 808 | 811 |
| 812 void MediaRouterMojoImpl::OnTerminateRouteResult( |
| 813 const MediaRoute::Id& route_id, |
| 814 mojo::String error_text, |
| 815 interfaces::RouteRequestResultCode result_code) { |
| 816 if (result_code != interfaces::RouteRequestResultCode::OK) { |
| 817 LOG(WARNING) << "Failed to terminate route " << route_id << |
| 818 ": result_code = " << result_code << ", " << error_text; |
| 819 } |
| 820 MediaRouterMojoMetrics::RecordMediaRouteProviderTerminateRoute( |
| 821 mojo::RouteRequestResultCodeFromMojo(result_code)); |
| 822 } |
| 823 |
| 809 void MediaRouterMojoImpl::DoStartObservingMediaSinks( | 824 void MediaRouterMojoImpl::DoStartObservingMediaSinks( |
| 810 const MediaSource::Id& source_id) { | 825 const MediaSource::Id& source_id) { |
| 811 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; | 826 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; |
| 812 // No need to call MRPM if there are no sinks available. | 827 // No need to call MRPM if there are no sinks available. |
| 813 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) | 828 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) |
| 814 return; | 829 return; |
| 815 | 830 |
| 816 // No need to call MRPM if all observers have been removed in the meantime. | 831 // No need to call MRPM if all observers have been removed in the meantime. |
| 817 auto* sinks_query = sinks_queries_.get(source_id); | 832 auto* sinks_query = sinks_queries_.get(source_id); |
| 818 if (!sinks_query || !sinks_query->observers.might_have_observers()) | 833 if (!sinks_query || !sinks_query->observers.might_have_observers()) |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 base::Unretained(this), source_id)); | 1026 base::Unretained(this), source_id)); |
| 1012 } | 1027 } |
| 1013 | 1028 |
| 1014 void MediaRouterMojoImpl::DoUpdateMediaSinks( | 1029 void MediaRouterMojoImpl::DoUpdateMediaSinks( |
| 1015 const MediaSource::Id& source_id) { | 1030 const MediaSource::Id& source_id) { |
| 1016 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; | 1031 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; |
| 1017 media_route_provider_->UpdateMediaSinks(source_id); | 1032 media_route_provider_->UpdateMediaSinks(source_id); |
| 1018 } | 1033 } |
| 1019 | 1034 |
| 1020 } // namespace media_router | 1035 } // namespace media_router |
| OLD | NEW |