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

Unified Diff: android_webview/native/aw_message_port_service_impl.cc

Issue 956763002: Implement the close() API for Message ports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Nasko review Created 5 years, 10 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: android_webview/native/aw_message_port_service_impl.cc
diff --git a/android_webview/native/aw_message_port_service_impl.cc b/android_webview/native/aw_message_port_service_impl.cc
index d2e1fa44614c9b559c8d0a39de0458992a31c121..b4bf2ca61f9108a96bc05e59288ba6d0c600480f 100644
--- a/android_webview/native/aw_message_port_service_impl.cc
+++ b/android_webview/native/aw_message_port_service_impl.cc
@@ -135,6 +135,21 @@ void AwMessagePortServiceImpl::PostAppToWebMessage(JNIEnv* env, jobject obj,
base::Owned(j_sent_ports)));
}
+// The message port service cannot immediately close the port, because
+// it is possible that messages are still queued in the renderer process
+// waiting for a conversion. Instead, it sends a special message with
+// a flag which indicates that this message port should be closed.
+void AwMessagePortServiceImpl::ClosePort(JNIEnv* env, jobject obj,
+ int message_port_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&AwMessagePortServiceImpl::PostClosePortMessage,
+ base::Unretained(this),
+ message_port_id));
+}
+
void AwMessagePortServiceImpl::RemoveSentPorts(
const std::vector<int>& sent_ports) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -151,6 +166,15 @@ void AwMessagePortServiceImpl::PostAppToWebMessageOnIOThread(
ports_[sender_id]->SendAppToWebMessage(sender_id, *message, *sent_ports);
}
+void AwMessagePortServiceImpl::PostClosePortMessage(int message_port_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ ports_[message_port_id]->SendClosePortMessage(message_port_id);
+}
+
+void AwMessagePortServiceImpl::CleanupPort(int message_port_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ ports_.erase(message_port_id);
+}
void AwMessagePortServiceImpl::CreateMessageChannelOnIOThread(
scoped_refptr<AwMessagePortMessageFilter> filter,
« no previous file with comments | « android_webview/native/aw_message_port_service_impl.h ('k') | android_webview/renderer/aw_message_port_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698