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

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

Issue 2714783002: [Presentation API] (browser side) Implement reconnect() for 1-UA mode (Closed)
Patch Set: remove duplicate unit tests 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_OFFSCREEN_PRESENTATION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <unordered_map> 11 #include <unordered_map>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "chrome/browser/media/router/media_route.h"
15 #include "chrome/browser/media/router/render_frame_host_id.h" 16 #include "chrome/browser/media/router/render_frame_host_id.h"
16 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
17 #include "content/public/browser/presentation_service_delegate.h" 18 #include "content/public/browser/presentation_service_delegate.h"
18 19
19 class GURL; 20 class GURL;
20 21
21 namespace media_router { 22 namespace media_router {
22 // Manages all offscreen presentations started in the associated Profile and 23 // Manages all offscreen presentations started in the associated Profile and
23 // facilitates communication between the controllers and the receiver of an 24 // facilitates communication between the controllers and the receiver of an
24 // offscreen presentation. 25 // offscreen presentation.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 virtual void OnOffscreenPresentationReceiverCreated( 127 virtual void OnOffscreenPresentationReceiverCreated(
127 const std::string& presentation_id, 128 const std::string& presentation_id,
128 const GURL& presentation_url, 129 const GURL& presentation_url,
129 const content::ReceiverConnectionAvailableCallback& receiver_callback); 130 const content::ReceiverConnectionAvailableCallback& receiver_callback);
130 131
131 // Unregisters ReceiverConnectionAvailableCallback associated with 132 // Unregisters ReceiverConnectionAvailableCallback associated with
132 // |presentation_id|. 133 // |presentation_id|.
133 virtual void OnOffscreenPresentationReceiverTerminated( 134 virtual void OnOffscreenPresentationReceiverTerminated(
134 const std::string& presentation_id); 135 const std::string& presentation_id);
135 136
137 // Register |route| to offscreen presentation object associated with
138 // |presentation_id| and |presentation_url|.
139 // Creates a new presentation if no presentation with |presentation_id|
140 // exists.
141 virtual void RegisterOffscreenPresentationRoute(
142 const std::string& presentation_id,
143 const GURL& presentation_url,
144 const MediaRoute& route);
145
146 // Returns true if this class has an offscreen presentation with
147 // |presentation_id|.
148 virtual bool IsOffscreenPresentation(const std::string& presentation_id);
149
150 // Returns nullptr if |presentation_id| is not associated with an offscreen
151 // presentation.
152 virtual const MediaRoute* GetRoute(const std::string& presentation_id);
153
136 private: 154 private:
137 // Represents an offscreen presentation registered with 155 // Represents an offscreen presentation registered with
138 // OffscreenPresentationManager. Contains callback to the receiver to inform 156 // OffscreenPresentationManager. Contains callback to the receiver to inform
139 // it of new connections established from a controller. Contains set of 157 // it of new connections established from a controller. Contains set of
140 // controllers registered to OffscreenPresentationManager before corresponding 158 // controllers registered to OffscreenPresentationManager before corresponding
141 // receiver. 159 // receiver.
142 class OffscreenPresentation { 160 class OffscreenPresentation {
143 public: 161 public:
144 OffscreenPresentation(const std::string& presentation_id, 162 OffscreenPresentation(const std::string& presentation_id,
145 const GURL& presentation_url); 163 const GURL& presentation_url);
(...skipping 14 matching lines...) Expand all
160 // pending controller with |render_frame_id|. 178 // pending controller with |render_frame_id|.
161 void UnregisterController(const RenderFrameHostId& render_frame_id); 179 void UnregisterController(const RenderFrameHostId& render_frame_id);
162 180
163 // Register |receiver_callback| to current offscreen_presentation object. 181 // Register |receiver_callback| to current offscreen_presentation object.
164 // For each controller in |pending_controllers_| map, invoke 182 // For each controller in |pending_controllers_| map, invoke
165 // |receiver_callback| with controller as parameter. Clear 183 // |receiver_callback| with controller as parameter. Clear
166 // |pending_controllers_| map afterwards. 184 // |pending_controllers_| map afterwards.
167 void RegisterReceiver( 185 void RegisterReceiver(
168 const content::ReceiverConnectionAvailableCallback& receiver_callback); 186 const content::ReceiverConnectionAvailableCallback& receiver_callback);
169 187
188 // Register |route| to this class.
189 void RegisterRoute(const MediaRoute& route);
190
170 private: 191 private:
171 friend class OffscreenPresentationManagerTest; 192 friend class OffscreenPresentationManagerTest;
172 friend class OffscreenPresentationManager; 193 friend class OffscreenPresentationManager;
173 194
174 // Returns false if receiver_callback_ is null and there are no pending 195 // Returns false if receiver_callback_ is null and there are no pending
175 // controllers. 196 // controllers.
176 bool IsValid() const; 197 bool IsValid() const;
177 198
178 const std::string presentation_id_; 199 const std::string presentation_id_;
179 const GURL presentation_url_; 200 const GURL presentation_url_;
201 std::unique_ptr<MediaRoute> route_;
imcheng 2017/02/24 01:37:46 What does it mean to have an OffscreenPresentation
zhaobin 2017/02/24 02:35:33 Yes. RegisterReceiver() is invoked by receiver's P
imcheng 2017/02/24 20:52:25 Hmm, this almost feels as if we should have a pres
mark a. foltz 2017/03/01 06:26:32 What if we added a presentationId field to MediaRo
180 202
181 // Callback to invoke whenever a receiver connection is available. 203 // Callback to invoke whenever a receiver connection is available.
182 content::ReceiverConnectionAvailableCallback receiver_callback_; 204 content::ReceiverConnectionAvailableCallback receiver_callback_;
183 205
184 // Stores controller information. 206 // Stores controller information.
185 // |controller_connection_ptr|: Mojo::InterfacePtr to 207 // |controller_connection_ptr|: Mojo::InterfacePtr to
186 // blink::PresentationConnection object in controlling frame; 208 // blink::PresentationConnection object in controlling frame;
187 // |receiver_connection_request|: Mojo::InterfaceRequest to be bind to 209 // |receiver_connection_request|: Mojo::InterfaceRequest to be bind to
188 // blink::PresentationConnection object in receiver frame. 210 // blink::PresentationConnection object in receiver frame.
189 struct ControllerConnection { 211 struct ControllerConnection {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 OffscreenPresentationMap offscreen_presentations_; 252 OffscreenPresentationMap offscreen_presentations_;
231 253
232 base::ThreadChecker thread_checker_; 254 base::ThreadChecker thread_checker_;
233 255
234 DISALLOW_COPY_AND_ASSIGN(OffscreenPresentationManager); 256 DISALLOW_COPY_AND_ASSIGN(OffscreenPresentationManager);
235 }; 257 };
236 258
237 } // namespace media_router 259 } // namespace media_router
238 260
239 #endif // CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_ 261 #endif // CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698