| 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_SINKS_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_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_sink.h" | 11 #include "chrome/browser/media/router/media_sink.h" |
| 12 #include "chrome/browser/media/router/media_source.h" | 12 #include "chrome/browser/media/router/media_source.h" |
| 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace media_router { | 15 namespace media_router { |
| 15 | 16 |
| 16 class MediaRouter; | 17 class MediaRouter; |
| 17 | 18 |
| 18 // Base class for observing when the collection of sinks compatible with | 19 // Base class for observing when the collection of sinks compatible with |
| 19 // a MediaSource has been updated. | 20 // a MediaSource has been updated. |
| 20 // A MediaSinksObserver implementation can be registered to MediaRouter to | 21 // A MediaSinksObserver implementation can be registered to MediaRouter to |
| 21 // receive results. It can then interpret / process the results accordingly. | 22 // receive results. It can then interpret / process the results accordingly. |
| 22 // More documentation can be found at | 23 // More documentation can be found at |
| 23 // docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78 | 24 // docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78 |
| 24 class MediaSinksObserver { | 25 class MediaSinksObserver { |
| 25 public: | 26 public: |
| 26 // Constructs an observer that will observe for sinks compatible | 27 // Constructs an observer that will observe for sinks compatible |
| 27 // with |source|. | 28 // with |source|. |
| 28 MediaSinksObserver(MediaRouter* router, const MediaSource& source); | 29 MediaSinksObserver(MediaRouter* router, |
| 30 const MediaSource& source); |
| 29 virtual ~MediaSinksObserver(); | 31 virtual ~MediaSinksObserver(); |
| 30 | 32 |
| 31 // Registers with MediaRouter to start observing. Must be called before the | 33 // Registers with MediaRouter to start observing. Must be called before the |
| 32 // observer will start receiving updates. Returns |true| if the observer is | 34 // observer will start receiving updates. Returns |true| if the observer is |
| 33 // initialized. This method is no-op if the observer is already initialized. | 35 // initialized. This method is no-op if the observer is already initialized. |
| 34 bool Init(); | 36 bool Init(); |
| 35 | 37 |
| 36 // This function is invoked when the list of sinks compatible | 38 // This function is invoked when the list of sinks compatible |
| 37 // with |source_| has been updated. | 39 // with |source_| has been updated. |
| 38 // Implementations may not perform operations that modify the Media Router's | 40 // Implementations may not perform operations that modify the Media Router's |
| 39 // observer list. In particular, invoking this observer's destructor within | 41 // observer list. In particular, invoking this observer's destructor within |
| 40 // OnSinksReceived will result in undefined behavior. | 42 // OnSinksReceived will result in undefined behavior. |
| 41 virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) {} | 43 virtual void OnSinksReceived(const MediaSource& source, |
| 44 const std::vector<MediaSink>& sinks) {} |
| 42 | 45 |
| 43 const MediaSource& source() const { return source_; } | 46 const MediaSource& source() const { return source_; } |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 const MediaSource source_; | 49 const MediaSource source_; |
| 47 MediaRouter* router_; | 50 MediaRouter* router_; |
| 48 bool initialized_; | 51 bool initialized_; |
| 49 | 52 |
| 50 DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver); | 53 DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver); |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 } // namespace media_router | 56 } // namespace media_router |
| 54 | 57 |
| 55 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ | 58 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ |
| OLD | NEW |