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_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_IMPL_
H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_IMPL_
H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_IMPL_
H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_IMPL_
H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "chrome/browser/media/router/discovery/dial/device_description_service.
h" | 11 #include "chrome/browser/media/router/discovery/dial/device_description_service.
h" |
12 #include "chrome/browser/media/router/discovery/dial/dial_registry.h" | 12 #include "chrome/browser/media/router/discovery/dial/dial_registry.h" |
13 #include "chrome/browser/media/router/discovery/media_sink_service_base.h" | 13 #include "chrome/browser/media/router/discovery/media_sink_service_base.h" |
14 #include "chrome/browser/media/router/media_router_metrics.h" | 14 #include "chrome/browser/media/router/media_router_metrics.h" |
15 | 15 |
16 namespace media_router { | 16 namespace media_router { |
17 | 17 |
18 class DeviceDescriptionService; | 18 class DeviceDescriptionService; |
19 class DialRegistry; | 19 class DialRegistry; |
20 | 20 |
| 21 // A delegate class registered with DialMediaSinkService to receive |
| 22 // notifications when dial sinks are added or removed from DialMediaSinkService |
| 23 class DialMediaSinkServiceDelegate |
| 24 : public base::RefCountedThreadSafe<DialMediaSinkServiceDelegate> { |
| 25 public: |
| 26 // Invoked when |sink| is added to DialMediaSinkServiceImpl instance. |
| 27 virtual void OnDialSinkAdded(const MediaSinkInternal& sink) = 0; |
| 28 |
| 29 // Invoked when dial sinks are removed from DialMediaSinkServiceImpl instance. |
| 30 virtual void OnDialSinksRemoved() = 0; |
| 31 |
| 32 protected: |
| 33 virtual ~DialMediaSinkServiceDelegate() {} |
| 34 |
| 35 private: |
| 36 friend class base::RefCountedThreadSafe<DialMediaSinkServiceDelegate>; |
| 37 }; |
| 38 |
21 // A service which can be used to start background discovery and resolution of | 39 // A service which can be used to start background discovery and resolution of |
22 // DIAL devices (Smart TVs, Game Consoles, etc.). | 40 // DIAL devices (Smart TVs, Game Consoles, etc.). |
23 // This class is not thread safe. All methods must be called from the IO thread. | 41 // This class is not thread safe. All methods must be called from the IO thread. |
24 class DialMediaSinkServiceImpl : public MediaSinkServiceBase, | 42 class DialMediaSinkServiceImpl : public MediaSinkServiceBase, |
25 public DialRegistry::Observer { | 43 public DialRegistry::Observer { |
26 public: | 44 public: |
27 DialMediaSinkServiceImpl(const OnSinksDiscoveredCallback& callback, | 45 DialMediaSinkServiceImpl(const OnSinksDiscoveredCallback& callback, |
28 net::URLRequestContextGetter* request_context); | 46 net::URLRequestContextGetter* request_context); |
29 ~DialMediaSinkServiceImpl() override; | 47 ~DialMediaSinkServiceImpl() override; |
30 | 48 |
| 49 void SetDialMediaSinkServiceDelegate( |
| 50 scoped_refptr<DialMediaSinkServiceDelegate> delegate); |
| 51 |
31 // MediaSinkService implementation | 52 // MediaSinkService implementation |
32 void Start() override; | 53 void Start() override; |
33 void Stop() override; | 54 void Stop() override; |
34 | 55 |
35 protected: | 56 protected: |
36 // Returns instance of device description service. Create a new one if none | 57 // Returns instance of device description service. Create a new one if none |
37 // exists. | 58 // exists. |
38 DeviceDescriptionService* GetDescriptionService(); | 59 DeviceDescriptionService* GetDescriptionService(); |
39 | 60 |
40 // Does not take ownership of |dial_registry|. | 61 // Does not take ownership of |dial_registry|. |
(...skipping 30 matching lines...) Expand all Loading... |
71 | 92 |
72 // Raw pointer to DialRegistry singleton. | 93 // Raw pointer to DialRegistry singleton. |
73 DialRegistry* dial_registry_ = nullptr; | 94 DialRegistry* dial_registry_ = nullptr; |
74 | 95 |
75 // DialRegistry for unit test. | 96 // DialRegistry for unit test. |
76 DialRegistry* test_dial_registry_ = nullptr; | 97 DialRegistry* test_dial_registry_ = nullptr; |
77 | 98 |
78 // Device data list from current round of discovery. | 99 // Device data list from current round of discovery. |
79 DialRegistry::DeviceList current_devices_; | 100 DialRegistry::DeviceList current_devices_; |
80 | 101 |
| 102 scoped_refptr<DialMediaSinkServiceDelegate> delegate_; |
| 103 |
81 scoped_refptr<net::URLRequestContextGetter> request_context_; | 104 scoped_refptr<net::URLRequestContextGetter> request_context_; |
82 | 105 |
83 MediaRouterMetrics metrics_; | 106 MediaRouterMetrics metrics_; |
84 }; | 107 }; |
85 | 108 |
86 } // namespace media_router | 109 } // namespace media_router |
87 | 110 |
88 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_IM
PL_H_ | 111 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_IM
PL_H_ |
OLD | NEW |