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 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/navigation_details.h" | 21 #include "content/public/browser/navigation_details.h" |
22 #include "content/public/browser/presentation_screen_availability_listener.h" | 22 #include "content/public/browser/presentation_screen_availability_listener.h" |
23 #include "content/public/browser/presentation_service_delegate.h" | 23 #include "content/public/browser/presentation_service_delegate.h" |
24 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
25 #include "content/public/common/frame_navigate_params.h" | 25 #include "content/public/common/frame_navigate_params.h" |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 struct FrameNavigateParams; | 29 struct FrameNavigateParams; |
30 struct LoadCommittedDetails; | 30 struct LoadCommittedDetails; |
| 31 struct PresentationSessionMessage; |
31 class RenderFrameHost; | 32 class RenderFrameHost; |
32 | 33 |
33 // Implementation of Mojo PresentationService. | 34 // Implementation of Mojo PresentationService. |
34 // It handles Presentation API requests coming from Blink / renderer process | 35 // It handles Presentation API requests coming from Blink / renderer process |
35 // and delegates the requests to the embedder's media router via | 36 // and delegates the requests to the embedder's media router via |
36 // PresentationServiceDelegate. | 37 // PresentationServiceDelegate. |
37 // An instance of this class tied to a RenderFrameHost and listens to events | 38 // An instance of this class tied to a RenderFrameHost and listens to events |
38 // related to the RFH via implementing WebContentsObserver. | 39 // related to the RFH via implementing WebContentsObserver. |
39 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 40 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
40 // from the renderer when the first presentation API request is handled. | 41 // from the renderer when the first presentation API request is handled. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 bool is_start_session, | 261 bool is_start_session, |
261 int request_session_id, | 262 int request_session_id, |
262 const PresentationError& error); | 263 const PresentationError& error); |
263 | 264 |
264 // Requests delegate to start a session. | 265 // Requests delegate to start a session. |
265 void DoStartSession( | 266 void DoStartSession( |
266 const std::string& presentation_url, | 267 const std::string& presentation_url, |
267 const std::string& presentation_id, | 268 const std::string& presentation_id, |
268 const NewSessionMojoCallback& callback); | 269 const NewSessionMojoCallback& callback); |
269 | 270 |
| 271 // Passed to embedder's implementation of PresentationServiceDelegate for |
| 272 // later invocation when session messages arrive. |
| 273 // For optimization purposes, this method will empty the messages |
| 274 // passed to it. |
| 275 void OnSessionMessages( |
| 276 scoped_ptr<ScopedVector<PresentationSessionMessage>> messages); |
| 277 |
270 // Removes the head of the queue (which represents the request that has just | 278 // Removes the head of the queue (which represents the request that has just |
271 // been processed). | 279 // been processed). |
272 // Checks if there are any queued StartSession requests and if so, executes | 280 // Checks if there are any queued StartSession requests and if so, executes |
273 // the first one in the queue. | 281 // the first one in the queue. |
274 void HandleQueuedStartSessionRequests(); | 282 void HandleQueuedStartSessionRequests(); |
275 | 283 |
276 // Associates |callback| with a unique request ID and stores it in a map. | 284 // Associates |callback| with a unique request ID and stores it in a map. |
277 int RegisterNewSessionCallback( | 285 int RegisterNewSessionCallback( |
278 const NewSessionMojoCallback& callback); | 286 const NewSessionMojoCallback& callback); |
279 | 287 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 319 |
312 int next_request_session_id_; | 320 int next_request_session_id_; |
313 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; | 321 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; |
314 | 322 |
315 scoped_ptr<DefaultSessionStartContext> default_session_start_context_; | 323 scoped_ptr<DefaultSessionStartContext> default_session_start_context_; |
316 | 324 |
317 // RAII binding of |this| to an Presentation interface request. | 325 // RAII binding of |this| to an Presentation interface request. |
318 // The binding is removed when binding_ is cleared or goes out of scope. | 326 // The binding is removed when binding_ is cleared or goes out of scope. |
319 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; | 327 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; |
320 | 328 |
| 329 scoped_ptr<SessionMessagesCallback> on_session_messages_callback_; |
| 330 |
321 // ID of the RenderFrameHost this object is associated with. | 331 // ID of the RenderFrameHost this object is associated with. |
322 int render_process_id_; | 332 int render_process_id_; |
323 int render_frame_id_; | 333 int render_frame_id_; |
324 | 334 |
325 // NOTE: Weak pointers must be invalidated before all other member variables. | 335 // NOTE: Weak pointers must be invalidated before all other member variables. |
326 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 336 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
327 | 337 |
328 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 338 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
329 }; | 339 }; |
330 | 340 |
331 } // namespace content | 341 } // namespace content |
332 | 342 |
333 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 343 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
OLD | NEW |