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

Unified Diff: android_webview/common/aw_message_port_messages.h

Issue 869133005: Post a Message from Java to JS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address mnaganov comments Created 5 years, 11 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/common/aw_message_port_messages.h
diff --git a/android_webview/common/aw_message_port_messages.h b/android_webview/common/aw_message_port_messages.h
index 866d713d1418feb805202c665bc38d1f86569887..be7c77ce7347987dd9911edff0fd58b2311a8180 100644
--- a/android_webview/common/aw_message_port_messages.h
+++ b/android_webview/common/aw_message_port_messages.h
@@ -14,10 +14,32 @@
// MessagePort messages
// These are messages sent from the browser to the renderer process.
-// Tells the renderer to convert the sent message from a WebSerializeScript
-// format to a base::ListValue. Due to the complexities of renderer/browser
-// relation, this can only be done in renderer for now.
-IPC_MESSAGE_ROUTED3(AwMessagePortMsg_Message,
+// Normally the postmessages are exchanged between the renderers and the message
+// itself is opaque to the browser process. The format of the message is a
+// WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure
+// and can only be serialized/deserialized in renderer. Further, we could not
+// have Blink or V8 on the browser side due to their relience on static
+// variables.
+//
+// For posting messages from Java (Webview) to JS, we pass the browser/renderer
+// boundary an extra time and convert the messages to a type that browser can
+// use. Since WebView is single-process this is not terribly expensive, but
+// if we can do the conversion at the browser, then we can drop this code.
+
+// Tells the renderer to convert the message from a WebSerializeScript
+// format to a base::ListValue. This IPC is used for messages that are
+// incoming to Android webview from JS.
+IPC_MESSAGE_ROUTED3(AwMessagePortMsg_WebToAppMessage,
+ int /* recipient message port id */,
+ base::string16 /* message */,
+ std::vector<int> /* sent message port_ids */)
+
+// Tells the renderer to convert the message from a String16
+// format to a WebSerializedScriptValue. This IPC is used for messages that
+// are outgoing from Webview to JS.
+// TODO(sgurun) when we start supporting other types, use a ListValue instead
+// of string16
+IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage,
int /* recipient message port id */,
base::string16 /* message */,
std::vector<int> /* sent message port_ids */)
@@ -25,8 +47,14 @@ IPC_MESSAGE_ROUTED3(AwMessagePortMsg_Message,
//-----------------------------------------------------------------------------
// These are messages sent from the renderer to the browser process.
-// Response to AwMessagePortMessage_ConvertMessage
-IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedMessage,
+// Response to AwMessagePortMessage_WebToAppMessage
+IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage,
int /* recipient message port id */,
base::ListValue /* converted message */,
std::vector<int> /* sent message port_ids */)
+
+// Response to AwMessagePortMessage_AppToWebMessage
+IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage,
+ int /* recipient message port id */,
+ base::string16 /* converted message */,
+ std::vector<int> /* sent message port_ids */)

Powered by Google App Engine
This is Rietveld 408576698