| 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 MediaSource::Id source_id, |
| 38 const std::vector<MediaRoute>& routes, |
| 39 const std::vector<MediaRoute>& joinable_routes) { |
| 40 |
| 41 if (source_id.compare(this->source_id()) != -1) |
| 42 return; |
| 43 |
| 38 std::vector<MediaRoute::Id> current_route_ids_; | 44 std::vector<MediaRoute::Id> current_route_ids_; |
| 39 current_route_ids_.reserve(routes.size()); | 45 current_route_ids_.reserve(routes.size()); |
| 40 for (const MediaRoute& route : routes) | 46 for (const MediaRoute& route : routes) |
| 41 current_route_ids_.push_back(route.media_route_id()); | 47 current_route_ids_.push_back(route.media_route_id()); |
| 42 | 48 |
| 43 for (auto it = tracked_route_ids_.begin(); it != tracked_route_ids_.end(); | 49 for (auto it = tracked_route_ids_.begin(); it != tracked_route_ids_.end(); |
| 44 /*no-op*/) { | 50 /*no-op*/) { |
| 45 const MediaRoute::Id& route_id = *it; | 51 const MediaRoute::Id& route_id = *it; |
| 46 if (ContainsValue(previous_route_ids_, route_id) && | 52 if (ContainsValue(previous_route_ids_, route_id) && |
| 47 !ContainsValue(current_route_ids_, route_id)) { | 53 !ContainsValue(current_route_ids_, route_id)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 void PresentationSessionStateObserver::InvokeCallback( | 64 void PresentationSessionStateObserver::InvokeCallback( |
| 59 const MediaRoute::Id& route_id, | 65 const MediaRoute::Id& route_id, |
| 60 content::PresentationSessionState new_state) { | 66 content::PresentationSessionState new_state) { |
| 61 const content::PresentationSessionInfo* session_info = | 67 const content::PresentationSessionInfo* session_info = |
| 62 route_id_to_presentation_->Get(route_id); | 68 route_id_to_presentation_->Get(route_id); |
| 63 if (session_info) | 69 if (session_info) |
| 64 state_changed_callback_.Run(*session_info, new_state); | 70 state_changed_callback_.Run(*session_info, new_state); |
| 65 } | 71 } |
| 66 | 72 |
| 67 } // namespace media_router | 73 } // namespace media_router |
| OLD | NEW |