Chromium Code Reviews| Index: content/browser/presentation/presentation_service_impl.cc |
| diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc |
| index 900d186b1f50d6c7723a55a93982fcffa2fda26c..27a2ad143b03dd13bbb7d1db8d72da5c53ec1a93 100644 |
| --- a/content/browser/presentation/presentation_service_impl.cc |
| +++ b/content/browser/presentation/presentation_service_impl.cc |
| @@ -144,6 +144,8 @@ PresentationServiceImpl::PresentationServiceImpl( |
| } |
| PresentationServiceImpl::~PresentationServiceImpl() { |
| + DVLOG(2) << "~PresentationServiceImpl: " << render_process_id_ << ", " |
| + << render_frame_id_; |
| if (delegate_) |
| delegate_->RemoveObserver(render_process_id_, render_frame_id_); |
| } |
| @@ -178,6 +180,14 @@ void PresentationServiceImpl::SetClient( |
| DCHECK(!client_.get()); |
| // TODO(imcheng): Set ErrorHandler to listen for errors. |
| client_ = std::move(client); |
| + |
| + if (delegate_) { |
|
imcheng
2016/09/28 07:28:37
1) We might as well call these in the PSImpl const
zhaobin
2016/09/29 17:20:44
1) RegisterReceiverAvailableCallback() invokes dis
|
| + delegate_->RegisterReceiverAvailableCallback( |
| + base::Bind(&PresentationServiceImpl::OnReceiverConnectionAvailable, |
| + weak_factory_.GetWeakPtr())); |
| + delegate_->RegisterOffscreenPresentationClient(render_process_id_, |
| + render_frame_id_, this); |
| + } |
| } |
| void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) { |
| @@ -427,6 +437,10 @@ void PresentationServiceImpl::CloseConnection( |
| if (delegate_) |
| delegate_->CloseConnection(render_process_id_, render_frame_id_, |
| presentation_id); |
| + |
| + for (const auto& iter : offscreen_presentation_observers_) |
|
imcheng
2016/09/28 07:28:37
This probably doesn't make sense until we have ext
zhaobin
2016/09/29 17:20:44
code removed in new patch
|
| + iter->RemoveOffscreenPresentationClient(this); |
| + offscreen_presentation_observers_.clear(); |
| } |
| void PresentationServiceImpl::Terminate(const GURL& presentation_url, |
| @@ -492,6 +506,27 @@ void PresentationServiceImpl::OnSessionMessages( |
| std::move(mojo_messages)); |
| } |
| +void PresentationServiceImpl::OnReceiverConnectionAvailable( |
| + const content::PresentationSessionInfo& session_info, |
| + OffscreenPresentationClient* controller) { |
| + DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable"; |
| + client_->OnReceiverConnectionAvailable( |
| + blink::mojom::PresentationSessionInfo::From(session_info)); |
| + |
| + controller->SetOffscreenPresentationClient(this); |
| + this->SetOffscreenPresentationClient(controller); |
| +} |
| + |
| +void PresentationServiceImpl::SetOffscreenPresentationClient( |
| + OffscreenPresentationClient* client) { |
| + offscreen_presentation_observers_.insert(client); |
| +} |
| + |
| +void PresentationServiceImpl::RemoveOffscreenPresentationClient( |
| + OffscreenPresentationClient* client) { |
| + offscreen_presentation_observers_.erase(client); |
| +} |
| + |
| void PresentationServiceImpl::DidNavigateAnyFrame( |
| content::RenderFrameHost* render_frame_host, |
| const content::LoadCommittedDetails& details, |
| @@ -561,6 +596,11 @@ void PresentationServiceImpl::Reset() { |
| send_message_callback_->Run(false); |
| send_message_callback_.reset(); |
| } |
| + |
| + for (const auto& iter : offscreen_presentation_observers_) |
| + iter->RemoveOffscreenPresentationClient(this); |
| + |
| + offscreen_presentation_observers_.clear(); |
| } |
| void PresentationServiceImpl::OnDelegateDestroyed() { |