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

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: Extended SendStringMessage() to delegate, Added unit test & other fixes. 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 9e2fd22e9c8c59971ce8f898b92864e220704a2e..20228c3537979cad9baad461dac9880e680cacee 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -300,6 +300,33 @@ void PresentationServiceImpl::SetDefaultPresentationURL(
DoSetDefaultPresentationUrl(new_default_url, default_presentation_id);
}
+void PresentationServiceImpl::SendStringMessage(
+ const mojo::String& presentation_url,
+ const mojo::String& presentation_id,
+ const mojo::String& message,
+ const SendMessageMojoCallback& callback) {
+ if (!delegate_) {
+ callback.Run();
+ return;
+ }
+ // Save the callback and run it after request completion by delegate_.
+ send_message_cb_ptr_.reset(new SendMessageMojoCallback(callback));
imcheng 2015/04/14 21:29:13 Given that incoming SendStringMessage requests are
USE s.singapati at gmail.com 2015/04/15 16:09:08 Acknowledged. Yes, I also had almost same question
USE s.singapati at gmail.com 2015/04/16 11:14:15 Also, if callback is invoked immediately after cal
+ delegate_->SendStringMessage(
+ render_frame_host_->GetProcess()->GetID(),
+ render_frame_host_->GetRoutingID(),
+ presentation_url,
+ presentation_id,
+ message,
+ base::Bind(&PresentationServiceImpl::OnSendMessageCallback,
+ weak_factory_.GetWeakPtr()));
+}
+
+void PresentationServiceImpl::OnSendMessageCallback() {
+ DCHECK(send_message_cb_ptr_);
+ send_message_cb_ptr_->Run();
+ send_message_cb_ptr_.reset();
+}
+
void PresentationServiceImpl::CloseSession(
const mojo::String& presentation_url,
const mojo::String& presentation_id) {
@@ -373,6 +400,13 @@ void PresentationServiceImpl::Reset() {
InvokeNewSessionMojoCallbackWithError(*pending_entry.second);
}
pending_session_cbs_.clear();
+
+ if (send_message_cb_ptr_) {
+ // Running the callback might result in the PresentationDispatcher sending
+ // the next message. So, just reset the callback since the frame is being
+ // closed anyways.
+ send_message_cb_ptr_.reset();
imcheng 2015/04/14 21:29:13 It cannot simply be reset since it will DCHECK per
USE s.singapati at gmail.com 2015/04/15 16:09:08 Acknowledged. - Then it must run the callback for
+ }
}
void PresentationServiceImpl::InvokeNewSessionMojoCallbackWithError(

Powered by Google App Engine
This is Rietveld 408576698