| 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 SendMessage( |
| 171 presentation::MessageRequestPtr message_request, |
| 172 const SendMessageMojoCallback& callback) override; |
| 169 void CloseSession( | 173 void CloseSession( |
| 170 const mojo::String& presentation_url, | 174 const mojo::String& presentation_url, |
| 171 const mojo::String& presentation_id) override; | 175 const mojo::String& presentation_id) override; |
| 172 void ListenForSessionStateChange( | 176 void ListenForSessionStateChange( |
| 173 const SessionStateCallback& callback) override; | 177 const SessionStateCallback& callback) override; |
| 174 | 178 |
| 175 // Creates a binding between this object and |request|. | 179 // Creates a binding between this object and |request|. |
| 176 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); | 180 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); |
| 177 | 181 |
| 178 // mojo::ErrorHandler override. | 182 // mojo::ErrorHandler override. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 200 // Sets |default_presentation_url_| to |presentation_url| and informs the | 204 // Sets |default_presentation_url_| to |presentation_url| and informs the |
| 201 // delegate of new default presentation URL and ID. | 205 // delegate of new default presentation URL and ID. |
| 202 void DoSetDefaultPresentationUrl( | 206 void DoSetDefaultPresentationUrl( |
| 203 const std::string& presentation_url, | 207 const std::string& presentation_url, |
| 204 const std::string& presentation_id); | 208 const std::string& presentation_id); |
| 205 | 209 |
| 206 // Removes all listeners and resets default presentation URL on this instance | 210 // Removes all listeners and resets default presentation URL on this instance |
| 207 // and informs the PresentationServiceDelegate of such. | 211 // and informs the PresentationServiceDelegate of such. |
| 208 void Reset(); | 212 void Reset(); |
| 209 | 213 |
| 210 // These two functions are bound as base::Callbacks and passed to | 214 // These functions are bound as base::Callbacks and passed to |
| 211 // embedder's implementation of PresentationServiceDelegate for later | 215 // embedder's implementation of PresentationServiceDelegate for later |
| 212 // invocation. | 216 // invocation. |
| 213 void OnStartOrJoinSessionSucceeded( | 217 void OnStartOrJoinSessionSucceeded( |
| 214 bool is_start_session, | 218 bool is_start_session, |
| 215 int request_session_id, | 219 int request_session_id, |
| 216 const PresentationSessionInfo& session_info); | 220 const PresentationSessionInfo& session_info); |
| 217 void OnStartOrJoinSessionError( | 221 void OnStartOrJoinSessionError( |
| 218 bool is_start_session, | 222 bool is_start_session, |
| 219 int request_session_id, | 223 int request_session_id, |
| 220 const PresentationError& error); | 224 const PresentationError& error); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 272 |
| 269 // NOTE: Weak pointers must be invalidated before all other member variables. | 273 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 270 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 274 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 271 | 275 |
| 272 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 276 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 273 }; | 277 }; |
| 274 | 278 |
| 275 } // namespace content | 279 } // namespace content |
| 276 | 280 |
| 277 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 281 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |