Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: chrome/browser/media/router/dial_media_sink_service.h

Issue 2701633002: [Media Router] Add DialMediaSinkService and DeviceDescriptionService (Closed)
Patch Set: Add DialMediaSinkCacheService and unit test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_DIAL_MEDIA_SINK_SERVICE_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_DIAL_MEDIA_SINK_SERVICE_H_
7
8 #include <memory>
9
10 #include "chrome/browser/extensions/api/dial/dial_registry.h"
11 #include "chrome/browser/media/router/device_description_service.h"
12 #include "chrome/browser/media/router/dial_media_sink_cache_service.h"
13 #include "chrome/browser/media/router/discovery/media_sink_internal.h"
14 #include "chrome/browser/media/router/media_sink_service.h"
15
16 namespace content {
17 class BrowserContext;
18 }
19
20 namespace extensions {
21 class DialAPI;
22 }
23
24 namespace net {
25 class URLRequestContextGetter;
26 }
27
28 namespace media_router {
29
30 class DialMediaSinkService
31 : public MediaSinkService,
32 public extensions::api::dial::DialRegistry::Observer,
33 public DeviceDescriptionService::Observer {
34 public:
35 DialMediaSinkService(const OnSinksDiscoveredCallback& callback,
36 content::BrowserContext* browser_context);
37 ~DialMediaSinkService() override;
38
39 // MediaSinkService implementation
40 void Start() override;
41 void AddSinkQuery(MediaSinksObserver* observer) override;
42 void RemoveSinkQuery(MediaSinksObserver* observer) override;
43
44 protected:
45 using DialRegistry = extensions::api::dial::DialRegistry;
46
47 virtual DialRegistry* dial_registry();
48 virtual DeviceDescriptionService* description_service();
49 virtual DialMediaSinkCacheService* cache_service();
50
51 private:
52 friend class DialMediaSinkServiceTest;
53 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestStart);
54 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestFetchCompleted);
55 FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestIsDifferent);
56
57 // api::dial::DialRegistry::Observer implementation
58 void OnDialDeviceEvent(const DialRegistry::DeviceList& devices) override;
59 void OnDialError(DialRegistry::DialErrorCode type) override;
60
61 // DeviceDescriptionService::Observer implementation.
62 void OnDeviceDescriptionAvailable(
63 const std::string& device_label,
64 const DialDeviceDescription& description) override;
65 void OnDeviceDescriptionFetchError(const std::string& device_label,
66 const std::string& error_message) override;
67
68 void FetchCompleted();
69
70 bool IsDifferent(const std::vector<MediaSinkInternal> new_sinks,
71 const std::vector<MediaSinkInternal> old_sinks);
72
73 // Device ids pending resolution
74 std::set<std::string> pending_device_labels_;
75
76 // Map of <sink id, DialMediaSink> for current round discovery.
77 // std::map<std::string, DialMediaSink> dial_sinks_;
78
79 // Timer for finishing fetching.
80 base::OneShotTimer finish_timer_;
81
82 // |dial_api_| lives in IO thread. It owns |dial_registry_|.
83 scoped_refptr<extensions::DialAPI> dial_api_;
84
85 // This class does not take ownership of |dial_registry_|. |dial_api_| owns
86 // this.
87 DialRegistry* dial_registry_;
88
89 std::unique_ptr<DeviceDescriptionService> description_service_;
90 std::unique_ptr<DialMediaSinkCacheService> cache_service_;
91
92 content::BrowserContext* browser_context_;
93 net::URLRequestContextGetter* request_context_;
94
95 std::vector<MediaSinkInternal> mrp_sinks_;
96
97 bool network_disconnected_;
98 };
99
100 } // namespace media_router
101
102 #endif // CHROME_BROWSER_MEDIA_ROUTER_DIAL_MEDIA_SINK_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698