OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Defines messages between the browser and worker process, as well as between | 5 // Defines messages between the browser and worker process, as well as between |
6 // the renderer and worker process. | 6 // the renderer and worker process. |
7 | 7 |
8 // Multiply-included message file, hence no include guard. | 8 // Multiply-included message file, hence no include guard. |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/common/message_port_types.h" | |
17 #include "ipc/ipc_message_macros.h" | 16 #include "ipc/ipc_message_macros.h" |
18 #include "ipc/ipc_message_utils.h" | 17 #include "ipc/ipc_message_utils.h" |
19 | 18 |
20 #undef IPC_MESSAGE_EXPORT | 19 #undef IPC_MESSAGE_EXPORT |
21 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | 20 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
22 #define IPC_MESSAGE_START MessagePortMsgStart | 21 #define IPC_MESSAGE_START MessagePortMsgStart |
23 | 22 |
24 // Singly-included section for typedefs. | 23 // Singly-included section for typedefs. |
25 #ifndef CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ | 24 #ifndef CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ |
26 #define CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ | 25 #define CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ |
27 | 26 |
28 typedef std::pair<content::MessagePortMessage, | 27 typedef std::pair<base::string16, std::vector<int>> QueuedMessage; |
29 std::vector<content::TransferredMessagePort>> QueuedMessage; | |
30 | 28 |
31 #endif // CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ | 29 #endif // CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ |
32 | 30 |
33 IPC_STRUCT_TRAITS_BEGIN(content::MessagePortMessage) | |
34 IPC_STRUCT_TRAITS_MEMBER(message_as_string) | |
35 IPC_STRUCT_TRAITS_MEMBER(message_as_value) | |
36 IPC_STRUCT_TRAITS_END() | |
37 | |
38 IPC_STRUCT_TRAITS_BEGIN(content::TransferredMessagePort) | |
39 IPC_STRUCT_TRAITS_MEMBER(id) | |
40 IPC_STRUCT_TRAITS_MEMBER(send_messages_as_values) | |
41 IPC_STRUCT_TRAITS_END() | |
42 | |
43 //----------------------------------------------------------------------------- | 31 //----------------------------------------------------------------------------- |
44 // MessagePort messages | 32 // MessagePort messages |
45 // These are messages sent from the browser to child processes. | 33 // These are messages sent from the browser to child processes. |
46 | 34 |
47 // Sends a message to a message port. | 35 // Sends a message to a message port. |
48 IPC_MESSAGE_ROUTED3( | 36 IPC_MESSAGE_ROUTED3( |
49 MessagePortMsg_Message, | 37 MessagePortMsg_Message, |
50 content::MessagePortMessage /* message */, | 38 base::string16 /* message */, |
51 std::vector<content::TransferredMessagePort> /* sent_message_ports */, | 39 std::vector<int> /* sent_message_ports */, |
52 std::vector<int> /* new_routing_ids */) | 40 std::vector<int> /* new_routing_ids */) |
53 | 41 |
54 // Tells the Message Port Channel object that there are no more in-flight | 42 // Tells the Message Port Channel object that there are no more in-flight |
55 // messages arriving. | 43 // messages arriving. |
56 IPC_MESSAGE_ROUTED0(MessagePortMsg_MessagesQueued) | 44 IPC_MESSAGE_ROUTED0(MessagePortMsg_MessagesQueued) |
57 | 45 |
58 //----------------------------------------------------------------------------- | 46 //----------------------------------------------------------------------------- |
59 // MessagePortHost messages | 47 // MessagePortHost messages |
60 // These are messages sent from child processes to the browser. | 48 // These are messages sent from child processes to the browser. |
61 | 49 |
62 // Creates a new Message Port Channel object. The first paramaeter is the | 50 // Creates a new Message Port Channel object. The first paramaeter is the |
63 // message port channel's routing id in this process. The second parameter | 51 // message port channel's routing id in this process. The second parameter |
64 // is the process-wide-unique identifier for that port. | 52 // is the process-wide-unique identifier for that port. |
65 IPC_SYNC_MESSAGE_CONTROL0_2(MessagePortHostMsg_CreateMessagePort, | 53 IPC_SYNC_MESSAGE_CONTROL0_2(MessagePortHostMsg_CreateMessagePort, |
66 int /* route_id */, | 54 int /* route_id */, |
67 int /* message_port_id */) | 55 int /* message_port_id */) |
68 | 56 |
69 // Sent when a Message Port Channel object is destroyed. | 57 // Sent when a Message Port Channel object is destroyed. |
70 IPC_MESSAGE_CONTROL1(MessagePortHostMsg_DestroyMessagePort, | 58 IPC_MESSAGE_CONTROL1(MessagePortHostMsg_DestroyMessagePort, |
71 int /* message_port_id */) | 59 int /* message_port_id */) |
72 | 60 |
73 // Sends a message to a message port. Optionally sends a message port as | 61 // Sends a message to a message port. Optionally sends a message port as |
74 // as well if sent_message_port_id != MSG_ROUTING_NONE. | 62 // as well if sent_message_port_id != MSG_ROUTING_NONE. |
75 IPC_MESSAGE_CONTROL3( | 63 IPC_MESSAGE_CONTROL3( |
76 MessagePortHostMsg_PostMessage, | 64 MessagePortHostMsg_PostMessage, |
77 int /* sender_message_port_id */, | 65 int /* sender_message_port_id */, |
78 content::MessagePortMessage /* message */, | 66 base::string16 /* message */, |
79 std::vector<content::TransferredMessagePort> /* sent_message_ports */) | 67 std::vector<int> /* sent_message_ports */) |
80 | 68 |
81 // Causes messages sent to the remote port to be delivered to this local port. | 69 // Causes messages sent to the remote port to be delivered to this local port. |
82 IPC_MESSAGE_CONTROL2(MessagePortHostMsg_Entangle, | 70 IPC_MESSAGE_CONTROL2(MessagePortHostMsg_Entangle, |
83 int /* local_message_port_id */, | 71 int /* local_message_port_id */, |
84 int /* remote_message_port_id */) | 72 int /* remote_message_port_id */) |
85 | 73 |
86 // Causes the browser to queue messages sent to this port until the the port | 74 // Causes the browser to queue messages sent to this port until the the port |
87 // has made sure that all in-flight messages were routed to the new | 75 // has made sure that all in-flight messages were routed to the new |
88 // destination. | 76 // destination. |
89 IPC_MESSAGE_CONTROL1(MessagePortHostMsg_QueueMessages, | 77 IPC_MESSAGE_CONTROL1(MessagePortHostMsg_QueueMessages, |
90 int /* message_port_id */) | 78 int /* message_port_id */) |
91 | 79 |
92 // Sends the browser all the queued messages that arrived at this message port | 80 // Sends the browser all the queued messages that arrived at this message port |
93 // after it was sent in a postMessage call. | 81 // after it was sent in a postMessage call. |
94 // NOTE: MSVS can't compile the macro if std::vector<std::pair<string16, int> > | 82 // NOTE: MSVS can't compile the macro if std::vector<std::pair<string16, int> > |
95 // is used, so we typedef it in worker_messages.h. | 83 // is used, so we typedef it in worker_messages.h. |
96 IPC_MESSAGE_CONTROL2(MessagePortHostMsg_SendQueuedMessages, | 84 IPC_MESSAGE_CONTROL2(MessagePortHostMsg_SendQueuedMessages, |
97 int /* message_port_id */, | 85 int /* message_port_id */, |
98 std::vector<QueuedMessage> /* queued_messages */) | 86 std::vector<QueuedMessage> /* queued_messages */) |
99 | 87 |
100 // Tells the browser this message port is ready to receive messages. If the | 88 // Tells the browser this message port is ready to receive messages. If the |
101 // browser was holding messages to this port because no destination for the | 89 // browser was holding messages to this port because no destination for the |
102 // port was available yet this will cause the browser to release those messages. | 90 // port was available yet this will cause the browser to release those messages. |
103 IPC_MESSAGE_CONTROL1(MessagePortHostMsg_ReleaseMessages, | 91 IPC_MESSAGE_CONTROL1(MessagePortHostMsg_ReleaseMessages, |
104 int /* message_port_id */) | 92 int /* message_port_id */) |
OLD | NEW |