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

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: added a test 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..c3ff3216e0a76ddb0e7323460d8d7d713ce17e1b 100644
--- a/android_webview/common/aw_message_port_messages.h
+++ b/android_webview/common/aw_message_port_messages.h
@@ -14,10 +14,29 @@
// 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.
mnaganov (inactive) 2015/01/27 13:30:17 You may mention that we couldn't have Blink or V8
sgurun-gerrit only 2015/01/29 03:06:08 Done.
+// 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
mnaganov (inactive) 2015/01/27 13:30:17 I would argue with this statement. Using IPC takes
sgurun-gerrit only 2015/01/29 03:06:08 Acknowledged. I am planning to add some perf tests
+// 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_InMessage,
mnaganov (inactive) 2015/01/27 13:30:17 The terms "In" and "Out" doesn't clearly mark the
sgurun-gerrit only 2015/01/29 03:06:08 Done.
+ 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_OutMessage,
int /* recipient message port id */,
base::string16 /* message */,
std::vector<int> /* sent message port_ids */)
@@ -25,8 +44,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_InMessage
+IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedInMessage,
int /* recipient message port id */,
base::ListValue /* converted message */,
std::vector<int> /* sent message port_ids */)
+
+// Response to AwMessagePortMessage_OutMessage
+IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedOutMessage,
+ 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