| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SINK_SERVICE_H_ | 5 #ifndef CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | 6 #define CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "chrome/common/media_router/discovery/media_sink_internal.h" |
| 12 #include "chrome/common/media_router/media_sink.h" | 13 #include "chrome/common/media_router/media_sink.h" |
| 13 | 14 |
| 14 namespace media_router { | 15 namespace media_router { |
| 15 | 16 |
| 16 class MediaSinksObserver; | |
| 17 | |
| 18 // A service which can be used to start background discovery and resolution of | 17 // A service which can be used to start background discovery and resolution of |
| 19 // MediaSinks. Often these are remote devices, like Chromecast. In addition, the | 18 // MediaSinks. Often these are remote devices, like Chromecast. In addition, the |
| 20 // service is capable of answering MediaSink queries using the sinks that it | 19 // service is capable of answering MediaSink queries using the sinks that it |
| 21 // generated. | 20 // generated. |
| 22 // This class is not thread safe. All methods must be called from the IO thread. | 21 // This class is not thread safe. All methods must be called from the IO thread. |
| 23 class MediaSinkService { | 22 class MediaSinkService { |
| 24 public: | 23 public: |
| 25 // Callback to be invoked when this class finishes sink discovering. | 24 // Callback to be invoked when this class finishes sink discovering. |
| 26 // Arg 0: Sinks discovered and resolved by the service. | 25 // Arg 0: Sinks discovered and resolved by the service. |
| 27 using OnSinksDiscoveredCallback = | 26 using OnSinksDiscoveredCallback = |
| 28 base::Callback<void(const std::vector<MediaSink>&)>; | 27 base::Callback<void(const std::vector<MediaSinkInternal>&)>; |
| 29 | 28 |
| 30 explicit MediaSinkService( | 29 explicit MediaSinkService( |
| 31 const OnSinksDiscoveredCallback& sinks_discovered_callback); | 30 const OnSinksDiscoveredCallback& sink_discovery_callback); |
| 32 | 31 |
| 33 virtual ~MediaSinkService(); | 32 virtual ~MediaSinkService(); |
| 34 | 33 |
| 35 // Starts sink discovery. No-ops if already started. | 34 // Starts sink discovery. No-ops if already started. |
| 36 // Sinks discovered and resolved are continuously passed to | 35 // Sinks discovered and resolved are continuously passed to |
| 37 // |callback|. | 36 // |callback|. |
| 38 virtual void Start() = 0; | 37 virtual void Start() = 0; |
| 39 | 38 |
| 40 // Adds a sink query to observe for MediaSink updates. | |
| 41 // Multiple observers can be added for a given MediaSource. | |
| 42 // Start() must be called first. This class does not take | |
| 43 // ownership of |observer|. | |
| 44 virtual void AddSinkQuery(MediaSinksObserver* observer) = 0; | |
| 45 | |
| 46 // Removes a sink query and stops observing MediaSink updates. No-op if | |
| 47 // |observer| is not registered with this class. | |
| 48 virtual void RemoveSinkQuery(MediaSinksObserver* observer) = 0; | |
| 49 | |
| 50 protected: | 39 protected: |
| 51 OnSinksDiscoveredCallback sinks_discovered_callback_; | 40 OnSinksDiscoveredCallback sink_discovery_callback_; |
| 52 | 41 |
| 53 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); | 42 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); |
| 54 }; | 43 }; |
| 55 | 44 |
| 56 } // namespace media_router | 45 } // namespace media_router |
| 57 | 46 |
| 58 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | 47 #endif // CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
| OLD | NEW |