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 | |
10 #include "chrome/browser/media/router/discovery/dial/device_description_service. h" | |
11 #include "chrome/browser/media/router/discovery/dial/dial_registry.h" | |
12 #include "chrome/browser/media/router/discovery/media_sink_internal.h" | |
13 #include "chrome/browser/media/router/media_sink_service.h" | |
14 | |
15 namespace content { | |
16 class BrowserContext; | |
17 } | |
18 | |
19 namespace media_router { | |
20 | |
21 class DeviceDescriptionService; | |
22 class DialMediaSinkCacheService; | |
23 class DialRegistry; | |
24 | |
25 class DialMediaSinkService : public MediaSinkService, | |
26 public DialRegistry::Observer { | |
27 public: | |
28 DialMediaSinkService(const OnSinksDiscoveredCallback& callback, | |
29 content::BrowserContext* browser_context); | |
30 ~DialMediaSinkService() override; | |
31 | |
32 // MediaSinkService implementation | |
33 void Start() override; | |
34 void AddSinkQuery(MediaSinksObserver* observer) override; | |
35 void RemoveSinkQuery(MediaSinksObserver* observer) override; | |
36 | |
37 void Stop(); | |
38 | |
39 protected: | |
40 virtual DialRegistry* dial_registry(); | |
41 virtual DeviceDescriptionService* description_service(); | |
42 virtual DialMediaSinkCacheService* cache_service(); | |
43 | |
44 private: | |
45 friend class DialMediaSinkServiceTest; | |
46 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestStart); | |
47 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestFetchCompleted); | |
48 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestIsDifferent); | |
49 | |
50 // api::dial::DialRegistry::Observer implementation | |
51 void OnDialDeviceEvent(const DialRegistry::DeviceList& devices) override; | |
52 void OnDialError(DialRegistry::DialErrorCode type) override; | |
53 | |
54 // Called when fails to fetch or parse device description xml. | |
55 void OnDeviceDescriptionError(const std::string& device_label, | |
56 const std::string& error_message); | |
57 | |
58 // Called when |finish_timer_| expires. | |
59 void FetchCompleted(); | |
60 | |
61 // Returns true if |new_sink| is the same as |old_sinks|. | |
mark a. foltz
2017/04/12 00:17:18
s/new_sink/new_sinks/
The comment and the name of
zhaobin
2017/04/18 06:58:27
Done.
| |
62 bool IsDifferent(const std::vector<MediaSinkInternal> new_sinks, | |
63 const std::vector<MediaSinkInternal> old_sinks); | |
64 | |
65 // Timer for finishing fetching. | |
66 base::OneShotTimer finish_timer_; | |
67 | |
68 std::unique_ptr<DeviceDescriptionService> description_service_; | |
69 std::unique_ptr<DialMediaSinkCacheService> cache_service_; | |
70 | |
71 // Sinks sent to Media Router Provider in last FetchCompleted(). | |
72 std::vector<MediaSinkInternal> mrp_sinks_; | |
73 | |
74 bool network_disconnected_; | |
75 | |
76 content::BrowserContext* browser_context_; | |
77 net::URLRequestContextGetter* request_context_; | |
78 }; | |
79 | |
80 } // namespace media_router | |
81 | |
82 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_ | |
OLD | NEW |