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_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ | 5 #ifndef CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
6 #define CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_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/discovery/media_sink_internal.h" |
13 #include "chrome/common/media_router/media_sink.h" | 13 #include "chrome/common/media_router/media_sink.h" |
14 | 14 |
15 namespace media_router { | 15 namespace media_router { |
16 | 16 |
17 // 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 |
18 // MediaSinks. Often these are remote devices, like Chromecast. In addition, the | 18 // MediaSinks. Often these are remote devices, like Chromecast. In addition, the |
19 // 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 |
20 // generated. | 20 // generated. |
21 // This class is not thread safe. All methods must be called from the UI thread. | 21 // This class is not thread safe. All methods must be called from the UI thread. |
22 class MediaSinkService { | 22 class MediaSinkService { |
23 public: | 23 public: |
24 // Callback to be invoked when this class finishes sink discovering. | 24 // Callback to be invoked when this class finishes sink discovering. |
25 // Arg 0: Sinks discovered and resolved by the service. | 25 // Arg 0: Sinks discovered and resolved by the service. |
26 using OnSinksDiscoveredCallback = | 26 using OnSinksDiscoveredCallback = |
27 base::Callback<void(const std::vector<MediaSinkInternal>&)>; | 27 base::Callback<void(std::vector<MediaSinkInternal>)>; |
28 | 28 |
29 explicit MediaSinkService( | 29 explicit MediaSinkService( |
30 const OnSinksDiscoveredCallback& sink_discovery_callback); | 30 const OnSinksDiscoveredCallback& sink_discovery_callback); |
31 | 31 |
32 virtual ~MediaSinkService(); | 32 virtual ~MediaSinkService(); |
33 | 33 |
34 // Starts sink discovery. No-ops if already started. | 34 // Starts sink discovery. No-ops if already started. |
35 // Sinks discovered and resolved are continuously passed to | 35 // Sinks discovered and resolved are continuously passed to |
36 // |callback|. | 36 // |callback|. |
37 virtual void Start() = 0; | 37 virtual void Start() = 0; |
38 | 38 |
39 // Stops sink discovery. No-ops if already stopped. | 39 // Stops sink discovery. No-ops if already stopped. |
40 virtual void Stop() = 0; | 40 virtual void Stop() = 0; |
41 | 41 |
42 protected: | 42 protected: |
43 OnSinksDiscoveredCallback sink_discovery_callback_; | 43 OnSinksDiscoveredCallback sink_discovery_callback_; |
44 | 44 |
45 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); | 45 DISALLOW_COPY_AND_ASSIGN(MediaSinkService); |
46 }; | 46 }; |
47 | 47 |
48 } // namespace media_router | 48 } // namespace media_router |
49 | 49 |
50 #endif // CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ | 50 #endif // CHROME_COMMON_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_H_ |
OLD | NEW |