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

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

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: resolve code review comments from Mark Created 4 years, 2 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..deefe7ddc827f2470e37872a5a3dced095eaefa3 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_ << ", "
mark a. foltz 2016/10/08 00:33:42 __FUNCTION__ as is done elsewhere in this patch?
zhaobin 2016/10/12 02:27:33 Done.
+ << 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);
+
+ if (delegate_) {
+ delegate_->RegisterReceiverAvailableCallback(
+ base::Bind(&PresentationServiceImpl::OnReceiverConnectionAvailable,
+ weak_factory_.GetWeakPtr()));
+ }
}
void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) {
@@ -393,7 +401,10 @@ void PresentationServiceImpl::SendSessionMessage(
blink::mojom::PresentationSessionInfoPtr session,
blink::mojom::SessionMessagePtr session_message,
const SendSessionMessageCallback& callback) {
- DVLOG(2) << "SendSessionMessage";
+ DVLOG(2) << "SendSessionMessage"
+ << " [url]: " << session->url << ", [id]: " << session->id
+ << ", [process id]: " << render_process_id_
+ << ", [render frame id]: " << render_frame_id_;
DCHECK(!session_message.is_null());
// send_message_callback_ should be null by now, otherwise resetting of
// send_message_callback_ with new callback will drop the old callback.
@@ -474,13 +485,30 @@ void PresentationServiceImpl::ListenForSessionMessages(
weak_factory_.GetWeakPtr(), session_info));
}
+void PresentationServiceImpl::SetPresentationConnection(
+ blink::mojom::PresentationSessionInfoPtr session,
+ blink::mojom::PresentationConnectionPtr connection) {
+ DVLOG(2) << "SetPresentationConnection";
+
+ if (!delegate_)
+ return;
+
+ PresentationSessionInfo session_info(session.To<PresentationSessionInfo>());
+ delegate_->RegisterOffscreenPresentationConnection(
+ render_process_id_, render_frame_id_, session_info,
+ std::move(connection));
+}
+
void PresentationServiceImpl::OnSessionMessages(
const PresentationSessionInfo& session,
const ScopedVector<PresentationSessionMessage>& messages,
bool pass_ownership) {
DCHECK(client_);
-
- DVLOG(2) << "OnSessionMessages";
+ DVLOG(2) << "OnSessionMessages"
+ << " [url]: " << session.presentation_url
+ << ", [id]: " << session.presentation_id
+ << ", [process id]: " << render_process_id_
+ << ", [render frame id]: " << render_frame_id_;
std::vector<blink::mojom::SessionMessagePtr> mojo_messages(messages.size());
std::transform(messages.begin(), messages.end(), mojo_messages.begin(),
[pass_ownership](PresentationSessionMessage* message) {
@@ -492,6 +520,17 @@ void PresentationServiceImpl::OnSessionMessages(
std::move(mojo_messages));
}
+void PresentationServiceImpl::OnReceiverConnectionAvailable(
+ const content::PresentationSessionInfo& session_info,
+ PresentationConnectionPtr&& controller) {
+ DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable";
+ DVLOG(2) << "controller: " << controller;
+
+ client_->OnReceiverConnectionAvailable(
+ blink::mojom::PresentationSessionInfo::From(session_info),
+ std::move(controller));
+}
+
void PresentationServiceImpl::DidNavigateAnyFrame(
content::RenderFrameHost* render_frame_host,
const content::LoadCommittedDetails& details,

Powered by Google App Engine
This is Rietveld 408576698