| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "chrome/common/media_router/media_sink.h" | |
| 13 | |
| 14 namespace media_router { | |
| 15 | |
| 16 class MediaSinksObserver; | |
| 17 | |
| 18 // 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 | |
| 20 // service is capable of answering MediaSink queries using the sinks that it | |
| 21 // generated. | |
| 22 // This class is not thread safe. All methods must be called from the IO thread. | |
| 23 class MediaSinkService { | |
| 24 public: | |
| 25 // Callback to be invoked when this class finishes sink discovering. | |
| 26 // Arg 0: Sinks discovered and resolved by the service. | |
| 27 using OnSinksDiscoveredCallback = | |
| 28 base::Callback<void(const std::vector<MediaSink>&)>; | |
| 29 | |
| 30 explicit MediaSinkService( | |
| 31 const OnSinksDiscoveredCallback& sinks_discovered_callback); | |
| 32 | |
| 33 virtual ~MediaSinkService(); | |
| 34 | |
| 35 // Starts sink discovery. No-ops if already started. | |
| 36 // Sinks discovered and resolved are continuously passed to | |
| 37 // |callback|. | |
| 38 virtual void Start() = 0; | |
| 39 | |
| 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: | |
| 51 OnSinksDiscoveredCallback sinks_discovered_callback_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); | |
| 54 }; | |
| 55 | |
| 56 } // namespace media_router | |
| 57 | |
| 58 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_SERVICE_H_ | |
| OLD | NEW |