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)) { | 733 if (!IsKnownEnumValue(availability)) { |
734 DLOG(WARNING) << "Unknown SinkAvailability value " << availability; | 734 DLOG(WARNING) << "Unknown SinkAvailability value " << availability; |
735 return; | 735 return; |
736 } | 736 } |
737 | 737 |
738 if (availability_ == availability) | 738 if (availability_ == availability) |
739 return; | 739 return; |
740 | 740 |
741 availability_ = availability; | 741 availability_ = availability; |
742 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { | 742 if (availability_ == interfaces::MediaRouter::SinkAvailability::UNAVAILABLE) { |
743 // Sinks are no longer available. MRPM has already removed all sink queries. | 743 // Sinks are no longer available. MRPM has already removed all sink queries. |
744 for (auto& source_and_query : sinks_queries_) { | 744 for (auto& source_and_query : sinks_queries_) { |
745 auto* query = source_and_query.second; | 745 auto* query = source_and_query.second; |
746 query->is_active = false; | 746 query->is_active = false; |
747 query->has_cached_result = false; | 747 query->has_cached_result = false; |
748 query->cached_sink_list.clear(); | 748 query->cached_sink_list.clear(); |
749 } | 749 } |
750 } else { | 750 } else { |
751 // Sinks are now available. Tell MRPM to start all sink queries again. | 751 // Sinks are now available. Tell MRPM to start all sink queries again. |
752 for (const auto& source_and_query : sinks_queries_) { | 752 for (const auto& source_and_query : sinks_queries_) { |
753 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStartObservingMediaSinks, | 753 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStartObservingMediaSinks, |
754 base::Unretained(this), source_and_query.first)); | 754 base::Unretained(this), source_and_query.first)); |
755 } | 755 } |
756 } | 756 } |
757 } | 757 } |
758 | 758 |
759 void MediaRouterMojoImpl::OnPresentationConnectionStateChanged( | 759 void MediaRouterMojoImpl::OnPresentationConnectionStateChanged( |
760 const mojo::String& route_id, | 760 const mojo::String& route_id, |
761 interfaces::MediaRouter::PresentationConnectionState state) { | 761 interfaces::MediaRouter::PresentationConnectionState state) { |
762 if (!interfaces::MediaRouter::PresentationConnectionState_IsValidValue( | 762 if (!IsKnownEnumValue(state)) { |
763 state)) { | |
764 DLOG(WARNING) << "Unknown PresentationConnectionState value " << state; | 763 DLOG(WARNING) << "Unknown PresentationConnectionState value " << state; |
765 return; | 764 return; |
766 } | 765 } |
767 | 766 |
768 NotifyPresentationConnectionStateChange( | 767 NotifyPresentationConnectionStateChange( |
769 route_id, mojo::PresentationConnectionStateFromMojo(state)); | 768 route_id, mojo::PresentationConnectionStateFromMojo(state)); |
770 } | 769 } |
771 | 770 |
772 bool MediaRouterMojoImpl::HasLocalDisplayRoute() const { | 771 bool MediaRouterMojoImpl::HasLocalDisplayRoute() const { |
773 return has_local_display_route_; | 772 return has_local_display_route_; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT) | 932 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT) |
934 current_wake_reason_ = reason; | 933 current_wake_reason_ = reason; |
935 } | 934 } |
936 | 935 |
937 void MediaRouterMojoImpl::ClearWakeReason() { | 936 void MediaRouterMojoImpl::ClearWakeReason() { |
938 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT); | 937 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT); |
939 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; | 938 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; |
940 } | 939 } |
941 | 940 |
942 } // namespace media_router | 941 } // namespace media_router |
OLD | NEW |