| 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 media_route_provider_->ConnectRouteByRouteId( | 678 media_route_provider_->ConnectRouteByRouteId( |
| 679 source_id, route_id, presentation_id, origin, tab_id, | 679 source_id, route_id, presentation_id, origin, tab_id, |
| 680 timeout > base::TimeDelta() ? timeout.InMilliseconds() : 0, | 680 timeout > base::TimeDelta() ? timeout.InMilliseconds() : 0, |
| 681 off_the_record, base::Bind(&MediaRouterMojoImpl::RouteResponseReceived, | 681 off_the_record, base::Bind(&MediaRouterMojoImpl::RouteResponseReceived, |
| 682 base::Unretained(this), presentation_id, | 682 base::Unretained(this), presentation_id, |
| 683 off_the_record, callbacks)); | 683 off_the_record, callbacks)); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void MediaRouterMojoImpl::DoTerminateRoute(const MediaRoute::Id& route_id) { | 686 void MediaRouterMojoImpl::DoTerminateRoute(const MediaRoute::Id& route_id) { |
| 687 DVLOG_WITH_INSTANCE(1) << "DoTerminateRoute " << route_id; | 687 DVLOG_WITH_INSTANCE(1) << "DoTerminateRoute " << route_id; |
| 688 media_route_provider_->TerminateRoute(route_id); | 688 media_route_provider_->TerminateRoute( |
| 689 route_id, |
| 690 base::Bind(&MediaRouterMojoImpl::OnTerminateRouteResult, |
| 691 base::Unretained(this), route_id)); |
| 689 } | 692 } |
| 690 | 693 |
| 691 void MediaRouterMojoImpl::DoDetachRoute(const MediaRoute::Id& route_id) { | 694 void MediaRouterMojoImpl::DoDetachRoute(const MediaRoute::Id& route_id) { |
| 692 DVLOG_WITH_INSTANCE(1) << "DoDetachRoute " << route_id; | 695 DVLOG_WITH_INSTANCE(1) << "DoDetachRoute " << route_id; |
| 693 media_route_provider_->DetachRoute(route_id); | 696 media_route_provider_->DetachRoute(route_id); |
| 694 } | 697 } |
| 695 | 698 |
| 696 void MediaRouterMojoImpl::DoSendSessionMessage( | 699 void MediaRouterMojoImpl::DoSendSessionMessage( |
| 697 const MediaRoute::Id& route_id, | 700 const MediaRoute::Id& route_id, |
| 698 const std::string& message, | 701 const std::string& message, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 830 |
| 828 void MediaRouterMojoImpl::OnPresentationConnectionClosed( | 831 void MediaRouterMojoImpl::OnPresentationConnectionClosed( |
| 829 const mojo::String& route_id, | 832 const mojo::String& route_id, |
| 830 interfaces::MediaRouter::PresentationConnectionCloseReason reason, | 833 interfaces::MediaRouter::PresentationConnectionCloseReason reason, |
| 831 const mojo::String& message) { | 834 const mojo::String& message) { |
| 832 NotifyPresentationConnectionClose( | 835 NotifyPresentationConnectionClose( |
| 833 route_id, mojo::PresentationConnectionCloseReasonFromMojo(reason), | 836 route_id, mojo::PresentationConnectionCloseReasonFromMojo(reason), |
| 834 message); | 837 message); |
| 835 } | 838 } |
| 836 | 839 |
| 840 void MediaRouterMojoImpl::OnTerminateRouteResult( |
| 841 const MediaRoute::Id& route_id, |
| 842 mojo::String error_text, |
| 843 interfaces::RouteRequestResultCode result_code) { |
| 844 if (result_code != interfaces::RouteRequestResultCode::OK) { |
| 845 LOG(WARNING) << "Failed to terminate route " << route_id << |
| 846 ": result_code = " << result_code << ", " << error_text; |
| 847 } |
| 848 MediaRouterMojoMetrics::RecordMediaRouteProviderTerminateRoute( |
| 849 mojo::RouteRequestResultCodeFromMojo(result_code)); |
| 850 } |
| 851 |
| 837 void MediaRouterMojoImpl::DoStartObservingMediaSinks( | 852 void MediaRouterMojoImpl::DoStartObservingMediaSinks( |
| 838 const MediaSource::Id& source_id) { | 853 const MediaSource::Id& source_id) { |
| 839 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; | 854 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; |
| 840 // No need to call MRPM if there are no sinks available. | 855 // No need to call MRPM if there are no sinks available. |
| 841 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) | 856 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) |
| 842 return; | 857 return; |
| 843 | 858 |
| 844 // No need to call MRPM if all observers have been removed in the meantime. | 859 // No need to call MRPM if all observers have been removed in the meantime. |
| 845 auto* sinks_query = sinks_queries_.get(source_id); | 860 auto* sinks_query = sinks_queries_.get(source_id); |
| 846 if (!sinks_query || !sinks_query->observers.might_have_observers()) | 861 if (!sinks_query || !sinks_query->observers.might_have_observers()) |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 base::Unretained(this), source_id)); | 1054 base::Unretained(this), source_id)); |
| 1040 } | 1055 } |
| 1041 | 1056 |
| 1042 void MediaRouterMojoImpl::DoUpdateMediaSinks( | 1057 void MediaRouterMojoImpl::DoUpdateMediaSinks( |
| 1043 const MediaSource::Id& source_id) { | 1058 const MediaSource::Id& source_id) { |
| 1044 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; | 1059 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; |
| 1045 media_route_provider_->UpdateMediaSinks(source_id); | 1060 media_route_provider_->UpdateMediaSinks(source_id); |
| 1046 } | 1061 } |
| 1047 | 1062 |
| 1048 } // namespace media_router | 1063 } // namespace media_router |
| OLD | NEW |