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

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

Issue 2355723004: [Presentation API] 1-UA: send message between controller and receiver page (Closed)
Patch Set: Merge with changes in Issue 2343013002 Created 4 years, 2 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>
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 delegate_->SetDefaultPresentationUrls( 396 delegate_->SetDefaultPresentationUrls(
397 render_process_id_, render_frame_id_, presentation_urls_for_delegate, 397 render_process_id_, render_frame_id_, presentation_urls_for_delegate,
398 base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted, 398 base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted,
399 weak_factory_.GetWeakPtr())); 399 weak_factory_.GetWeakPtr()));
400 } 400 }
401 401
402 void PresentationServiceImpl::SendSessionMessage( 402 void PresentationServiceImpl::SendSessionMessage(
403 blink::mojom::PresentationSessionInfoPtr session, 403 blink::mojom::PresentationSessionInfoPtr session,
404 blink::mojom::SessionMessagePtr session_message, 404 blink::mojom::SessionMessagePtr session_message,
405 const SendSessionMessageCallback& callback) { 405 const SendSessionMessageCallback& callback) {
406 DVLOG(2) << "SendSessionMessage"; 406 DVLOG(2) << "SendSessionMessage"
407 << " [url]: " << session->url << ", [id]: " << session->id
408 << ", [process id]: " << render_process_id_
409 << ", [render frame id]: " << render_frame_id_;
407 DCHECK(!session_message.is_null()); 410 DCHECK(!session_message.is_null());
408 // send_message_callback_ should be null by now, otherwise resetting of 411 // send_message_callback_ should be null by now, otherwise resetting of
409 // send_message_callback_ with new callback will drop the old callback. 412 // send_message_callback_ with new callback will drop the old callback.
410 if (!delegate_ || send_message_callback_) { 413 if (!delegate_ || send_message_callback_) {
411 callback.Run(false); 414 callback.Run(false);
412 return; 415 return;
413 } 416 }
414 417
418 for (auto message_observer : offscreen_presentation_observers_) {
419 ScopedVector<PresentationSessionMessage> messages;
420 messages.push_back(GetPresentationSessionMessage(session_message.Clone()));
421 message_observer->OnSessionMessages(session.To<PresentationSessionInfo>(),
422 messages, false);
423 }
424
415 send_message_callback_.reset(new SendSessionMessageCallback(callback)); 425 send_message_callback_.reset(new SendSessionMessageCallback(callback));
416 delegate_->SendMessage( 426 delegate_->SendMessage(
417 render_process_id_, render_frame_id_, 427 render_process_id_, render_frame_id_,
418 session.To<PresentationSessionInfo>(), 428 session.To<PresentationSessionInfo>(),
419 GetPresentationSessionMessage(std::move(session_message)), 429 GetPresentationSessionMessage(std::move(session_message)),
420 base::Bind(&PresentationServiceImpl::OnSendMessageCallback, 430 base::Bind(&PresentationServiceImpl::OnSendMessageCallback,
421 weak_factory_.GetWeakPtr())); 431 weak_factory_.GetWeakPtr()));
422 } 432 }
423 433
424 void PresentationServiceImpl::OnSendMessageCallback(bool sent) { 434 void PresentationServiceImpl::OnSendMessageCallback(bool sent) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 render_process_id_, render_frame_id_, session_info, 496 render_process_id_, render_frame_id_, session_info,
487 base::Bind(&PresentationServiceImpl::OnSessionMessages, 497 base::Bind(&PresentationServiceImpl::OnSessionMessages,
488 weak_factory_.GetWeakPtr(), session_info)); 498 weak_factory_.GetWeakPtr(), session_info));
489 } 499 }
490 500
491 void PresentationServiceImpl::OnSessionMessages( 501 void PresentationServiceImpl::OnSessionMessages(
492 const PresentationSessionInfo& session, 502 const PresentationSessionInfo& session,
493 const ScopedVector<PresentationSessionMessage>& messages, 503 const ScopedVector<PresentationSessionMessage>& messages,
494 bool pass_ownership) { 504 bool pass_ownership) {
495 DCHECK(client_); 505 DCHECK(client_);
496 506 DVLOG(2) << "OnSessionMessages"
497 DVLOG(2) << "OnSessionMessages"; 507 << " [url]: " << session.presentation_url
508 << ", [id]: " << session.presentation_id
509 << ", [process id]: " << render_process_id_
510 << ", [render frame id]: " << render_frame_id_;
498 std::vector<blink::mojom::SessionMessagePtr> mojo_messages(messages.size()); 511 std::vector<blink::mojom::SessionMessagePtr> mojo_messages(messages.size());
499 std::transform(messages.begin(), messages.end(), mojo_messages.begin(), 512 std::transform(messages.begin(), messages.end(), mojo_messages.begin(),
500 [pass_ownership](PresentationSessionMessage* message) { 513 [pass_ownership](PresentationSessionMessage* message) {
501 return ToMojoSessionMessage(message, pass_ownership); 514 return ToMojoSessionMessage(message, pass_ownership);
502 }); 515 });
503 516
504 client_->OnSessionMessagesReceived( 517 client_->OnSessionMessagesReceived(
505 blink::mojom::PresentationSessionInfo::From(session), 518 blink::mojom::PresentationSessionInfo::From(session),
506 std::move(mojo_messages)); 519 std::move(mojo_messages));
507 } 520 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 673
661 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( 674 void PresentationServiceImpl::NewSessionCallbackWrapper::Run(
662 blink::mojom::PresentationSessionInfoPtr session, 675 blink::mojom::PresentationSessionInfoPtr session,
663 blink::mojom::PresentationErrorPtr error) { 676 blink::mojom::PresentationErrorPtr error) {
664 DCHECK(!callback_.is_null()); 677 DCHECK(!callback_.is_null());
665 callback_.Run(std::move(session), std::move(error)); 678 callback_.Run(std::move(session), std::move(error));
666 callback_.Reset(); 679 callback_.Reset();
667 } 680 }
668 681
669 } // namespace content 682 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/presentation/presentation_service_impl.h ('k') | content/public/browser/presentation_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698