Chromium Code Reviews| 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_DELEG ATE_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_DELEG ATE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include "chrome/common/media_router/discovery/media_sink_service.h" | |
| 10 #include "content/public/browser/browser_thread.h" | |
| 11 | |
| 12 namespace net { | |
| 13 class URLRequestContextGetter; | |
| 14 } | |
| 15 | |
| 16 namespace media_router { | |
| 17 | |
| 18 class DialMediaSinkService; | |
| 19 | |
| 20 // A wrapper class of DialMediaSinkService handling thread hopping between UI | |
| 21 // and IO threads. This class is thread safe. Public APIs should be invoked on | |
| 22 // UI thread. It then post tasks to IO thread and invoke them on underlying | |
| 23 // DialMediaSinkService instance. | |
| 24 class DialMediaSinkServiceDelegate | |
|
mark a. foltz
2017/05/12 21:37:37
Bikeshed:
Usually I would see a "delegate" and th
zhaobin
2017/05/12 23:03:38
Sure. Will do refactor in another patch and update
| |
| 25 : public base::RefCountedThreadSafe<DialMediaSinkServiceDelegate> { | |
| 26 public: | |
| 27 DialMediaSinkServiceDelegate(); | |
| 28 | |
| 29 // Store |callback| and post task to IO thread. | |
|
mark a. foltz
2017/05/12 21:37:37
Suggested comment:
Starts discovery of DIAL devic
zhaobin
2017/05/12 23:03:38
Done.
| |
| 30 void Start(const MediaSinkService::OnSinksDiscoveredCallback& callback, | |
| 31 net::URLRequestContextGetter* request_context); | |
| 32 | |
| 33 // Clear |sink_discovery_callback_| and post task to IO thread. | |
|
mark a. foltz
2017/05/12 21:37:37
Suggest:
Stops discovery of DIAL devices on IO th
zhaobin
2017/05/12 23:03:38
Done.
| |
| 34 void Stop(); | |
| 35 | |
| 36 void SetDialMediaSinkServiceForTest( | |
| 37 std::unique_ptr<DialMediaSinkService, | |
| 38 content::BrowserThread::DeleteOnIOThread> | |
| 39 dial_media_sink_service); | |
| 40 | |
| 41 private: | |
| 42 friend class DialMediaSinkServiceDelegateTest; | |
| 43 friend class base::RefCountedThreadSafe<DialMediaSinkServiceDelegate>; | |
| 44 ~DialMediaSinkServiceDelegate(); | |
| 45 | |
| 46 // Create |dial_media_sink_service_| if none exists before and start DIAL | |
|
mark a. foltz
2017/05/12 21:37:37
Creates
zhaobin
2017/05/12 23:03:38
Done.
| |
| 47 // discvoery. | |
|
mark a. foltz
2017/05/12 21:37:37
typo in discovery
zhaobin
2017/05/12 23:03:38
Done.
| |
| 48 void StartOnIOThread(net::URLRequestContextGetter* request_context); | |
| 49 | |
| 50 // Stop DIAL discovery. | |
|
mark a. foltz
2017/05/12 21:37:37
Stops
zhaobin
2017/05/12 23:03:38
Done.
| |
| 51 void StopOnIOThread(); | |
| 52 | |
| 53 // Callback passed to |dial_media_sink_service_| ctor. When invoked, post task | |
| 54 // to UI thread and invoke |sink_discovery_callback_|; | |
| 55 void OnSinksDiscoveredOnIOThread(const std::vector<MediaSinkInternal>& sinks); | |
| 56 | |
| 57 // Invoke |sink_discovery_callback_| on UI thread. | |
|
mark a. foltz
2017/05/12 21:37:37
Invokes
zhaobin
2017/05/12 23:03:38
Done.
| |
| 58 void OnSinksDiscoveredOnUIThread(const std::vector<MediaSinkInternal>& sinks); | |
| 59 | |
| 60 private: | |
| 61 std::unique_ptr<DialMediaSinkService, | |
| 62 content::BrowserThread::DeleteOnIOThread> | |
| 63 dial_media_sink_service_; | |
| 64 | |
| 65 MediaSinkService::OnSinksDiscoveredCallback sink_discovery_ui_callback_; | |
| 66 }; | |
| 67 | |
| 68 } // namespace media_router | |
| 69 | |
| 70 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_DE LEGATE_H_ | |
| OLD | NEW |