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

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

Issue 2613153003: [Presentation API] Replaces type converters with typemaps (Closed)
Patch Set: Add more OWNERS foo Created 3 years, 11 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
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 #include "content/browser/presentation/presentation_service_impl.h" 5 #include "content/browser/presentation/presentation_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "content/browser/presentation/presentation_type_converters.h"
15 #include "content/public/browser/content_browser_client.h" 14 #include "content/public/browser/content_browser_client.h"
16 #include "content/public/browser/navigation_details.h" 15 #include "content/public/browser/navigation_details.h"
17 #include "content/public/browser/render_frame_host.h" 16 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/content_client.h" 19 #include "content/public/common/content_client.h"
21 #include "content/public/common/frame_navigate_params.h" 20 #include "content/public/common/frame_navigate_params.h"
22 #include "content/public/common/presentation_connection_message.h" 21 #include "content/public/common/presentation_connection_message.h"
23 #include "content/public/common/presentation_constants.h" 22 #include "content/public/common/presentation_constants.h"
24 23
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return output; 99 return output;
101 } 100 }
102 } 101 }
103 102
104 NOTREACHED() << "Invalid presentation message type " << input->type; 103 NOTREACHED() << "Invalid presentation message type " << input->type;
105 return output; 104 return output;
106 } 105 }
107 106
108 void InvokeNewSessionCallbackWithError( 107 void InvokeNewSessionCallbackWithError(
109 const PresentationServiceImpl::NewSessionCallback& callback) { 108 const PresentationServiceImpl::NewSessionCallback& callback) {
110 callback.Run(blink::mojom::PresentationSessionInfoPtr(), 109 callback.Run(base::nullopt,
111 blink::mojom::PresentationError::From(PresentationError( 110 PresentationError(PRESENTATION_ERROR_UNKNOWN, "Internal error"));
112 PRESENTATION_ERROR_UNKNOWN, "Internal error")));
113 } 111 }
114 112
115 } // namespace 113 } // namespace
116 114
117 PresentationServiceImpl::PresentationServiceImpl( 115 PresentationServiceImpl::PresentationServiceImpl(
118 RenderFrameHost* render_frame_host, 116 RenderFrameHost* render_frame_host,
119 WebContents* web_contents, 117 WebContents* web_contents,
120 ControllerPresentationServiceDelegate* controller_delegate, 118 ControllerPresentationServiceDelegate* controller_delegate,
121 ReceiverPresentationServiceDelegate* receiver_delegate) 119 ReceiverPresentationServiceDelegate* receiver_delegate)
122 : WebContentsObserver(web_contents), 120 : WebContentsObserver(web_contents),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 controller_delegate_->RemoveScreenAvailabilityListener( 222 controller_delegate_->RemoveScreenAvailabilityListener(
225 render_process_id_, render_frame_id_, listener_it->second.get()); 223 render_process_id_, render_frame_id_, listener_it->second.get());
226 screen_availability_listeners_.erase(listener_it); 224 screen_availability_listeners_.erase(listener_it);
227 } 225 }
228 226
229 void PresentationServiceImpl::StartSession( 227 void PresentationServiceImpl::StartSession(
230 const std::vector<GURL>& presentation_urls, 228 const std::vector<GURL>& presentation_urls,
231 const NewSessionCallback& callback) { 229 const NewSessionCallback& callback) {
232 DVLOG(2) << "StartSession"; 230 DVLOG(2) << "StartSession";
233 if (!controller_delegate_) { 231 if (!controller_delegate_) {
234 callback.Run( 232 callback.Run(base::nullopt,
235 blink::mojom::PresentationSessionInfoPtr(), 233 PresentationError(PRESENTATION_ERROR_NO_AVAILABLE_SCREENS,
236 blink::mojom::PresentationError::From(PresentationError( 234 "No screens found."));
237 PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, "No screens found.")));
238 return; 235 return;
239 } 236 }
240 237
241 // There is a StartSession request in progress. To avoid queueing up 238 // There is a StartSession request in progress. To avoid queueing up
242 // requests, the incoming request is rejected. 239 // requests, the incoming request is rejected.
243 if (start_session_request_id_ != kInvalidRequestSessionId) { 240 if (start_session_request_id_ != kInvalidRequestSessionId) {
244 InvokeNewSessionCallbackWithError(callback); 241 InvokeNewSessionCallbackWithError(callback);
245 return; 242 return;
246 } 243 }
247 244
248 start_session_request_id_ = GetNextRequestSessionId(); 245 start_session_request_id_ = GetNextRequestSessionId();
249 pending_start_session_cb_.reset(new NewSessionCallbackWrapper(callback)); 246 pending_start_session_cb_.reset(new NewSessionCallbackWrapper(callback));
250 controller_delegate_->StartSession( 247 controller_delegate_->StartSession(
251 render_process_id_, render_frame_id_, presentation_urls, 248 render_process_id_, render_frame_id_, presentation_urls,
252 base::Bind(&PresentationServiceImpl::OnStartSessionSucceeded, 249 base::Bind(&PresentationServiceImpl::OnStartSessionSucceeded,
253 weak_factory_.GetWeakPtr(), start_session_request_id_), 250 weak_factory_.GetWeakPtr(), start_session_request_id_),
254 base::Bind(&PresentationServiceImpl::OnStartSessionError, 251 base::Bind(&PresentationServiceImpl::OnStartSessionError,
255 weak_factory_.GetWeakPtr(), start_session_request_id_)); 252 weak_factory_.GetWeakPtr(), start_session_request_id_));
256 } 253 }
257 254
258 void PresentationServiceImpl::JoinSession( 255 void PresentationServiceImpl::JoinSession(
259 const std::vector<GURL>& presentation_urls, 256 const std::vector<GURL>& presentation_urls,
260 const base::Optional<std::string>& presentation_id, 257 const base::Optional<std::string>& presentation_id,
261 const NewSessionCallback& callback) { 258 const NewSessionCallback& callback) {
262 DVLOG(2) << "JoinSession"; 259 DVLOG(2) << "JoinSession";
263 if (!controller_delegate_) { 260 if (!controller_delegate_) {
264 callback.Run(blink::mojom::PresentationSessionInfoPtr(), 261 callback.Run(base::nullopt,
265 blink::mojom::PresentationError::From(PresentationError( 262 PresentationError(PRESENTATION_ERROR_NO_PRESENTATION_FOUND,
266 PRESENTATION_ERROR_NO_PRESENTATION_FOUND, 263 "Error joining route: No matching route"));
267 "Error joining route: No matching route")));
268 return; 264 return;
269 } 265 }
270 266
271 int request_session_id = RegisterJoinSessionCallback(callback); 267 int request_session_id = RegisterJoinSessionCallback(callback);
272 if (request_session_id == kInvalidRequestSessionId) { 268 if (request_session_id == kInvalidRequestSessionId) {
273 InvokeNewSessionCallbackWithError(callback); 269 InvokeNewSessionCallbackWithError(callback);
274 return; 270 return;
275 } 271 }
276 controller_delegate_->JoinSession( 272 controller_delegate_->JoinSession(
277 render_process_id_, render_frame_id_, presentation_urls, 273 render_process_id_, render_frame_id_, presentation_urls,
(...skipping 28 matching lines...) Expand all
306 } 302 }
307 } 303 }
308 304
309 void PresentationServiceImpl::OnStartSessionSucceeded( 305 void PresentationServiceImpl::OnStartSessionSucceeded(
310 int request_session_id, 306 int request_session_id,
311 const PresentationSessionInfo& session_info) { 307 const PresentationSessionInfo& session_info) {
312 if (request_session_id != start_session_request_id_) 308 if (request_session_id != start_session_request_id_)
313 return; 309 return;
314 310
315 CHECK(pending_start_session_cb_.get()); 311 CHECK(pending_start_session_cb_.get());
316 pending_start_session_cb_->Run( 312 pending_start_session_cb_->Run(session_info, base::nullopt);
317 blink::mojom::PresentationSessionInfo::From(session_info),
318 blink::mojom::PresentationErrorPtr());
319 ListenForConnectionStateChangeAndChangeState(session_info); 313 ListenForConnectionStateChangeAndChangeState(session_info);
320 pending_start_session_cb_.reset(); 314 pending_start_session_cb_.reset();
321 start_session_request_id_ = kInvalidRequestSessionId; 315 start_session_request_id_ = kInvalidRequestSessionId;
322 } 316 }
323 317
324 void PresentationServiceImpl::OnStartSessionError( 318 void PresentationServiceImpl::OnStartSessionError(
325 int request_session_id, 319 int request_session_id,
326 const PresentationError& error) { 320 const PresentationError& error) {
327 if (request_session_id != start_session_request_id_) 321 if (request_session_id != start_session_request_id_)
328 return; 322 return;
329 323
330 CHECK(pending_start_session_cb_.get()); 324 CHECK(pending_start_session_cb_.get());
331 pending_start_session_cb_->Run(blink::mojom::PresentationSessionInfoPtr(), 325 pending_start_session_cb_->Run(base::nullopt, error);
332 blink::mojom::PresentationError::From(error));
333 pending_start_session_cb_.reset(); 326 pending_start_session_cb_.reset();
334 start_session_request_id_ = kInvalidRequestSessionId; 327 start_session_request_id_ = kInvalidRequestSessionId;
335 } 328 }
336 329
337 void PresentationServiceImpl::OnJoinSessionSucceeded( 330 void PresentationServiceImpl::OnJoinSessionSucceeded(
338 int request_session_id, 331 int request_session_id,
339 const PresentationSessionInfo& session_info) { 332 const PresentationSessionInfo& session_info) {
340 if (RunAndEraseJoinSessionMojoCallback( 333 if (RunAndEraseJoinSessionMojoCallback(request_session_id, session_info,
341 request_session_id, 334 base::nullopt)) {
342 blink::mojom::PresentationSessionInfo::From(session_info),
343 blink::mojom::PresentationErrorPtr())) {
344 ListenForConnectionStateChangeAndChangeState(session_info); 335 ListenForConnectionStateChangeAndChangeState(session_info);
345 } 336 }
346 } 337 }
347 338
348 void PresentationServiceImpl::OnJoinSessionError( 339 void PresentationServiceImpl::OnJoinSessionError(
349 int request_session_id, 340 int request_session_id,
350 const PresentationError& error) { 341 const PresentationError& error) {
351 RunAndEraseJoinSessionMojoCallback( 342 RunAndEraseJoinSessionMojoCallback(request_session_id, base::nullopt, error);
352 request_session_id, blink::mojom::PresentationSessionInfoPtr(),
353 blink::mojom::PresentationError::From(error));
354 } 343 }
355 344
356 bool PresentationServiceImpl::RunAndEraseJoinSessionMojoCallback( 345 bool PresentationServiceImpl::RunAndEraseJoinSessionMojoCallback(
357 int request_session_id, 346 int request_session_id,
358 blink::mojom::PresentationSessionInfoPtr session, 347 const base::Optional<PresentationSessionInfo>& session_info,
359 blink::mojom::PresentationErrorPtr error) { 348 const base::Optional<PresentationError>& error) {
360 auto it = pending_join_session_cbs_.find(request_session_id); 349 auto it = pending_join_session_cbs_.find(request_session_id);
361 if (it == pending_join_session_cbs_.end()) 350 if (it == pending_join_session_cbs_.end())
362 return false; 351 return false;
363 352
364 DCHECK(it->second.get()); 353 DCHECK(it->second.get());
365 it->second->Run(std::move(session), std::move(error)); 354 it->second->Run(session_info, error);
366 pending_join_session_cbs_.erase(it); 355 pending_join_session_cbs_.erase(it);
367 return true; 356 return true;
368 } 357 }
369 358
370 void PresentationServiceImpl::SetDefaultPresentationUrls( 359 void PresentationServiceImpl::SetDefaultPresentationUrls(
371 const std::vector<GURL>& presentation_urls) { 360 const std::vector<GURL>& presentation_urls) {
372 DVLOG(2) << "SetDefaultPresentationUrls"; 361 DVLOG(2) << "SetDefaultPresentationUrls";
373 if (!controller_delegate_) 362 if (!controller_delegate_)
374 return; 363 return;
375 364
376 if (default_presentation_urls_ == presentation_urls) 365 if (default_presentation_urls_ == presentation_urls)
377 return; 366 return;
378 367
379 default_presentation_urls_ = presentation_urls; 368 default_presentation_urls_ = presentation_urls;
380 controller_delegate_->SetDefaultPresentationUrls( 369 controller_delegate_->SetDefaultPresentationUrls(
381 render_process_id_, render_frame_id_, presentation_urls, 370 render_process_id_, render_frame_id_, presentation_urls,
382 base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted, 371 base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted,
383 weak_factory_.GetWeakPtr())); 372 weak_factory_.GetWeakPtr()));
384 } 373 }
385 374
386 void PresentationServiceImpl::SendConnectionMessage( 375 void PresentationServiceImpl::SendConnectionMessage(
387 blink::mojom::PresentationSessionInfoPtr session, 376 const PresentationSessionInfo& session_info,
388 blink::mojom::ConnectionMessagePtr connection_message, 377 blink::mojom::ConnectionMessagePtr connection_message,
389 const SendConnectionMessageCallback& callback) { 378 const SendConnectionMessageCallback& callback) {
390 DVLOG(2) << "SendConnectionMessage" 379 DVLOG(2) << "SendConnectionMessage [id]: " << session_info.presentation_id;
391 << " [id]: " << session->id;
392 DCHECK(!connection_message.is_null()); 380 DCHECK(!connection_message.is_null());
393 // send_message_callback_ should be null by now, otherwise resetting of 381 // send_message_callback_ should be null by now, otherwise resetting of
394 // send_message_callback_ with new callback will drop the old callback. 382 // send_message_callback_ with new callback will drop the old callback.
395 if (!controller_delegate_ || send_message_callback_) { 383 if (!controller_delegate_ || send_message_callback_) {
396 callback.Run(false); 384 callback.Run(false);
397 return; 385 return;
398 } 386 }
399 387
400 send_message_callback_.reset(new SendConnectionMessageCallback(callback)); 388 send_message_callback_.reset(new SendConnectionMessageCallback(callback));
401 controller_delegate_->SendMessage( 389 controller_delegate_->SendMessage(
402 render_process_id_, render_frame_id_, 390 render_process_id_, render_frame_id_, session_info,
403 session.To<PresentationSessionInfo>(),
404 GetPresentationConnectionMessage(std::move(connection_message)), 391 GetPresentationConnectionMessage(std::move(connection_message)),
405 base::Bind(&PresentationServiceImpl::OnSendMessageCallback, 392 base::Bind(&PresentationServiceImpl::OnSendMessageCallback,
406 weak_factory_.GetWeakPtr())); 393 weak_factory_.GetWeakPtr()));
407 } 394 }
408 395
409 void PresentationServiceImpl::OnSendMessageCallback(bool sent) { 396 void PresentationServiceImpl::OnSendMessageCallback(bool sent) {
410 // It is possible that Reset() is invoked before receiving this callback. 397 // It is possible that Reset() is invoked before receiving this callback.
411 // So, always check send_message_callback_ for non-null. 398 // So, always check send_message_callback_ for non-null.
412 if (send_message_callback_) { 399 if (send_message_callback_) {
413 send_message_callback_->Run(sent); 400 send_message_callback_->Run(sent);
(...skipping 19 matching lines...) Expand all
433 } 420 }
434 421
435 void PresentationServiceImpl::OnConnectionStateChanged( 422 void PresentationServiceImpl::OnConnectionStateChanged(
436 const PresentationSessionInfo& connection, 423 const PresentationSessionInfo& connection,
437 const PresentationConnectionStateChangeInfo& info) { 424 const PresentationConnectionStateChangeInfo& info) {
438 DVLOG(2) << "PresentationServiceImpl::OnConnectionStateChanged " 425 DVLOG(2) << "PresentationServiceImpl::OnConnectionStateChanged "
439 << "[presentation_id]: " << connection.presentation_id 426 << "[presentation_id]: " << connection.presentation_id
440 << " [state]: " << info.state; 427 << " [state]: " << info.state;
441 DCHECK(client_.get()); 428 DCHECK(client_.get());
442 if (info.state == PRESENTATION_CONNECTION_STATE_CLOSED) { 429 if (info.state == PRESENTATION_CONNECTION_STATE_CLOSED) {
443 client_->OnConnectionClosed( 430 client_->OnConnectionClosed(connection, info.close_reason, info.message);
444 blink::mojom::PresentationSessionInfo::From(connection),
445 content::PresentationConnectionCloseReasonToMojo(info.close_reason),
446 info.message);
447 } else { 431 } else {
448 client_->OnConnectionStateChanged( 432 client_->OnConnectionStateChanged(connection, info.state);
449 blink::mojom::PresentationSessionInfo::From(connection),
450 PresentationConnectionStateToMojo(info.state));
451 } 433 }
452 } 434 }
453 435
454 bool PresentationServiceImpl::FrameMatches( 436 bool PresentationServiceImpl::FrameMatches(
455 content::RenderFrameHost* render_frame_host) const { 437 content::RenderFrameHost* render_frame_host) const {
456 if (!render_frame_host) 438 if (!render_frame_host)
457 return false; 439 return false;
458 440
459 return render_frame_host->GetProcess()->GetID() == render_process_id_ && 441 return render_frame_host->GetProcess()->GetID() == render_process_id_ &&
460 render_frame_host->GetRoutingID() == render_frame_id_; 442 render_frame_host->GetRoutingID() == render_frame_id_;
461 } 443 }
462 444
463 PresentationServiceDelegate* 445 PresentationServiceDelegate*
464 PresentationServiceImpl::GetPresentationServiceDelegate() { 446 PresentationServiceImpl::GetPresentationServiceDelegate() {
465 return receiver_delegate_ 447 return receiver_delegate_
466 ? static_cast<PresentationServiceDelegate*>(receiver_delegate_) 448 ? static_cast<PresentationServiceDelegate*>(receiver_delegate_)
467 : static_cast<PresentationServiceDelegate*>(controller_delegate_); 449 : static_cast<PresentationServiceDelegate*>(controller_delegate_);
468 } 450 }
469 451
470 void PresentationServiceImpl::ListenForConnectionMessages( 452 void PresentationServiceImpl::ListenForConnectionMessages(
471 blink::mojom::PresentationSessionInfoPtr session) { 453 const PresentationSessionInfo& session_info) {
472 DVLOG(2) << "ListenForConnectionMessages"; 454 DVLOG(2) << "ListenForConnectionMessages";
473 if (!controller_delegate_) 455 if (!controller_delegate_)
474 return; 456 return;
475 457
476 PresentationSessionInfo session_info(session.To<PresentationSessionInfo>());
477 controller_delegate_->ListenForConnectionMessages( 458 controller_delegate_->ListenForConnectionMessages(
478 render_process_id_, render_frame_id_, session_info, 459 render_process_id_, render_frame_id_, session_info,
479 base::Bind(&PresentationServiceImpl::OnConnectionMessages, 460 base::Bind(&PresentationServiceImpl::OnConnectionMessages,
480 weak_factory_.GetWeakPtr(), session_info)); 461 weak_factory_.GetWeakPtr(), session_info));
481 } 462 }
482 463
483 void PresentationServiceImpl::SetPresentationConnection( 464 void PresentationServiceImpl::SetPresentationConnection(
484 blink::mojom::PresentationSessionInfoPtr session, 465 const PresentationSessionInfo& session_info,
485 blink::mojom::PresentationConnectionPtr controller_connection_ptr, 466 blink::mojom::PresentationConnectionPtr controller_connection_ptr,
486 blink::mojom::PresentationConnectionRequest receiver_connection_request) { 467 blink::mojom::PresentationConnectionRequest receiver_connection_request) {
487 DVLOG(2) << "SetPresentationConnection"; 468 DVLOG(2) << "SetPresentationConnection";
488 469
489 if (!controller_delegate_) 470 if (!controller_delegate_)
490 return; 471 return;
491 472
492 PresentationSessionInfo session_info(session.To<PresentationSessionInfo>());
493 controller_delegate_->ConnectToOffscreenPresentation( 473 controller_delegate_->ConnectToOffscreenPresentation(
494 render_process_id_, render_frame_id_, session_info, 474 render_process_id_, render_frame_id_, session_info,
495 std::move(controller_connection_ptr), 475 std::move(controller_connection_ptr),
496 std::move(receiver_connection_request)); 476 std::move(receiver_connection_request));
497 } 477 }
498 478
499 void PresentationServiceImpl::OnConnectionMessages( 479 void PresentationServiceImpl::OnConnectionMessages(
500 const PresentationSessionInfo& session, 480 const PresentationSessionInfo& session_info,
501 const std::vector<std::unique_ptr<PresentationConnectionMessage>>& messages, 481 const std::vector<std::unique_ptr<PresentationConnectionMessage>>& messages,
502 bool pass_ownership) { 482 bool pass_ownership) {
503 DCHECK(client_); 483 DCHECK(client_);
504 484
505 DVLOG(2) << "OnConnectionMessages" 485 DVLOG(2) << "OnConnectionMessages [id]: " << session_info.presentation_id;
506 << " [id]: " << session.presentation_id;
507 std::vector<blink::mojom::ConnectionMessagePtr> mojo_messages( 486 std::vector<blink::mojom::ConnectionMessagePtr> mojo_messages(
508 messages.size()); 487 messages.size());
509 std::transform( 488 std::transform(
510 messages.begin(), messages.end(), mojo_messages.begin(), 489 messages.begin(), messages.end(), mojo_messages.begin(),
511 [pass_ownership]( 490 [pass_ownership](
512 const std::unique_ptr<PresentationConnectionMessage>& message) { 491 const std::unique_ptr<PresentationConnectionMessage>& message) {
513 return ToMojoConnectionMessage(message.get(), pass_ownership); 492 return ToMojoConnectionMessage(message.get(), pass_ownership);
514 }); 493 });
515 494
516 client_->OnConnectionMessagesReceived( 495 client_->OnConnectionMessagesReceived(session_info, std::move(mojo_messages));
517 blink::mojom::PresentationSessionInfo::From(session),
518 std::move(mojo_messages));
519 } 496 }
520 497
521 void PresentationServiceImpl::OnReceiverConnectionAvailable( 498 void PresentationServiceImpl::OnReceiverConnectionAvailable(
522 const content::PresentationSessionInfo& session_info, 499 const content::PresentationSessionInfo& session_info,
523 PresentationConnectionPtr controller_connection_ptr, 500 PresentationConnectionPtr controller_connection_ptr,
524 PresentationConnectionRequest receiver_connection_request) { 501 PresentationConnectionRequest receiver_connection_request) {
525 DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable"; 502 DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable";
526 503
527 client_->OnReceiverConnectionAvailable( 504 client_->OnReceiverConnectionAvailable(
528 blink::mojom::PresentationSessionInfo::From(session_info), 505 session_info, std::move(controller_connection_ptr),
529 std::move(controller_connection_ptr),
530 std::move(receiver_connection_request)); 506 std::move(receiver_connection_request));
531 } 507 }
532 508
533 void PresentationServiceImpl::DidNavigateAnyFrame( 509 void PresentationServiceImpl::DidNavigateAnyFrame(
534 content::RenderFrameHost* render_frame_host, 510 content::RenderFrameHost* render_frame_host,
535 const content::LoadCommittedDetails& details, 511 const content::LoadCommittedDetails& details,
536 const content::FrameNavigateParams& params) { 512 const content::FrameNavigateParams& params) {
537 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame"; 513 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame";
538 if (!FrameMatches(render_frame_host)) 514 if (!FrameMatches(render_frame_host))
539 return; 515 return;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 void PresentationServiceImpl::OnDelegateDestroyed() { 581 void PresentationServiceImpl::OnDelegateDestroyed() {
606 DVLOG(2) << "PresentationServiceImpl::OnDelegateDestroyed"; 582 DVLOG(2) << "PresentationServiceImpl::OnDelegateDestroyed";
607 controller_delegate_ = nullptr; 583 controller_delegate_ = nullptr;
608 receiver_delegate_ = nullptr; 584 receiver_delegate_ = nullptr;
609 Reset(); 585 Reset();
610 } 586 }
611 587
612 void PresentationServiceImpl::OnDefaultPresentationStarted( 588 void PresentationServiceImpl::OnDefaultPresentationStarted(
613 const PresentationSessionInfo& connection) { 589 const PresentationSessionInfo& connection) {
614 DCHECK(client_.get()); 590 DCHECK(client_.get());
615 client_->OnDefaultSessionStarted( 591 client_->OnDefaultSessionStarted(connection);
616 blink::mojom::PresentationSessionInfo::From(connection));
617 ListenForConnectionStateChangeAndChangeState(connection); 592 ListenForConnectionStateChangeAndChangeState(connection);
618 } 593 }
619 594
620 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: 595 PresentationServiceImpl::ScreenAvailabilityListenerImpl::
621 ScreenAvailabilityListenerImpl(const GURL& availability_url, 596 ScreenAvailabilityListenerImpl(const GURL& availability_url,
622 PresentationServiceImpl* service) 597 PresentationServiceImpl* service)
623 : availability_url_(availability_url), service_(service) { 598 : availability_url_(availability_url), service_(service) {
624 DCHECK(service_); 599 DCHECK(service_);
625 DCHECK(service_->client_.get()); 600 DCHECK(service_->client_.get());
626 } 601 }
(...skipping 22 matching lines...) Expand all
649 : callback_(callback) { 624 : callback_(callback) {
650 } 625 }
651 626
652 PresentationServiceImpl::NewSessionCallbackWrapper 627 PresentationServiceImpl::NewSessionCallbackWrapper
653 ::~NewSessionCallbackWrapper() { 628 ::~NewSessionCallbackWrapper() {
654 if (!callback_.is_null()) 629 if (!callback_.is_null())
655 InvokeNewSessionCallbackWithError(callback_); 630 InvokeNewSessionCallbackWithError(callback_);
656 } 631 }
657 632
658 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( 633 void PresentationServiceImpl::NewSessionCallbackWrapper::Run(
659 blink::mojom::PresentationSessionInfoPtr session, 634 const base::Optional<PresentationSessionInfo>& session_info,
660 blink::mojom::PresentationErrorPtr error) { 635 const base::Optional<PresentationError>& error) {
661 DCHECK(!callback_.is_null()); 636 DCHECK(!callback_.is_null());
662 callback_.Run(std::move(session), std::move(error)); 637 callback_.Run(session_info, error);
663 callback_.Reset(); 638 callback_.Reset();
664 } 639 }
665 640
666 } // namespace content 641 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698