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

Unified Diff: content/browser/presentation/presentation_service_impl.cc

Issue 2343013002: [Presentation API] (MR side) 1-UA: notify receiver page when receiver connection becomes available (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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..af19f9a6b5d7c8cf35474410722a2021a5470cc1 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,12 @@ void PresentationServiceImpl::SetClient(
DCHECK(!client_.get());
// TODO(imcheng): Set ErrorHandler to listen for errors.
client_ = std::move(client);
+
+ // It will invoke onReceiverConnectionAvailable callback
+ // on receiver frame (associated with ReceiverPSDImpl);
+ // It does nothing on controller frame.
+ if (delegate_)
+ delegate_->RegisterOffscreenPresentationReceiver(this);
imcheng 2016/09/19 23:01:17 I have a few concerns with this approach: 1) We a
zhaobin 2016/09/23 17:18:18 Acknowledged.
}
void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) {
@@ -319,6 +327,10 @@ void PresentationServiceImpl::OnStartSessionSucceeded(
ListenForConnectionStateChange(session_info);
pending_start_session_cb_.reset();
start_session_request_id_ = kInvalidRequestSessionId;
+
+ if (delegate_)
+ delegate_->RegisterOffscreenPresentationController(
+ session_info.presentation_id, this);
}
void PresentationServiceImpl::OnStartSessionError(
@@ -424,9 +436,11 @@ void PresentationServiceImpl::CloseConnection(
const GURL& presentation_url,
const std::string& presentation_id) {
DVLOG(2) << "CloseConnection " << presentation_id;
- if (delegate_)
+ if (delegate_) {
delegate_->CloseConnection(render_process_id_, render_frame_id_,
presentation_id);
+ delegate_->UnregisterOffscreenPresentationController(presentation_id, this);
+ }
}
void PresentationServiceImpl::Terminate(const GURL& presentation_url,
@@ -492,6 +506,23 @@ void PresentationServiceImpl::OnSessionMessages(
std::move(mojo_messages));
}
+void PresentationServiceImpl::OnReceiverConnectionAvailable(
+ const content::PresentationSessionInfo& session_info) {
+ DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable";
+ client_->OnReceiverConnectionAvailable(
+ blink::mojom::PresentationSessionInfo::From(session_info));
+}
+
+void PresentationServiceImpl::AddOffscreenPresentationObserver(
+ OffscreenPresentationClient* client) {
+ offscreen_presentation_observers_.insert(client);
+}
+
+void PresentationServiceImpl::RemoveOffscreenPresentationObserver(
+ OffscreenPresentationClient* client) {
+ offscreen_presentation_observers_.erase(client);
+}
+
void PresentationServiceImpl::DidNavigateAnyFrame(
content::RenderFrameHost* render_frame_host,
const content::LoadCommittedDetails& details,
@@ -537,8 +568,10 @@ void PresentationServiceImpl::WebContentsDestroyed() {
void PresentationServiceImpl::Reset() {
DVLOG(2) << "PresentationServiceImpl::Reset";
- if (delegate_)
+ if (delegate_) {
delegate_->Reset(render_process_id_, render_frame_id_);
+ delegate_->UnregisterOffscreenPresentationReceiver(this);
+ }
default_presentation_urls_.clear();

Powered by Google App Engine
This is Rietveld 408576698