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

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

Issue 2958663002: [MediaRouter] PresentationServiceDelegateImpl cleanup. (Closed)
Patch Set: rebase Created 3 years, 5 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 | « chrome/browser/media/router/presentation_service_delegate_impl.cc ('k') | no next file » | 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 #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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 if (receiver_delegate_ && is_main_frame_) { 119 if (receiver_delegate_ && is_main_frame_) {
120 receiver_delegate_->RegisterReceiverConnectionAvailableCallback( 120 receiver_delegate_->RegisterReceiverConnectionAvailableCallback(
121 base::Bind(&PresentationServiceImpl::OnReceiverConnectionAvailable, 121 base::Bind(&PresentationServiceImpl::OnReceiverConnectionAvailable,
122 weak_factory_.GetWeakPtr())); 122 weak_factory_.GetWeakPtr()));
123 } 123 }
124 } 124 }
125 125
126 void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) { 126 void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) {
127 DVLOG(2) << "ListenForScreenAvailability " << url.spec(); 127 DVLOG(2) << "ListenForScreenAvailability " << url.spec();
128 if (!controller_delegate_) { 128 if (!controller_delegate_ || !url.is_valid()) {
129 client_->OnScreenAvailabilityUpdated( 129 client_->OnScreenAvailabilityUpdated(
130 url, blink::mojom::ScreenAvailability::UNAVAILABLE); 130 url, blink::mojom::ScreenAvailability::UNAVAILABLE);
131 return; 131 return;
132 } 132 }
133 133
134 if (screen_availability_listeners_.count(url)) 134 if (screen_availability_listeners_.count(url))
135 return; 135 return;
136 136
137 std::unique_ptr<ScreenAvailabilityListenerImpl> listener( 137 std::unique_ptr<ScreenAvailabilityListenerImpl> listener(
138 new ScreenAvailabilityListenerImpl(url, this)); 138 new ScreenAvailabilityListenerImpl(url, this));
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 const PresentationInfo& connection) { 457 const PresentationInfo& connection) {
458 DCHECK(client_.get()); 458 DCHECK(client_.get());
459 client_->OnDefaultPresentationStarted(connection); 459 client_->OnDefaultPresentationStarted(connection);
460 ListenForConnectionStateChange(connection); 460 ListenForConnectionStateChange(connection);
461 } 461 }
462 462
463 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: 463 PresentationServiceImpl::ScreenAvailabilityListenerImpl::
464 ScreenAvailabilityListenerImpl(const GURL& availability_url, 464 ScreenAvailabilityListenerImpl(const GURL& availability_url,
465 PresentationServiceImpl* service) 465 PresentationServiceImpl* service)
466 : availability_url_(availability_url), service_(service) { 466 : availability_url_(availability_url), service_(service) {
467 DCHECK(availability_url_.is_valid());
467 DCHECK(service_); 468 DCHECK(service_);
468 DCHECK(service_->client_.get()); 469 DCHECK(service_->client_.get());
469 } 470 }
470 471
471 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: 472 PresentationServiceImpl::ScreenAvailabilityListenerImpl::
472 ~ScreenAvailabilityListenerImpl() { 473 ~ScreenAvailabilityListenerImpl() = default;
473 }
474 474
475 GURL PresentationServiceImpl::ScreenAvailabilityListenerImpl:: 475 GURL PresentationServiceImpl::ScreenAvailabilityListenerImpl::
476 GetAvailabilityUrl() const { 476 GetAvailabilityUrl() const {
477 return availability_url_; 477 return availability_url_;
478 } 478 }
479 479
480 void PresentationServiceImpl::ScreenAvailabilityListenerImpl:: 480 void PresentationServiceImpl::ScreenAvailabilityListenerImpl::
481 OnScreenAvailabilityChanged(blink::mojom::ScreenAvailability availability) { 481 OnScreenAvailabilityChanged(blink::mojom::ScreenAvailability availability) {
482 service_->client_->OnScreenAvailabilityUpdated(availability_url_, 482 service_->client_->OnScreenAvailabilityUpdated(availability_url_,
483 availability); 483 availability);
(...skipping 10 matching lines...) Expand all
494 } 494 }
495 495
496 void PresentationServiceImpl::NewPresentationCallbackWrapper::Run( 496 void PresentationServiceImpl::NewPresentationCallbackWrapper::Run(
497 const base::Optional<PresentationInfo>& presentation_info, 497 const base::Optional<PresentationInfo>& presentation_info,
498 const base::Optional<PresentationError>& error) { 498 const base::Optional<PresentationError>& error) {
499 DCHECK(!callback_.is_null()); 499 DCHECK(!callback_.is_null());
500 std::move(callback_).Run(presentation_info, error); 500 std::move(callback_).Run(presentation_info, error);
501 } 501 }
502 502
503 } // namespace content 503 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/media/router/presentation_service_delegate_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698