OLD | NEW |
| (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 "content/common/content_export.h" | |
9 #include "ipc/ipc_message_macros.h" | |
10 | |
11 #undef IPC_MESSAGE_EXPORT | |
12 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | |
13 #define IPC_MESSAGE_START AwMessagePortMsgStart | |
14 | |
15 //----------------------------------------------------------------------------- | |
16 // MessagePort messages | |
17 // These are messages sent from the browser to the renderer process. | |
18 | |
19 // Normally the postmessages are exchanged between the renderers and the message | |
20 // itself is opaque to the browser process. The format of the message is a | |
21 // WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure | |
22 // and can only be serialized/deserialized in renderer. Further, we could not | |
23 // have Blink or V8 on the browser side due to their relience on static | |
24 // variables. | |
25 // | |
26 // For posting messages from Java (Android apps) to JS, we pass the | |
27 // browser/renderer boundary an extra time and convert the messages to a type | |
28 // that browser can use. Within the current implementation specificications, | |
29 // where we use the main frame on the browser side and it always stays within | |
30 // the same process this is not expensive, but if we can do the conversion at | |
31 // the browser, then we can drop this code. | |
32 | |
33 // Important Note about multi-process situation: In a multi-process scenario, | |
34 // the renderer that does the conversion can be theoretically different then the | |
35 // renderer that receives the message. Although in the current implementation | |
36 // this doesn't become an issue, there are 2 possible solutions to deal with | |
37 // this and make the overall system more robust to future changes: | |
38 // 1. Do the conversion at the browser side by writing a new serializer | |
39 // deserializer for WebSerializedScriptValue | |
40 // 2. Do the conversion at the content layer, at the renderer at the time of | |
41 // receiving the message. This may need adding new flags to indicate that | |
42 // message needs to be converted. However, this is complicated due to queing | |
43 // at the browser side and possibility of ports being shipped to a different | |
44 // renderer or browser delegate. | |
45 | |
46 // Tells the renderer to convert the message from a WebSerializeScript | |
47 // format to a base::ListValue. This IPC is used for messages that are | |
48 // incoming to Android apps from JS. | |
49 IPC_MESSAGE_ROUTED3(AppWebMessagePortMsg_WebToAppMessage, | |
50 int /* recipient message port id */, | |
51 base::string16 /* message */, | |
52 std::vector<int> /* sent message port_ids */) | |
53 | |
54 // Tells the renderer to convert the message from a String16 | |
55 // format to a WebSerializedScriptValue. This IPC is used for messages that | |
56 // are outgoing from Android apps to JS. | |
57 // TODO(sgurun) when we start supporting other types, use a ListValue instead | |
58 // of string16 | |
59 IPC_MESSAGE_ROUTED3(AppWebMessagePortMsg_AppToWebMessage, | |
60 int /* recipient message port id */, | |
61 base::string16 /* message */, | |
62 std::vector<int> /* sent message port_ids */) | |
63 | |
64 // Used to defer message port closing until after all in-flight messages | |
65 // are flushed from renderer to browser. Renderer piggy-backs the message | |
66 // to browser. | |
67 IPC_MESSAGE_ROUTED1(AppWebMessagePortMsg_ClosePort, int /* message port id */) | |
68 | |
69 //----------------------------------------------------------------------------- | |
70 // These are messages sent from the renderer to the browser process. | |
71 | |
72 // Response to AppWebMessagePortMessage_WebToAppMessage | |
73 IPC_MESSAGE_ROUTED3(AppWebMessagePortHostMsg_ConvertedWebToAppMessage, | |
74 int /* recipient message port id */, | |
75 base::ListValue /* converted message */, | |
76 std::vector<int> /* sent message port_ids */) | |
77 | |
78 // Response to AppWebMessagePortMessage_AppToWebMessage | |
79 IPC_MESSAGE_ROUTED3(AppWebMessagePortHostMsg_ConvertedAppToWebMessage, | |
80 int /* recipient message port id */, | |
81 base::string16 /* converted message */, | |
82 std::vector<int> /* sent message port_ids */) | |
83 | |
84 // Response to AppWebMessagePortMsg_ClosePort | |
85 IPC_MESSAGE_ROUTED1(AppWebMessagePortHostMsg_ClosePortAck, | |
86 int /* message port id */) | |
OLD | NEW |