OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
imcheng
2016/09/19 23:01:17
2016
zhaobin
2016/09/23 17:18:18
Done.
| |
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_OFFSCREEN_PRESENTATION_MANAGER_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/macros.h" | |
14 #include "chrome/browser/media/router/render_frame_host_id.h" | |
15 #include "components/keyed_service/core/keyed_service.h" | |
16 #include "content/public/browser/presentation_service_delegate.h" | |
17 | |
18 namespace media_router { | |
19 | |
20 class OffscreenPresentation; | |
21 | |
22 // This class lives in browser context and manages all presentations | |
imcheng
2016/09/19 23:01:17
Please clarify the comments:
- Instances of this
zhaobin
2016/09/23 17:18:18
Done.
| |
23 // in current browser process. All PSDImpl share the same instance of | |
24 // OffscreenPresentationManager. | |
25 class OffscreenPresentationManager : public KeyedService { | |
26 public: | |
27 ~OffscreenPresentationManager() override; | |
28 | |
29 // Register controller PSImpl to presentation with |presentation_id|. | |
30 // Create a new presentation if no presentation with |presentation_id| exists. | |
31 void RegisterOffscreenPresentationController( | |
32 const std::string& presentation_id, | |
33 content::OffscreenPresentationClient* controller); | |
34 | |
35 // Unregister controller PSImpl to presentation with |presentation_id|. | |
36 void UnregisterOffscreenPresentationController( | |
37 const std::string& presentation_id, | |
38 content::OffscreenPresentationClient* controller); | |
39 | |
40 // Register receiver PSImpl to presentation with |presentation_id|. | |
41 void RegisterOffscreenPresentationReceiver( | |
42 const std::string& presentation_id, | |
43 content::OffscreenPresentationClient* receiver); | |
imcheng
2016/09/19 23:01:17
The method signature here doesn't restrict it to R
zhaobin
2016/09/23 17:18:18
Done.
| |
44 | |
45 // Unregister receiver PSImpl to presentation with |presentation_id|, | |
46 // and remove presentation from presentation map. | |
47 void UnregisterOffscreenPresentationReceiver( | |
48 const std::string& presentation_id); | |
49 | |
50 private: | |
51 friend class OffscreenPresentationManagerFactory; | |
52 friend class OffscreenPresentationManagerTest; | |
53 | |
54 // Used by OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext. | |
55 OffscreenPresentationManager(); | |
56 | |
57 // Maps from presentation ID to OffscreenPresentation. | |
58 std::map<std::string, std::unique_ptr<OffscreenPresentation>> | |
59 offscreen_presentations_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(OffscreenPresentationManager); | |
62 }; | |
63 | |
64 class OffscreenPresentation { | |
imcheng
2016/09/19 23:01:17
Please add documentation
zhaobin
2016/09/23 17:18:18
Done.
| |
65 public: | |
66 explicit OffscreenPresentation(const std::string& presentation_id); | |
67 ~OffscreenPresentation(); | |
68 | |
69 void RegisterController(content::OffscreenPresentationClient* controller); | |
70 | |
71 void UnregisterController(content::OffscreenPresentationClient* controller); | |
72 | |
73 void RegisterReceiver(content::OffscreenPresentationClient* receiver); | |
74 | |
75 void UnregisterReceiver(); | |
76 | |
77 private: | |
78 friend class OffscreenPresentationManagerTest; | |
79 friend class OffscreenPresentationManager; | |
80 | |
81 void AddOffscreenPresentationObserver( | |
82 content::OffscreenPresentationClient* controller, | |
83 content::OffscreenPresentationClient* receiver); | |
84 | |
85 void RemoveOffscreenPresentationObserver( | |
86 content::OffscreenPresentationClient* controller, | |
87 content::OffscreenPresentationClient* receiver); | |
88 | |
89 // URL for current presentation | |
90 const std::string presentation_url_; | |
91 | |
92 // presentation_id for current presentation | |
93 const std::string presentation_id_; | |
94 | |
95 // proxy to receiver PSImpl | |
96 content::OffscreenPresentationClient* receiver_; | |
97 | |
98 // proxy to controller PSImpl | |
99 std::set<content::OffscreenPresentationClient*> controllers_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(OffscreenPresentation); | |
102 }; | |
103 | |
104 } // namespace media_router | |
105 | |
106 #endif // CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_ | |
OLD | NEW |