Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: content/browser/presentation/presentation_service_impl.h

Issue 1037483003: [PresentationAPI] Implementing send() from WebPresentationClient to the PresentationService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No (c) in new files Copyright message. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 using NewSessionMojoCallback = 60 using NewSessionMojoCallback =
61 mojo::Callback<void(presentation::PresentationSessionInfoPtr, 61 mojo::Callback<void(presentation::PresentationSessionInfoPtr,
62 presentation::PresentationErrorPtr)>; 62 presentation::PresentationErrorPtr)>;
63 using DefaultSessionMojoCallback = 63 using DefaultSessionMojoCallback =
64 mojo::Callback<void(presentation::PresentationSessionInfoPtr)>; 64 mojo::Callback<void(presentation::PresentationSessionInfoPtr)>;
65 using SessionStateCallback = 65 using SessionStateCallback =
66 mojo::Callback<void(presentation::PresentationSessionInfoPtr, 66 mojo::Callback<void(presentation::PresentationSessionInfoPtr,
67 presentation::PresentationSessionState)>; 67 presentation::PresentationSessionState)>;
68 using SessionMessagesCallback = 68 using SessionMessagesCallback =
69 mojo::Callback<void(mojo::Array<presentation::SessionMessagePtr>)>; 69 mojo::Callback<void(mojo::Array<presentation::SessionMessagePtr>)>;
70 using SendMessageMojoCallback = mojo::Callback<void(bool)>;
70 71
71 // A helper data class used by PresentationServiceImpl to do bookkeeping 72 // A helper data class used by PresentationServiceImpl to do bookkeeping
72 // of currently registered screen availability listeners. 73 // of currently registered screen availability listeners.
73 // An instance of this class is a simple state machine that waits for both 74 // An instance of this class is a simple state machine that waits for both
74 // the available bit and the Mojo callback to become available. 75 // the available bit and the Mojo callback to become available.
75 // Once this happens, the Mojo callback will be invoked with the available 76 // Once this happens, the Mojo callback will be invoked with the available
76 // bit, and the state machine will reset. 77 // bit, and the state machine will reset.
77 // The available bit is obtained from the embedder's media router. 78 // The available bit is obtained from the embedder's media router.
78 // The callback is obtained from the renderer via PresentationServiceImpl's 79 // The callback is obtained from the renderer via PresentationServiceImpl's
79 // ListenForScreenAvailability(). 80 // ListenForScreenAvailability().
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void ListenForDefaultSessionStart( 201 void ListenForDefaultSessionStart(
201 const DefaultSessionMojoCallback& callback) override; 202 const DefaultSessionMojoCallback& callback) override;
202 void StartSession( 203 void StartSession(
203 const mojo::String& presentation_url, 204 const mojo::String& presentation_url,
204 const mojo::String& presentation_id, 205 const mojo::String& presentation_id,
205 const NewSessionMojoCallback& callback) override; 206 const NewSessionMojoCallback& callback) override;
206 void JoinSession( 207 void JoinSession(
207 const mojo::String& presentation_url, 208 const mojo::String& presentation_url,
208 const mojo::String& presentation_id, 209 const mojo::String& presentation_id,
209 const NewSessionMojoCallback& callback) override; 210 const NewSessionMojoCallback& callback) override;
211 void SendSessionMessage(
212 presentation::SessionMessagePtr session_message,
213 const SendMessageMojoCallback& callback) override;
210 void CloseSession( 214 void CloseSession(
211 const mojo::String& presentation_url, 215 const mojo::String& presentation_url,
212 const mojo::String& presentation_id) override; 216 const mojo::String& presentation_id) override;
213 void ListenForSessionStateChange( 217 void ListenForSessionStateChange(
214 const SessionStateCallback& callback) override; 218 const SessionStateCallback& callback) override;
215 void ListenForSessionMessages( 219 void ListenForSessionMessages(
216 const SessionMessagesCallback& callback) override; 220 const SessionMessagesCallback& callback) override;
217 221
218 // Creates a binding between this object and |request|. 222 // Creates a binding between this object and |request|.
219 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); 223 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request);
(...skipping 25 matching lines...) Expand all
245 // Sets |default_presentation_url_| to |presentation_url| and informs the 249 // Sets |default_presentation_url_| to |presentation_url| and informs the
246 // delegate of new default presentation URL and ID. 250 // delegate of new default presentation URL and ID.
247 void DoSetDefaultPresentationUrl( 251 void DoSetDefaultPresentationUrl(
248 const std::string& presentation_url, 252 const std::string& presentation_url,
249 const std::string& presentation_id); 253 const std::string& presentation_id);
250 254
251 // Removes all listeners and resets default presentation URL on this instance 255 // Removes all listeners and resets default presentation URL on this instance
252 // and informs the PresentationServiceDelegate of such. 256 // and informs the PresentationServiceDelegate of such.
253 void Reset(); 257 void Reset();
254 258
255 // These two functions are bound as base::Callbacks and passed to 259 // These functions are bound as base::Callbacks and passed to
256 // embedder's implementation of PresentationServiceDelegate for later 260 // embedder's implementation of PresentationServiceDelegate for later
257 // invocation. 261 // invocation.
258 void OnStartOrJoinSessionSucceeded( 262 void OnStartOrJoinSessionSucceeded(
259 bool is_start_session, 263 bool is_start_session,
260 int request_session_id, 264 int request_session_id,
261 const PresentationSessionInfo& session_info); 265 const PresentationSessionInfo& session_info);
262 void OnStartOrJoinSessionError( 266 void OnStartOrJoinSessionError(
263 bool is_start_session, 267 bool is_start_session,
264 int request_session_id, 268 int request_session_id,
265 const PresentationError& error); 269 const PresentationError& error);
270 void OnSendMessageCallback();
266 271
267 // Requests delegate to start a session. 272 // Requests delegate to start a session.
268 void DoStartSession( 273 void DoStartSession(
269 const std::string& presentation_url, 274 const std::string& presentation_url,
270 const std::string& presentation_id, 275 const std::string& presentation_id,
271 const NewSessionMojoCallback& callback); 276 const NewSessionMojoCallback& callback);
272 277
273 // Passed to embedder's implementation of PresentationServiceDelegate for 278 // Passed to embedder's implementation of PresentationServiceDelegate for
274 // later invocation when session messages arrive. 279 // later invocation when session messages arrive.
275 // For optimization purposes, this method will empty the messages 280 // For optimization purposes, this method will empty the messages
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 326
322 int next_request_session_id_; 327 int next_request_session_id_;
323 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; 328 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_;
324 329
325 scoped_ptr<DefaultSessionStartContext> default_session_start_context_; 330 scoped_ptr<DefaultSessionStartContext> default_session_start_context_;
326 331
327 // RAII binding of |this| to an Presentation interface request. 332 // RAII binding of |this| to an Presentation interface request.
328 // The binding is removed when binding_ is cleared or goes out of scope. 333 // The binding is removed when binding_ is cleared or goes out of scope.
329 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; 334 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_;
330 335
336 // There can be only one send message request at a time.
337 scoped_ptr<SendMessageMojoCallback> send_message_callback_;
338
331 scoped_ptr<SessionMessagesCallback> on_session_messages_callback_; 339 scoped_ptr<SessionMessagesCallback> on_session_messages_callback_;
332 340
333 // ID of the RenderFrameHost this object is associated with. 341 // ID of the RenderFrameHost this object is associated with.
334 int render_process_id_; 342 int render_process_id_;
335 int render_frame_id_; 343 int render_frame_id_;
336 344
337 // NOTE: Weak pointers must be invalidated before all other member variables. 345 // NOTE: Weak pointers must be invalidated before all other member variables.
338 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; 346 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_;
339 347
340 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); 348 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl);
341 }; 349 };
342 350
343 } // namespace content 351 } // namespace content
344 352
345 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ 353 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698