| 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/presentation_session_state_observer.h" | 5 #include "chrome/browser/media/router/presentation_session_state_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/media/router/media_router.h" | 7 #include "chrome/browser/media/router/media_router.h" |
| 8 | 8 |
| 9 namespace media_router { | 9 namespace media_router { |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 tracked_route_ids_.push_back(route_id); | 27 tracked_route_ids_.push_back(route_id); |
| 28 InvokeCallback(route_id, content::PRESENTATION_SESSION_STATE_CONNECTED); | 28 InvokeCallback(route_id, content::PRESENTATION_SESSION_STATE_CONNECTED); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void PresentationSessionStateObserver::Reset() { | 31 void PresentationSessionStateObserver::Reset() { |
| 32 tracked_route_ids_.clear(); | 32 tracked_route_ids_.clear(); |
| 33 previous_route_ids_.clear(); | 33 previous_route_ids_.clear(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void PresentationSessionStateObserver::OnRoutesUpdated( | 36 void PresentationSessionStateObserver::OnRoutesUpdated( |
| 37 const std::vector<MediaRoute>& routes) { | 37 const std::vector<MediaRoute>& routes, |
| 38 const std::vector<MediaRoute::Id>& joinable_route_ids) { |
| 38 std::vector<MediaRoute::Id> current_route_ids_; | 39 std::vector<MediaRoute::Id> current_route_ids_; |
| 39 current_route_ids_.reserve(routes.size()); | 40 current_route_ids_.reserve(routes.size()); |
| 40 for (const MediaRoute& route : routes) | 41 for (const MediaRoute& route : routes) |
| 41 current_route_ids_.push_back(route.media_route_id()); | 42 current_route_ids_.push_back(route.media_route_id()); |
| 42 | 43 |
| 43 for (auto it = tracked_route_ids_.begin(); it != tracked_route_ids_.end(); | 44 for (auto it = tracked_route_ids_.begin(); it != tracked_route_ids_.end(); |
| 44 /*no-op*/) { | 45 /*no-op*/) { |
| 45 const MediaRoute::Id& route_id = *it; | 46 const MediaRoute::Id& route_id = *it; |
| 46 if (ContainsValue(previous_route_ids_, route_id) && | 47 if (ContainsValue(previous_route_ids_, route_id) && |
| 47 !ContainsValue(current_route_ids_, route_id)) { | 48 !ContainsValue(current_route_ids_, route_id)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 void PresentationSessionStateObserver::InvokeCallback( | 59 void PresentationSessionStateObserver::InvokeCallback( |
| 59 const MediaRoute::Id& route_id, | 60 const MediaRoute::Id& route_id, |
| 60 content::PresentationSessionState new_state) { | 61 content::PresentationSessionState new_state) { |
| 61 const content::PresentationSessionInfo* session_info = | 62 const content::PresentationSessionInfo* session_info = |
| 62 route_id_to_presentation_->Get(route_id); | 63 route_id_to_presentation_->Get(route_id); |
| 63 if (session_info) | 64 if (session_info) |
| 64 state_changed_callback_.Run(*session_info, new_state); | 65 state_changed_callback_.Run(*session_info, new_state); |
| 65 } | 66 } |
| 66 | 67 |
| 67 } // namespace media_router | 68 } // namespace media_router |
| OLD | NEW |