OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 30 matching lines...) Expand all Loading... |
41 // It handles Presentation API requests coming from Blink / renderer process | 41 // It handles Presentation API requests coming from Blink / renderer process |
42 // and delegates the requests to the embedder's media router via | 42 // and delegates the requests to the embedder's media router via |
43 // PresentationServiceDelegate. | 43 // PresentationServiceDelegate. |
44 // An instance of this class tied to a RenderFrameHost and listens to events | 44 // An instance of this class tied to a RenderFrameHost and listens to events |
45 // related to the RFH via implementing WebContentsObserver. | 45 // related to the RFH via implementing WebContentsObserver. |
46 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 46 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
47 // from the renderer when the first presentation API request is handled. | 47 // from the renderer when the first presentation API request is handled. |
48 class CONTENT_EXPORT PresentationServiceImpl | 48 class CONTENT_EXPORT PresentationServiceImpl |
49 : public NON_EXPORTED_BASE(blink::mojom::PresentationService), | 49 : public NON_EXPORTED_BASE(blink::mojom::PresentationService), |
50 public WebContentsObserver, | 50 public WebContentsObserver, |
51 public PresentationServiceDelegate::Observer { | 51 public PresentationServiceDelegate::Observer, |
| 52 public OffscreenPresentationClient { |
52 public: | 53 public: |
53 using NewSessionCallback = | 54 using NewSessionCallback = |
54 base::Callback<void(blink::mojom::PresentationSessionInfoPtr, | 55 base::Callback<void(blink::mojom::PresentationSessionInfoPtr, |
55 blink::mojom::PresentationErrorPtr)>; | 56 blink::mojom::PresentationErrorPtr)>; |
56 | 57 |
57 ~PresentationServiceImpl() override; | 58 ~PresentationServiceImpl() override; |
58 | 59 |
59 // Static factory method to create an instance of PresentationServiceImpl. | 60 // Static factory method to create an instance of PresentationServiceImpl. |
60 // |render_frame_host|: The RFH the instance is associated with. | 61 // |render_frame_host|: The RFH the instance is associated with. |
61 // |request|: The instance will be bound to this request. Used for Mojo setup. | 62 // |request|: The instance will be bound to this request. Used for Mojo setup. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void ListenForConnectionStateChange( | 228 void ListenForConnectionStateChange( |
228 const PresentationSessionInfo& connection); | 229 const PresentationSessionInfo& connection); |
229 | 230 |
230 // Passed to embedder's implementation of PresentationServiceDelegate for | 231 // Passed to embedder's implementation of PresentationServiceDelegate for |
231 // later invocation when session messages arrive. | 232 // later invocation when session messages arrive. |
232 void OnSessionMessages( | 233 void OnSessionMessages( |
233 const content::PresentationSessionInfo& session, | 234 const content::PresentationSessionInfo& session, |
234 const ScopedVector<PresentationSessionMessage>& messages, | 235 const ScopedVector<PresentationSessionMessage>& messages, |
235 bool pass_ownership); | 236 bool pass_ownership); |
236 | 237 |
| 238 // OffscreenPresentationClient Implementation |
| 239 void OnReceiverConnectionAvailable( |
| 240 const content::PresentationSessionInfo&) override; |
| 241 |
| 242 void AddOffscreenPresentationObserver(OffscreenPresentationClient*) override; |
| 243 |
| 244 void RemoveOffscreenPresentationObserver( |
| 245 OffscreenPresentationClient*) override; |
| 246 |
237 // Associates a JoinSession |callback| with a unique request ID and | 247 // Associates a JoinSession |callback| with a unique request ID and |
238 // stores it in a map. | 248 // stores it in a map. |
239 // Returns a positive value on success. | 249 // Returns a positive value on success. |
240 int RegisterJoinSessionCallback(const NewSessionCallback& callback); | 250 int RegisterJoinSessionCallback(const NewSessionCallback& callback); |
241 | 251 |
242 // Invoked by the embedder's PresentationServiceDelegate when a | 252 // Invoked by the embedder's PresentationServiceDelegate when a |
243 // PresentationConnection's state has changed. | 253 // PresentationConnection's state has changed. |
244 void OnConnectionStateChanged( | 254 void OnConnectionStateChanged( |
245 const PresentationSessionInfo& connection, | 255 const PresentationSessionInfo& connection, |
246 const PresentationConnectionStateChangeInfo& info); | 256 const PresentationConnectionStateChangeInfo& info); |
(...skipping 30 matching lines...) Expand all Loading... |
277 | 287 |
278 // There can be only one send message request at a time. | 288 // There can be only one send message request at a time. |
279 std::unique_ptr<SendSessionMessageCallback> send_message_callback_; | 289 std::unique_ptr<SendSessionMessageCallback> send_message_callback_; |
280 | 290 |
281 std::unique_ptr<SessionMessagesCallback> on_session_messages_callback_; | 291 std::unique_ptr<SessionMessagesCallback> on_session_messages_callback_; |
282 | 292 |
283 // ID of the RenderFrameHost this object is associated with. | 293 // ID of the RenderFrameHost this object is associated with. |
284 int render_process_id_; | 294 int render_process_id_; |
285 int render_frame_id_; | 295 int render_frame_id_; |
286 | 296 |
| 297 // Offscreen presentation observer list for current frame. |
| 298 // For controller PSImpl, it contains corresponding receiver PSImpl, |
| 299 // and vise versa. |
| 300 std::set<OffscreenPresentationClient*> offscreen_presentation_observers_; |
| 301 |
287 // NOTE: Weak pointers must be invalidated before all other member variables. | 302 // NOTE: Weak pointers must be invalidated before all other member variables. |
288 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 303 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
289 | 304 |
290 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 305 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
291 }; | 306 }; |
292 | 307 |
293 } // namespace content | 308 } // namespace content |
294 | 309 |
295 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 310 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
OLD | NEW |