Chromium Code Reviews| 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 void OnSessionMessages( | |
|
whywhat
2015/05/01 15:26:12
Please, document that for optimization purposes, t
haibinlu
2015/05/01 19:03:20
Done. Message size is up to 64KB. With get-next-ba
| |
| 272 scoped_ptr<ScopedVector<PresentationSessionMessage>> messages); | |
| 273 | |
| 274 static presentation::SessionMessagePtr ToMojoSessionMessage( | |
|
whywhat
2015/05/01 15:26:12
move to the .cc file and the unnamed namespace? do
haibinlu
2015/05/01 19:03:20
Done.
| |
| 275 content::PresentationSessionMessage* input); | |
| 276 | |
| 270 // Removes the head of the queue (which represents the request that has just | 277 // Removes the head of the queue (which represents the request that has just |
| 271 // been processed). | 278 // been processed). |
| 272 // Checks if there are any queued StartSession requests and if so, executes | 279 // Checks if there are any queued StartSession requests and if so, executes |
| 273 // the first one in the queue. | 280 // the first one in the queue. |
| 274 void HandleQueuedStartSessionRequests(); | 281 void HandleQueuedStartSessionRequests(); |
| 275 | 282 |
| 276 // Associates |callback| with a unique request ID and stores it in a map. | 283 // Associates |callback| with a unique request ID and stores it in a map. |
| 277 int RegisterNewSessionCallback( | 284 int RegisterNewSessionCallback( |
| 278 const NewSessionMojoCallback& callback); | 285 const NewSessionMojoCallback& callback); |
| 279 | 286 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 | 318 |
| 312 int next_request_session_id_; | 319 int next_request_session_id_; |
| 313 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; | 320 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; |
| 314 | 321 |
| 315 scoped_ptr<DefaultSessionStartContext> default_session_start_context_; | 322 scoped_ptr<DefaultSessionStartContext> default_session_start_context_; |
| 316 | 323 |
| 317 // RAII binding of |this| to an Presentation interface request. | 324 // RAII binding of |this| to an Presentation interface request. |
| 318 // The binding is removed when binding_ is cleared or goes out of scope. | 325 // The binding is removed when binding_ is cleared or goes out of scope. |
| 319 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; | 326 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; |
| 320 | 327 |
| 328 scoped_ptr<SessionMessagesCallback> on_session_messages_; | |
|
whywhat
2015/05/01 15:26:12
nit: postfix the name with callback_. without know
haibinlu
2015/05/01 19:03:20
Done.
| |
| 329 | |
| 321 // ID of the RenderFrameHost this object is associated with. | 330 // ID of the RenderFrameHost this object is associated with. |
| 322 int render_process_id_; | 331 int render_process_id_; |
| 323 int render_frame_id_; | 332 int render_frame_id_; |
| 324 | 333 |
| 325 // NOTE: Weak pointers must be invalidated before all other member variables. | 334 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 326 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 335 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 327 | 336 |
| 328 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 337 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 329 }; | 338 }; |
| 330 | 339 |
| 331 } // namespace content | 340 } // namespace content |
| 332 | 341 |
| 333 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 342 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |