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