| 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/media_router_mojo_impl.h" | 5 #include "chrome/browser/media/router/media_router_mojo_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 } | 723 } |
| 724 | 724 |
| 725 // Listen for more messages. | 725 // Listen for more messages. |
| 726 media_route_provider_->ListenForRouteMessages( | 726 media_route_provider_->ListenForRouteMessages( |
| 727 route_id, base::Bind(&MediaRouterMojoImpl::OnRouteMessagesReceived, | 727 route_id, base::Bind(&MediaRouterMojoImpl::OnRouteMessagesReceived, |
| 728 base::Unretained(this), route_id)); | 728 base::Unretained(this), route_id)); |
| 729 } | 729 } |
| 730 | 730 |
| 731 void MediaRouterMojoImpl::OnSinkAvailabilityUpdated( | 731 void MediaRouterMojoImpl::OnSinkAvailabilityUpdated( |
| 732 SinkAvailability availability) { | 732 SinkAvailability availability) { |
| 733 if (!interfaces::MediaRouter::SinkAvailability_IsValidValue(availability)) { | |
| 734 DLOG(WARNING) << "Unknown SinkAvailability value " << availability; | |
| 735 return; | |
| 736 } | |
| 737 | |
| 738 if (availability_ == availability) | 733 if (availability_ == availability) |
| 739 return; | 734 return; |
| 740 | 735 |
| 741 availability_ = availability; | 736 availability_ = availability; |
| 742 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { | 737 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { |
| 743 // Sinks are no longer available. MRPM has already removed all sink queries. | 738 // Sinks are no longer available. MRPM has already removed all sink queries. |
| 744 for (auto& source_and_query : sinks_queries_) { | 739 for (auto& source_and_query : sinks_queries_) { |
| 745 auto* query = source_and_query.second; | 740 auto* query = source_and_query.second; |
| 746 query->is_active = false; | 741 query->is_active = false; |
| 747 query->has_cached_result = false; | 742 query->has_cached_result = false; |
| 748 query->cached_sink_list.clear(); | 743 query->cached_sink_list.clear(); |
| 749 } | 744 } |
| 750 } else { | 745 } else { |
| 751 // Sinks are now available. Tell MRPM to start all sink queries again. | 746 // Sinks are now available. Tell MRPM to start all sink queries again. |
| 752 for (const auto& source_and_query : sinks_queries_) { | 747 for (const auto& source_and_query : sinks_queries_) { |
| 753 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStartObservingMediaSinks, | 748 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStartObservingMediaSinks, |
| 754 base::Unretained(this), source_and_query.first)); | 749 base::Unretained(this), source_and_query.first)); |
| 755 } | 750 } |
| 756 } | 751 } |
| 757 } | 752 } |
| 758 | 753 |
| 759 void MediaRouterMojoImpl::OnPresentationConnectionStateChanged( | 754 void MediaRouterMojoImpl::OnPresentationConnectionStateChanged( |
| 760 const mojo::String& route_id, | 755 const mojo::String& route_id, |
| 761 interfaces::MediaRouter::PresentationConnectionState state) { | 756 interfaces::MediaRouter::PresentationConnectionState state) { |
| 762 if (!interfaces::MediaRouter::PresentationConnectionState_IsValidValue( | |
| 763 state)) { | |
| 764 DLOG(WARNING) << "Unknown PresentationConnectionState value " << state; | |
| 765 return; | |
| 766 } | |
| 767 | |
| 768 NotifyPresentationConnectionStateChange( | 757 NotifyPresentationConnectionStateChange( |
| 769 route_id, mojo::PresentationConnectionStateFromMojo(state)); | 758 route_id, mojo::PresentationConnectionStateFromMojo(state)); |
| 770 } | 759 } |
| 771 | 760 |
| 772 bool MediaRouterMojoImpl::HasLocalDisplayRoute() const { | 761 bool MediaRouterMojoImpl::HasLocalDisplayRoute() const { |
| 773 return has_local_display_route_; | 762 return has_local_display_route_; |
| 774 } | 763 } |
| 775 | 764 |
| 776 void MediaRouterMojoImpl::DoStartObservingMediaSinks( | 765 void MediaRouterMojoImpl::DoStartObservingMediaSinks( |
| 777 const MediaSource::Id& source_id) { | 766 const MediaSource::Id& source_id) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT) | 922 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT) |
| 934 current_wake_reason_ = reason; | 923 current_wake_reason_ = reason; |
| 935 } | 924 } |
| 936 | 925 |
| 937 void MediaRouterMojoImpl::ClearWakeReason() { | 926 void MediaRouterMojoImpl::ClearWakeReason() { |
| 938 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT); | 927 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT); |
| 939 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; | 928 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; |
| 940 } | 929 } |
| 941 | 930 |
| 942 } // namespace media_router | 931 } // namespace media_router |
| OLD | NEW |