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

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

Issue 2701633002: [Media Router] Add DialMediaSinkService and DeviceDescriptionService (Closed)
Patch Set: Created 3 years, 10 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/media_sink.h"
13 #include "chrome/browser/media/router/media_sink_service.h"
14
15 namespace content {
16 class BrowserContext;
17 }
18
19 namespace extensions {
20 class DialAPI;
21 }
22
23 namespace net {
24 class URLRequestContextGetter;
25 }
26
27 namespace media_router {
28
29 class DialMediaSinkService
30 : public MediaSinkService,
31 public extensions::api::dial::DialRegistry::Observer,
32 public DeviceDescriptionService::Observer {
33 public:
34 DialMediaSinkService(const OnSinksDiscoveredCallback& callback,
35 content::BrowserContext* browser_context);
mark a. foltz 2017/03/11 00:08:15 Is this a profile-keyed service? Note that we hav
zhaobin 2017/04/10 18:44:41 We use profile to get request context for URL fetc
36 ~DialMediaSinkService() override;
37
38 // MediaSinkService implementation
39 void Start() override;
40 void AddSinkQuery(MediaSinksObserver* observer) override;
41 void RemoveSinkQuery(MediaSinksObserver* observer) override;
42
43 private:
44 using DialRegistry = extensions::api::dial::DialRegistry;
45
46 DialRegistry* dial_registry();
47 DeviceDescriptionService* description_service();
48
49 // api::dial::DialRegistry::Observer implementation
50 void OnDialDeviceEvent(const DialRegistry::DeviceList& devices) override;
51 void OnDialError(DialRegistry::DialErrorCode type) override;
52
53 // DeviceDescriptionService::Observer implementation.
54 void OnDeviceDescriptionAvailable(
55 const std::string& device_label,
56 const DialDeviceDescription& description) override;
57 void OnDeviceDescriptionFetchError(const std::string& device_label,
58 const std::string& error_message) override;
59
60 void OnDeviceDescription(const std::string& device_id);
61 void FetchCompleted();
62
63 // Device ids pending resolution
64 std::set<std::string> pending_device_labels_;
65
66 // Map of <sink id, mediaSink>
67 std::map<std::string, std::unique_ptr<MediaSink>> dial_sinks_;
68
69 // |dial_api_| lives in IO thread. It owns |dial_registry_|.
70 scoped_refptr<extensions::DialAPI> dial_api_;
71 DialRegistry* dial_registry_;
mark a. foltz 2017/03/11 00:08:15 The DialRegistry should become refcounted, since I
zhaobin 2017/03/28 13:36:59 DialRegistry is a leaky singleton now. Raw pointer
72
73 std::unique_ptr<DeviceDescriptionService> description_service_;
74 content::BrowserContext* browser_context_;
75 net::URLRequestContextGetter* request_context_;
mark a. foltz 2017/03/11 00:08:15 This is usually passed directly to the URLFetcher
zhaobin 2017/04/10 18:44:42 profile->GetRequestContext() should be called on U
76 };
77
78 } // namespace media_router
79
80 #endif // CHROME_BROWSER_MEDIA_ROUTER_DIAL_MEDIA_SINK_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698