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

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

Issue 1037483003: [PresentationAPI] Implementing send() from WebPresentationClient to the PresentationService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved presentation_message.h/.cc to content/public/browser/ Created 5 years, 8 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 e22e9149eb2e86ce40775bb7405deac5c7bfea83..34d315b8662088752b76e3bbf83d8a728efc5448 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -313,6 +313,39 @@ void PresentationServiceImpl::SetDefaultPresentationURL(
DoSetDefaultPresentationUrl(new_default_url, default_presentation_id);
}
+void PresentationServiceImpl::SendMessage(
+ presentation::SessionMessagePtr message_request,
+ const SendMessageMojoCallback& callback) {
+ DVLOG(2) << "SendMessage";
+ DCHECK(!message_request.is_null());
+ if (!delegate_) {
+ callback.Run(true);
whywhat 2015/04/30 15:50:58 nit: did you want to Run(false) here?
USE s.singapati at gmail.com 2015/05/01 10:30:25 Yes.
USE s.singapati at gmail.com 2015/05/04 16:40:28 Done.
+ return;
+ }
+
+ // send_message_cb_ptr_ should be null by now.
+ DCHECK(!send_message_cb_ptr_);
imcheng (use chromium acct) 2015/04/30 20:11:29 instead of DCHECKing and/or dropping the old callb
USE s.singapati at gmail.com 2015/05/04 16:40:28 Done.
+ send_message_cb_ptr_.reset(new SendMessageMojoCallback(callback));
+
+ delegate_->SendMessage(
+ render_process_id_,
+ render_frame_id_,
+ new PresentationMessageRequest(
+ message_request->presentation_url,
+ message_request->presentation_id,
+ static_cast<PresentationMessageType>(message_request->type),
whywhat 2015/04/30 15:50:58 nit: it'd be safer to have a static function that
imcheng (use chromium acct) 2015/04/30 20:11:29 To add to what Anton said, I think it would be goo
USE s.singapati at gmail.com 2015/05/04 16:40:28 Done for PresentationMessageType conversion. Need
USE s.singapati at gmail.com 2015/05/05 14:26:36 Done.
+ message_request->message,
+ message_request->data),
+ base::Bind(&PresentationServiceImpl::OnSendMessageCallback,
+ weak_factory_.GetWeakPtr()));
+}
+
+void PresentationServiceImpl::OnSendMessageCallback() {
+ DCHECK(send_message_cb_ptr_);
imcheng (use chromium acct) 2015/04/30 20:11:29 Hmm, Reset() could have occurred between SendMessa
USE s.singapati at gmail.com 2015/05/04 16:40:27 Done.
+ send_message_cb_ptr_->Run(true);
+ send_message_cb_ptr_.reset();
+}
+
void PresentationServiceImpl::CloseSession(
const mojo::String& presentation_url,
const mojo::String& presentation_id) {
@@ -383,6 +416,12 @@ void PresentationServiceImpl::Reset() {
queued_start_session_requests_.clear();
FlushNewSessionCallbacks();
default_session_start_context_.reset();
+ if (send_message_cb_ptr_) {
+ // Run the callback with false, indicating the renderer to stop sending
+ // the requests and invalidate all pending requests.
+ send_message_cb_ptr_->Run(false);
+ send_message_cb_ptr_.reset();
+ }
}
// static

Powered by Google App Engine
This is Rietveld 408576698