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

Unified 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: Created 5 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 539097ca10385e045a5fa04deaeb296bcddd4f07..8ee159d64f7357663699d010952a1a9be4595533 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -202,7 +202,8 @@ void PresentationServiceImpl::ListenForScreenAvailability(
listener.get())) {
screen_availability_listeners_.set(availability_url, listener.Pass());
} else {
- DVLOG(1) << "AddScreenAvailabilityListener failed. Ignoring request.";
+ DVLOG(1) << "AddScreenAvailabilityListener failed. Returning false.";
+ client_->OnScreenAvailabilityUpdated(url, false);
}
}
@@ -457,6 +458,47 @@ void PresentationServiceImpl::ListenForSessionMessages(
weak_factory_.GetWeakPtr(), session_info));
}
+void PresentationServiceImpl::GetPresentationReceiverSession(
+ const GetPresentationReceiverSessionMojoCallback& callback) {
+ DVLOG(2) << "GetPresentationReceiverSession";
+ if (!delegate_) {
+ callback.Run(presentation::PresentationSessionInfoPtr());
+ return;
+ }
+
+ presenter_session_callback_.reset(
+ new GetPresentationReceiverSessionMojoCallback(callback));
+ delegate_->GetPresentationReceiverSession(
+ render_process_id_, render_frame_id_,
+ base::Bind(
+ &PresentationServiceImpl::OnGetPresentationReceiverSessionSuccess,
+ weak_factory_.GetWeakPtr()),
+ base::Bind(
+ &PresentationServiceImpl::OnGetPresentationReceiverSessionError,
+ weak_factory_.GetWeakPtr()));
+}
+
+void PresentationServiceImpl::OnGetPresentationReceiverSessionSuccess(
+ const content::PresentationSessionInfo& session_info) {
+ DVLOG(2) << "OnGetPresentationReceiverSessionSuccess: "
+ << session_info.presentation_id;
+ if (presenter_session_callback_) {
+ presenter_session_callback_->Run(
+ presentation::PresentationSessionInfo::From(session_info));
+ presenter_session_callback_.reset();
+ }
+}
+
+void PresentationServiceImpl::OnGetPresentationReceiverSessionError(
+ const std::string& error) {
+ DVLOG(2) << __FUNCTION__ << ", error: " << error;
+ if (presenter_session_callback_) {
+ presenter_session_callback_->Run(
+ presentation::PresentationSessionInfoPtr());
+ presenter_session_callback_.reset();
+ }
+}
+
void PresentationServiceImpl::OnSessionMessages(
const PresentationSessionInfo& session,
const ScopedVector<PresentationSessionMessage>& messages,
@@ -525,7 +567,7 @@ void PresentationServiceImpl::Reset() {
default_session_start_context_.reset();
- if (on_session_messages_callback_.get()) {
+ if (on_session_messages_callback_) {
on_session_messages_callback_->Run(
mojo::Array<presentation::SessionMessagePtr>());
on_session_messages_callback_.reset();
@@ -537,6 +579,8 @@ void PresentationServiceImpl::Reset() {
send_message_callback_->Run(false);
send_message_callback_.reset();
}
+
+ presenter_session_callback_.reset();
}
void PresentationServiceImpl::OnDelegateDestroyed() {

Powered by Google App Engine
This is Rietveld 408576698