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_PROXY
_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY
_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY
_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY
_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/sequenced_task_runner_helpers.h" | 12 #include "base/sequenced_task_runner_helpers.h" |
13 #include "chrome/common/media_router/discovery/media_sink_service.h" | 13 #include "chrome/common/media_router/discovery/media_sink_service.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class BrowserContext; | 18 class BrowserContext; |
19 } | 19 } |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
23 } | 23 } |
24 | 24 |
25 namespace media_router { | 25 namespace media_router { |
26 | 26 |
| 27 class CastMediaSinkService; |
27 class DialMediaSinkServiceImpl; | 28 class DialMediaSinkServiceImpl; |
28 | 29 |
29 // A wrapper class of DialMediaSinkService handling thread hopping between UI | 30 // A wrapper class of DialMediaSinkService handling thread hopping between UI |
30 // and IO threads. This class is thread safe. Public APIs should be invoked on | 31 // and IO threads. This class is thread safe. Public APIs should be invoked on |
31 // UI thread. It then post tasks to IO thread and invoke them on underlying | 32 // UI thread. It then post tasks to IO thread and invoke them on underlying |
32 // DialMediaSinkService instance. | 33 // DialMediaSinkService instance. |
33 class DialMediaSinkServiceProxy | 34 class DialMediaSinkServiceProxy |
34 : public MediaSinkService, | 35 : public MediaSinkService, |
35 public base::RefCountedThreadSafe< | 36 public base::RefCountedThreadSafe< |
36 DialMediaSinkServiceProxy, | 37 DialMediaSinkServiceProxy, |
37 content::BrowserThread::DeleteOnIOThread> { | 38 content::BrowserThread::DeleteOnIOThread> { |
38 public: | 39 public: |
39 // |callback| is invoked on the UI thread when sinks are discovered. | 40 // |callback| is invoked on the UI thread when sinks are discovered. |
40 // |context| is browser context. | 41 // |context| is browser context. |
41 DialMediaSinkServiceProxy( | 42 DialMediaSinkServiceProxy( |
42 const MediaSinkService::OnSinksDiscoveredCallback& callback, | 43 const MediaSinkService::OnSinksDiscoveredCallback& callback, |
| 44 scoped_refptr<CastMediaSinkService> cast_media_sink_service, |
43 content::BrowserContext* context); | 45 content::BrowserContext* context); |
44 | 46 |
45 // Starts discovery of DIAL devices on IO thread. Caller is responsible for | 47 // Starts discovery of DIAL devices on IO thread. Caller is responsible for |
46 // calling Stop() before destroying this object.. | 48 // calling Stop() before destroying this object.. |
47 void Start() override; | 49 void Start() override; |
48 | 50 |
49 // Stops discovery of DIAL devices on IO thread. The callback passed to | 51 // Stops discovery of DIAL devices on IO thread. The callback passed to |
50 // Start() is cleared. | 52 // Start() is cleared. |
51 void Stop() override; | 53 void Stop() override; |
52 | 54 |
(...skipping 15 matching lines...) Expand all Loading... |
68 // Stops DIAL discovery. | 70 // Stops DIAL discovery. |
69 void StopOnIOThread(); | 71 void StopOnIOThread(); |
70 | 72 |
71 // Callback passed to |dial_media_sink_service_| ctor. When invoked, post task | 73 // Callback passed to |dial_media_sink_service_| ctor. When invoked, post task |
72 // to UI thread and invoke |sink_discovery_callback_|. | 74 // to UI thread and invoke |sink_discovery_callback_|. |
73 void OnSinksDiscoveredOnIOThread(std::vector<MediaSinkInternal> sinks); | 75 void OnSinksDiscoveredOnIOThread(std::vector<MediaSinkInternal> sinks); |
74 | 76 |
75 private: | 77 private: |
76 std::unique_ptr<DialMediaSinkServiceImpl> dial_media_sink_service_; | 78 std::unique_ptr<DialMediaSinkServiceImpl> dial_media_sink_service_; |
77 | 79 |
| 80 scoped_refptr<CastMediaSinkService> cast_media_sink_service_; |
| 81 |
78 scoped_refptr<net::URLRequestContextGetter> request_context_; | 82 scoped_refptr<net::URLRequestContextGetter> request_context_; |
79 | 83 |
80 DISALLOW_COPY_AND_ASSIGN(DialMediaSinkServiceProxy); | 84 DISALLOW_COPY_AND_ASSIGN(DialMediaSinkServiceProxy); |
81 }; | 85 }; |
82 | 86 |
83 } // namespace media_router | 87 } // namespace media_router |
84 | 88 |
85 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PR
OXY_H_ | 89 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PR
OXY_H_ |
OLD | NEW |