| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 using ScreenAvailabilityMojoCallback = | 57 using ScreenAvailabilityMojoCallback = |
| 58 mojo::Callback<void(mojo::String, bool)>; | 58 mojo::Callback<void(mojo::String, bool)>; |
| 59 using NewSessionMojoCallback = | 59 using NewSessionMojoCallback = |
| 60 mojo::Callback<void(presentation::PresentationSessionInfoPtr, | 60 mojo::Callback<void(presentation::PresentationSessionInfoPtr, |
| 61 presentation::PresentationErrorPtr)>; | 61 presentation::PresentationErrorPtr)>; |
| 62 using DefaultSessionMojoCallback = | 62 using DefaultSessionMojoCallback = |
| 63 mojo::Callback<void(presentation::PresentationSessionInfoPtr)>; | 63 mojo::Callback<void(presentation::PresentationSessionInfoPtr)>; |
| 64 using SessionStateCallback = | 64 using SessionStateCallback = |
| 65 mojo::Callback<void(presentation::PresentationSessionInfoPtr, | 65 mojo::Callback<void(presentation::PresentationSessionInfoPtr, |
| 66 presentation::PresentationSessionState)>; | 66 presentation::PresentationSessionState)>; |
| 67 using SendMessageMojoCallback = mojo::Callback<void()>; |
| 67 | 68 |
| 68 // A helper data class used by PresentationServiceImpl to do bookkeeping | 69 // A helper data class used by PresentationServiceImpl to do bookkeeping |
| 69 // of currently registered screen availability listeners. | 70 // of currently registered screen availability listeners. |
| 70 // An instance of this class is a simple state machine that waits for both | 71 // An instance of this class is a simple state machine that waits for both |
| 71 // the available bit and the Mojo callback to become available. | 72 // the available bit and the Mojo callback to become available. |
| 72 // Once this happens, the Mojo callback will be invoked with the available | 73 // Once this happens, the Mojo callback will be invoked with the available |
| 73 // bit, and the state machine will reset. | 74 // bit, and the state machine will reset. |
| 74 // The available bit is obtained from the embedder's media router. | 75 // The available bit is obtained from the embedder's media router. |
| 75 // The callback is obtained from the renderer via PresentationServiceImpl's | 76 // The callback is obtained from the renderer via PresentationServiceImpl's |
| 76 // ListenForScreenAvailability(). | 77 // ListenForScreenAvailability(). |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void ListenForDefaultSessionStart( | 160 void ListenForDefaultSessionStart( |
| 160 const DefaultSessionMojoCallback& callback) override; | 161 const DefaultSessionMojoCallback& callback) override; |
| 161 void StartSession( | 162 void StartSession( |
| 162 const mojo::String& presentation_url, | 163 const mojo::String& presentation_url, |
| 163 const mojo::String& presentation_id, | 164 const mojo::String& presentation_id, |
| 164 const NewSessionMojoCallback& callback) override; | 165 const NewSessionMojoCallback& callback) override; |
| 165 void JoinSession( | 166 void JoinSession( |
| 166 const mojo::String& presentation_url, | 167 const mojo::String& presentation_url, |
| 167 const mojo::String& presentation_id, | 168 const mojo::String& presentation_id, |
| 168 const NewSessionMojoCallback& callback) override; | 169 const NewSessionMojoCallback& callback) override; |
| 170 void SendStringMessage( |
| 171 const mojo::String& presentation_url, |
| 172 const mojo::String& presentation_id, |
| 173 const mojo::String& message, |
| 174 const SendMessageMojoCallback& callback) override; |
| 169 void CloseSession( | 175 void CloseSession( |
| 170 const mojo::String& presentation_url, | 176 const mojo::String& presentation_url, |
| 171 const mojo::String& presentation_id) override; | 177 const mojo::String& presentation_id) override; |
| 172 void ListenForSessionStateChange( | 178 void ListenForSessionStateChange( |
| 173 const SessionStateCallback& callback) override; | 179 const SessionStateCallback& callback) override; |
| 174 | 180 |
| 175 // Creates a binding between this object and |request|. | 181 // Creates a binding between this object and |request|. |
| 176 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); | 182 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); |
| 177 | 183 |
| 178 // mojo::ErrorHandler override. | 184 // mojo::ErrorHandler override. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 int next_request_session_id_; | 268 int next_request_session_id_; |
| 263 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; | 269 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; |
| 264 | 270 |
| 265 // RAII binding of |this| to an Presentation interface request. | 271 // RAII binding of |this| to an Presentation interface request. |
| 266 // The binding is removed when binding_ is cleared or goes out of scope. | 272 // The binding is removed when binding_ is cleared or goes out of scope. |
| 267 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; | 273 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; |
| 268 | 274 |
| 269 // NOTE: Weak pointers must be invalidated before all other member variables. | 275 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 270 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 276 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 271 | 277 |
| 278 // There could be be one send message request at a time. |
| 279 scoped_ptr<SendMessageMojoCallback> send_message_cb_ptr_; |
| 280 |
| 272 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 281 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 273 }; | 282 }; |
| 274 | 283 |
| 275 } // namespace content | 284 } // namespace content |
| 276 | 285 |
| 277 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 286 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |