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

Side by Side Diff: chrome/browser/media/router/discovery/dial/dial_media_sink_service_proxy.h

Issue 2837363002: [Media Router] Use DialMediaSinkService in MediaRouterMojoImpl (Closed)
Patch Set: rebase with master Created 3 years, 7 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_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY _H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY _H_
7
8 #include <memory>
9
10 #include "base/macros.h"
mark a. foltz 2017/05/19 18:56:57 You need #includes for base::RefCountedThreadSafe
zhaobin 2017/05/22 20:21:31 Done.
11 #include "chrome/common/media_router/discovery/media_sink_service.h"
12 #include "content/public/browser/browser_thread.h"
13
14 namespace content {
15 class BrowserContext;
16 }
17
18 namespace net {
19 class URLRequestContextGetter;
20 }
21
22 namespace media_router {
23
24 class DialMediaSinkServiceImpl;
25
26 // A wrapper class of DialMediaSinkService handling thread hopping between UI
27 // and IO threads. This class is thread safe. Public APIs should be invoked on
28 // UI thread. It then post tasks to IO thread and invoke them on underlying
29 // DialMediaSinkService instance.
30 class DialMediaSinkServiceProxy
31 : public MediaSinkService,
32 public base::RefCountedThreadSafe<
33 DialMediaSinkServiceProxy,
34 content::BrowserThread::DeleteOnIOThread> {
35 public:
36 // |callback| is invoked on the UI thread when sinks are discovered.
37 // |context| is browser context.
38 DialMediaSinkServiceProxy(
39 const MediaSinkService::OnSinksDiscoveredCallback& callback,
40 content::BrowserContext* context);
41
42 // Starts discovery of DIAL devices on IO thread.
43 void Start() override;
44
45 // Stops discovery of DIAL devices on IO thread. The callback passed to
46 // Start() is cleared.
47 void Stop() override;
48
49 void SetDialMediaSinkServiceForTest(
50 std::unique_ptr<DialMediaSinkServiceImpl> dial_media_sink_service);
51
52 private:
53 friend class DialMediaSinkServiceProxyTest;
54 friend class base::DeleteHelper<DialMediaSinkServiceProxy>;
55 friend struct content::BrowserThread::DeleteOnThread<
56 content::BrowserThread::IO>;
57 friend class base::RefCountedThreadSafe<DialMediaSinkServiceProxy>;
58
59 ~DialMediaSinkServiceProxy() override;
60
61 // Starts DIAL discovery.
62 void StartOnIOThread();
63
64 // Stops DIAL discovery.
65 void StopOnIOThread();
66
67 // Callback passed to |dial_media_sink_service_| ctor. When invoked, post task
68 // to UI thread and invoke |sink_discovery_callback_|;
mark a. foltz 2017/05/19 18:56:57 Nit: s/;/./
zhaobin 2017/05/22 20:21:31 Done.
69 void OnSinksDiscoveredOnIOThread(const std::vector<MediaSinkInternal>& sinks);
70
71 private:
72 std::unique_ptr<DialMediaSinkServiceImpl> dial_media_sink_service_;
73
74 net::URLRequestContextGetter* request_context_;
75
76 DISALLOW_COPY_AND_ASSIGN(DialMediaSinkServiceProxy);
77 };
78
79 } // namespace media_router
80
81 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PR OXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698