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

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

Issue 1314413005: [Presentation API] 1-UA presentation support + presenter APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 <string> 10 #include <string>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 void PresentationServiceImpl::ListenForScreenAvailability( 181 void PresentationServiceImpl::ListenForScreenAvailability(
182 const mojo::String& url) { 182 const mojo::String& url) {
183 DVLOG(2) << "ListenForScreenAvailability " << url; 183 DVLOG(2) << "ListenForScreenAvailability " << url;
184 if (!delegate_) { 184 if (!delegate_) {
185 client_->OnScreenAvailabilityUpdated(url, false); 185 client_->OnScreenAvailabilityUpdated(url, false);
186 return; 186 return;
187 } 187 }
188 188
189 const std::string& availability_url = url.get(); 189 const std::string& availability_url = url.get();
190 if (screen_availability_listeners_.count(availability_url)) 190 if (ContainsKey(screen_availability_listeners_, availability_url))
191 return; 191 return;
192 192
193 std::unique_ptr<ScreenAvailabilityListenerImpl> listener( 193 std::unique_ptr<ScreenAvailabilityListenerImpl> listener(
194 new ScreenAvailabilityListenerImpl(availability_url, this)); 194 new ScreenAvailabilityListenerImpl(availability_url, this));
195 if (delegate_->AddScreenAvailabilityListener( 195 if (delegate_->AddScreenAvailabilityListener(
196 render_process_id_, 196 render_process_id_,
197 render_frame_id_, 197 render_frame_id_,
198 listener.get())) { 198 listener.get())) {
199 screen_availability_listeners_[availability_url] = std::move(listener); 199 screen_availability_listeners_[availability_url] = std::move(listener);
200 } else { 200 } else {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 if (!delegate_) 453 if (!delegate_)
454 return; 454 return;
455 455
456 PresentationSessionInfo session_info(session.To<PresentationSessionInfo>()); 456 PresentationSessionInfo session_info(session.To<PresentationSessionInfo>());
457 delegate_->ListenForSessionMessages( 457 delegate_->ListenForSessionMessages(
458 render_process_id_, render_frame_id_, session_info, 458 render_process_id_, render_frame_id_, session_info,
459 base::Bind(&PresentationServiceImpl::OnSessionMessages, 459 base::Bind(&PresentationServiceImpl::OnSessionMessages,
460 weak_factory_.GetWeakPtr(), session_info)); 460 weak_factory_.GetWeakPtr(), session_info));
461 } 461 }
462 462
463 void PresentationServiceImpl::GetReceiverConnections(
464 const PresentationConnectionListMojoCallback& callback) {
465 DCHECK(!callback.is_null());
466 DVLOG(2) << "GetPresentationReceiverSession";
467 if (!delegate_) {
468 callback.Run(mojo::Array<blink::mojom::PresentationSessionInfoPtr>());
469 return;
470 }
471
472 std::vector<PresentationSessionInfo> connections =
473 delegate_->GetReceiverConnections(
474 render_process_id_, render_frame_id_,
475 base::Bind(&PresentationServiceImpl::OnReceiverConnectionAvailable,
476 weak_factory_.GetWeakPtr()));
477 callback.Run(
478 mojo::Array<blink::mojom::PresentationSessionInfoPtr>::From(connections));
479 }
480
481 void PresentationServiceImpl::OnReceiverConnectionAvailable(
482 const content::PresentationSessionInfo& connection) {
483 DCHECK(client_);
484 client_->OnReceiverConnectionAvailable(
485 blink::mojom::PresentationSessionInfo::From(connection));
486 }
487
463 void PresentationServiceImpl::OnSessionMessages( 488 void PresentationServiceImpl::OnSessionMessages(
464 const PresentationSessionInfo& session, 489 const PresentationSessionInfo& session,
465 const ScopedVector<PresentationSessionMessage>& messages, 490 const ScopedVector<PresentationSessionMessage>& messages,
466 bool pass_ownership) { 491 bool pass_ownership) {
467 DCHECK(client_); 492 DCHECK(client_);
468 493
469 DVLOG(2) << "OnSessionMessages"; 494 DVLOG(2) << "OnSessionMessages";
470 mojo::Array<blink::mojom::SessionMessagePtr> mojoMessages(messages.size()); 495 mojo::Array<blink::mojom::SessionMessagePtr> mojoMessages(messages.size());
471 for (size_t i = 0; i < messages.size(); ++i) 496 for (size_t i = 0; i < messages.size(); ++i)
472 mojoMessages[i] = ToMojoSessionMessage(messages[i], pass_ownership); 497 mojoMessages[i] = ToMojoSessionMessage(messages[i], pass_ownership);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 628
604 void PresentationServiceImpl::NewSessionMojoCallbackWrapper::Run( 629 void PresentationServiceImpl::NewSessionMojoCallbackWrapper::Run(
605 blink::mojom::PresentationSessionInfoPtr session, 630 blink::mojom::PresentationSessionInfoPtr session,
606 blink::mojom::PresentationErrorPtr error) { 631 blink::mojom::PresentationErrorPtr error) {
607 DCHECK(!callback_.is_null()); 632 DCHECK(!callback_.is_null());
608 callback_.Run(std::move(session), std::move(error)); 633 callback_.Run(std::move(session), std::move(error));
609 callback_.reset(); 634 callback_.reset();
610 } 635 }
611 636
612 } // namespace content 637 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698