| 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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTES_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTES_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTES_OBSERVER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTES_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/media/router/media_route.h" | 11 #include "chrome/browser/media/router/media_route.h" |
| 12 | 12 |
| 13 namespace media_router { | 13 namespace media_router { |
| 14 | 14 |
| 15 class MediaRouter; | 15 class MediaRouter; |
| 16 | 16 |
| 17 // Base class for observing when the set of MediaRoutes and their associated | 17 // Base class for observing when the set of MediaRoutes and their associated |
| 18 // MediaSinks have been updated. | 18 // MediaSinks have been updated. When an object is instantiated with a |
| 19 // |source_id|, the observer expects that |routes| reported by |
| 20 // |OnRoutesUpdated| that match the route IDs contained in the |
| 21 // |joinable_route_ids| can be connected joined by the source. If no |
| 22 // |source_id| is supplied, then the idea of joinable routes no longer applies. |
| 19 class MediaRoutesObserver { | 23 class MediaRoutesObserver { |
| 20 public: | 24 public: |
| 21 explicit MediaRoutesObserver(MediaRouter* router); | 25 explicit MediaRoutesObserver(MediaRouter* router) : |
| 26 MediaRoutesObserver(router, MediaSource::Id()) {} |
| 27 MediaRoutesObserver(MediaRouter* router, const MediaSource::Id source_id); |
| 22 virtual ~MediaRoutesObserver(); | 28 virtual ~MediaRoutesObserver(); |
| 23 | 29 |
| 24 // Invoked when the list of routes and their associated sinks have been | 30 // Invoked when the list of routes and their associated sinks have been |
| 25 // updated. | 31 // updated with the context of the |source_id|. This will return a list of |
| 32 // |routes| and a list of |joinable_route_ids|. A route is joinable only if |
| 33 // it is joinable in the context of the |source_id|. |
| 26 // Implementations may not perform operations that modify the Media Router's | 34 // Implementations may not perform operations that modify the Media Router's |
| 27 // observer list. In particular, invoking this observer's destructor within | 35 // observer list. In particular, invoking this observer's destructor within |
| 28 // OnRoutesUpdated will result in undefined behavior. | 36 // OnRoutesUpdated will result in undefined behavior. |
| 29 virtual void OnRoutesUpdated(const std::vector<MediaRoute>& routes) {} | 37 virtual void OnRoutesUpdated( |
| 38 const std::vector<MediaRoute>& routes, |
| 39 const std::vector<MediaRoute::Id>& joinable_route_ids) {} |
| 40 |
| 41 const MediaSource::Id source_id() const { return source_id_; } |
| 30 | 42 |
| 31 private: | 43 private: |
| 32 MediaRouter* router_; | 44 MediaRouter* router_; |
| 45 const MediaSource::Id source_id_; |
| 33 | 46 |
| 34 DISALLOW_COPY_AND_ASSIGN(MediaRoutesObserver); | 47 DISALLOW_COPY_AND_ASSIGN(MediaRoutesObserver); |
| 35 }; | 48 }; |
| 36 | 49 |
| 37 } // namespace media_router | 50 } // namespace media_router |
| 38 | 51 |
| 39 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTES_OBSERVER_H_ | 52 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTES_OBSERVER_H_ |
| OLD | NEW |