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

Side by Side Diff: content/common/app_web_message_port_messages.h

Issue 2375133002: Move MessagePort implementation from android_webview to content (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Multiply-included file, no traditional include guard. 5 // Multiply-included file, no traditional include guard.
6 #include <vector> 6 #include <vector>
7 7
8 #include "content/common/content_export.h"
8 #include "ipc/ipc_message_macros.h" 9 #include "ipc/ipc_message_macros.h"
9 10
11 #undef IPC_MESSAGE_EXPORT
12 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
10 #define IPC_MESSAGE_START AwMessagePortMsgStart 13 #define IPC_MESSAGE_START AwMessagePortMsgStart
11 14
12 //----------------------------------------------------------------------------- 15 //-----------------------------------------------------------------------------
13 // MessagePort messages 16 // MessagePort messages
14 // These are messages sent from the browser to the renderer process. 17 // These are messages sent from the browser to the renderer process.
15 18
16 // Normally the postmessages are exchanged between the renderers and the message 19 // Normally the postmessages are exchanged between the renderers and the message
17 // itself is opaque to the browser process. The format of the message is a 20 // itself is opaque to the browser process. The format of the message is a
18 // WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure 21 // WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure
19 // and can only be serialized/deserialized in renderer. Further, we could not 22 // and can only be serialized/deserialized in renderer. Further, we could not
20 // have Blink or V8 on the browser side due to their relience on static 23 // have Blink or V8 on the browser side due to their relience on static
21 // variables. 24 // variables.
22 // 25 //
23 // For posting messages from Java (Webview) to JS, we pass the browser/renderer 26 // For posting messages from Java (Android apps) to JS, we pass the
24 // boundary an extra time and convert the messages to a type that browser can 27 // browser/renderer boundary an extra time and convert the messages to a type
25 // use. Since WebView is single-process this is not terribly expensive, but 28 // that browser can use. Since WebView is single-process this is not terribly
sgurun-gerrit only 2016/09/30 23:40:59 this statement feels like needs clarification as c
Yusuf 2016/10/04 21:33:14 Done.
26 // if we can do the conversion at the browser, then we can drop this code. 29 // expensive, but if we can do the conversion at the browser, then we can drop
30 // this code.
27 31
28 // Important Note about multi-process situation: Webview is single process so 32 // Important Note about multi-process situation: Webview is single process so
sgurun-gerrit only 2016/09/30 23:40:59 this badly feels more context: after moving to CCT
Yusuf 2016/10/04 21:33:14 I tried to reinterpret the issue through rephrasin
29 // such a conversion does not increase the risk due to untrusted renderers. 33 // such a conversion does not increase the risk due to untrusted renderers.
30 // However, in a multi-process scenario, the renderer that does the conversion 34 // However, in a multi-process scenario, the renderer that does the conversion
31 // can be different then the renderer that receives the message. There are 35 // can be different then the renderer that receives the message. There are
32 // 2 possible solutions to deal with this: 36 // 2 possible solutions to deal with this:
33 // 1. Do the conversion at the browser side by writing a new serializer 37 // 1. Do the conversion at the browser side by writing a new serializer
34 // deserializer for WebSerializedScriptValue 38 // deserializer for WebSerializedScriptValue
35 // 2. Do the conversion at the content layer, at the renderer at the time of 39 // 2. Do the conversion at the content layer, at the renderer at the time of
36 // receiveing the message. This may need adding new flags to indicate that 40 // receiving the message. This may need adding new flags to indicate that
37 // message needs to be converted. However, this is complicated due to queing 41 // message needs to be converted. However, this is complicated due to queing
38 // at the browser side and possibility of ports being shipped to a different 42 // at the browser side and possibility of ports being shipped to a different
39 // renderer or browser delegate. 43 // renderer or browser delegate.
40 44
41 45
42 // Tells the renderer to convert the message from a WebSerializeScript 46 // Tells the renderer to convert the message from a WebSerializeScript
43 // format to a base::ListValue. This IPC is used for messages that are 47 // format to a base::ListValue. This IPC is used for messages that are
44 // incoming to Android webview from JS. 48 // incoming to Android apps from JS.
45 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_WebToAppMessage, 49 IPC_MESSAGE_ROUTED3(AppWebMessagePortMsg_WebToAppMessage,
46 int /* recipient message port id */, 50 int /* recipient message port id */,
47 base::string16 /* message */, 51 base::string16 /* message */,
48 std::vector<int> /* sent message port_ids */) 52 std::vector<int> /* sent message port_ids */)
49 53
50 // Tells the renderer to convert the message from a String16 54 // Tells the renderer to convert the message from a String16
51 // format to a WebSerializedScriptValue. This IPC is used for messages that 55 // format to a WebSerializedScriptValue. This IPC is used for messages that
52 // are outgoing from Webview to JS. 56 // are outgoing from Android apps to JS.
53 // TODO(sgurun) when we start supporting other types, use a ListValue instead 57 // TODO(sgurun) when we start supporting other types, use a ListValue instead
54 // of string16 58 // of string16
55 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage, 59 IPC_MESSAGE_ROUTED3(AppWebMessagePortMsg_AppToWebMessage,
56 int /* recipient message port id */, 60 int /* recipient message port id */,
57 base::string16 /* message */, 61 base::string16 /* message */,
58 std::vector<int> /* sent message port_ids */) 62 std::vector<int> /* sent message port_ids */)
59 63
60 // Used to defer message port closing until after all in-flight messages 64 // Used to defer message port closing until after all in-flight messages
61 // are flushed from renderer to browser. Renderer piggy-backs the message 65 // are flushed from renderer to browser. Renderer piggy-backs the message
62 // to browser. 66 // to browser.
63 IPC_MESSAGE_ROUTED1(AwMessagePortMsg_ClosePort, 67 IPC_MESSAGE_ROUTED1(AppWebMessagePortMsg_ClosePort,
64 int /* message port id */) 68 int /* message port id */)
65 69
66 //----------------------------------------------------------------------------- 70 //-----------------------------------------------------------------------------
67 // These are messages sent from the renderer to the browser process. 71 // These are messages sent from the renderer to the browser process.
68 72
69 // Response to AwMessagePortMessage_WebToAppMessage 73 // Response to AppWebMessagePortMessage_WebToAppMessage
70 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage, 74 IPC_MESSAGE_ROUTED3(AppWebMessagePortHostMsg_ConvertedWebToAppMessage,
71 int /* recipient message port id */, 75 int /* recipient message port id */,
72 base::ListValue /* converted message */, 76 base::ListValue /* converted message */,
73 std::vector<int> /* sent message port_ids */) 77 std::vector<int> /* sent message port_ids */)
74 78
75 // Response to AwMessagePortMessage_AppToWebMessage 79 // Response to AppWebMessagePortMessage_AppToWebMessage
76 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage, 80 IPC_MESSAGE_ROUTED3(AppWebMessagePortHostMsg_ConvertedAppToWebMessage,
77 int /* recipient message port id */, 81 int /* recipient message port id */,
78 base::string16 /* converted message */, 82 base::string16 /* converted message */,
79 std::vector<int> /* sent message port_ids */) 83 std::vector<int> /* sent message port_ids */)
80 84
81 // Response to AwMessagePortMsg_ClosePort 85 // Response to AppWebMessagePortMsg_ClosePort
82 IPC_MESSAGE_ROUTED1(AwMessagePortHostMsg_ClosePortAck, 86 IPC_MESSAGE_ROUTED1(AppWebMessagePortHostMsg_ClosePortAck,
83 int /* message port id */) 87 int /* message port id */)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698