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_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_ | |
7 | |
8 #include <memory> | |
9 #include <set> | |
10 | |
11 #include "chrome/browser/media/router/discovery/dial/device_description_service. h" | |
12 #include "chrome/browser/media/router/discovery/dial/dial_registry.h" | |
13 #include "chrome/common/media_router/discovery/media_sink_internal.h" | |
14 #include "chrome/common/media_router/discovery/media_sink_service.h" | |
15 | |
16 namespace content { | |
17 class BrowserContext; | |
18 } | |
19 | |
20 namespace media_router { | |
21 | |
22 class DeviceDescriptionService; | |
23 class DialRegistry; | |
24 | |
25 class DialMediaSinkService : public MediaSinkService, | |
imcheng
2017/04/26 22:52:16
Could you please backfill class comments here?
zhaobin
2017/04/27 01:41:20
Done.
| |
26 public DialRegistry::Observer { | |
27 public: | |
28 DialMediaSinkService(const OnSinksDiscoveredCallback& callback, | |
29 content::BrowserContext* browser_context, | |
30 net::URLRequestContextGetter* request_context); | |
31 ~DialMediaSinkService() override; | |
32 | |
33 // MediaSinkService implementation | |
34 void Start() override; | |
35 void AddSinkQuery(MediaSinksObserver* observer) override; | |
36 void RemoveSinkQuery(MediaSinksObserver* observer) override; | |
37 | |
38 void Stop(); | |
39 | |
40 protected: | |
41 virtual DialRegistry* dial_registry(); | |
42 | |
43 // Returns instance of device description service. Create a new one if none | |
44 // exists. | |
45 virtual DeviceDescriptionService* GetDescriptionService(); | |
46 | |
47 private: | |
48 friend class DialMediaSinkServiceTest; | |
49 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestStart); | |
50 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestFetchCompleted); | |
51 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestIsDifferent); | |
52 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, | |
53 TestOnDeviceDescriptionAvailable); | |
54 | |
55 // api::dial::DialRegistry::Observer implementation | |
56 void OnDialDeviceEvent(const DialRegistry::DeviceList& devices) override; | |
57 void OnDialError(DialRegistry::DialErrorCode type) override; | |
58 | |
59 // Called when description service successfully fetches and parses device | |
60 // description XML. | |
61 void OnDeviceDescriptionAvailable( | |
62 const DialDeviceData& device_data, | |
63 const ParsedDialDeviceDescription& description_data); | |
64 | |
65 // Called when fails to fetch or parse device description XML. | |
66 void OnDeviceDescriptionError(const DialDeviceData& device, | |
67 const std::string& error_message); | |
68 | |
69 // Called when |finish_timer_| expires. | |
70 void OnFetchCompleted(); | |
71 | |
72 // Timer for finishing fetching for the first time (returns some devices to | |
73 // user ASAP). | |
74 std::unique_ptr<base::OneShotTimer> finish_timer_; | |
75 | |
76 std::unique_ptr<DeviceDescriptionService> description_service_; | |
77 | |
78 // Sorted sinks from current round of discovery. | |
79 std::set<MediaSinkInternal> current_sinks_; | |
80 | |
81 // Sorted sinks sent to Media Router Provider in last FetchCompleted(). | |
82 std::set<MediaSinkInternal> mrp_sinks_; | |
83 | |
84 // Device data list from current round of discovery. | |
85 DialRegistry::DeviceList current_devices_; | |
86 | |
87 content::BrowserContext* browser_context_; | |
88 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
89 }; | |
90 | |
91 } // namespace media_router | |
92 | |
93 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_ | |
OLD | NEW |