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

Side by Side Diff: android_webview/common/aw_message_port_messages.h

Issue 2375133002: Move MessagePort implementation from android_webview to content (Closed)
Patch Set: rsesek nits and git cl format 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Multiply-included file, no traditional include guard.
6 #include <vector>
7
8 #include "ipc/ipc_message_macros.h"
9
10 #define IPC_MESSAGE_START AwMessagePortMsgStart
11
12 //-----------------------------------------------------------------------------
13 // MessagePort messages
14 // These are messages sent from the browser to the renderer process.
15
16 // 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
18 // WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure
19 // 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
21 // variables.
22 //
23 // For posting messages from Java (Webview) to JS, we pass the browser/renderer
24 // boundary an extra time and convert the messages to a type that browser can
25 // use. Since WebView is single-process this is not terribly expensive, but
26 // if we can do the conversion at the browser, then we can drop this code.
27
28 // Important Note about multi-process situation: Webview is single process so
29 // 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
31 // can be different then the renderer that receives the message. There are
32 // 2 possible solutions to deal with this:
33 // 1. Do the conversion at the browser side by writing a new serializer
34 // deserializer for WebSerializedScriptValue
35 // 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
37 // 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
39 // renderer or browser delegate.
40
41
42 // Tells the renderer to convert the message from a WebSerializeScript
43 // format to a base::ListValue. This IPC is used for messages that are
44 // incoming to Android webview from JS.
45 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_WebToAppMessage,
46 int /* recipient message port id */,
47 base::string16 /* message */,
48 std::vector<int> /* sent message port_ids */)
49
50 // Tells the renderer to convert the message from a String16
51 // format to a WebSerializedScriptValue. This IPC is used for messages that
52 // are outgoing from Webview to JS.
53 // TODO(sgurun) when we start supporting other types, use a ListValue instead
54 // of string16
55 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage,
56 int /* recipient message port id */,
57 base::string16 /* message */,
58 std::vector<int> /* sent message port_ids */)
59
60 // Used to defer message port closing until after all in-flight messages
61 // are flushed from renderer to browser. Renderer piggy-backs the message
62 // to browser.
63 IPC_MESSAGE_ROUTED1(AwMessagePortMsg_ClosePort,
64 int /* message port id */)
65
66 //-----------------------------------------------------------------------------
67 // These are messages sent from the renderer to the browser process.
68
69 // Response to AwMessagePortMessage_WebToAppMessage
70 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage,
71 int /* recipient message port id */,
72 base::ListValue /* converted message */,
73 std::vector<int> /* sent message port_ids */)
74
75 // Response to AwMessagePortMessage_AppToWebMessage
76 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage,
77 int /* recipient message port id */,
78 base::string16 /* converted message */,
79 std::vector<int> /* sent message port_ids */)
80
81 // Response to AwMessagePortMsg_ClosePort
82 IPC_MESSAGE_ROUTED1(AwMessagePortHostMsg_ClosePortAck,
83 int /* message port id */)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698