1 // Copyright (c) 2012 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.
5 // Defines messages between the browser and worker process, as well as between
6 // the renderer and worker process.
8 // Multiply-included message file, hence no include guard.
14 #include "base/basictypes.h"
15 #include "base/string16.h"
16 #include "content/common/content_export.h"
17 #include "googleurl/src/gurl.h"
18 #include "ipc/ipc_message_macros.h"
19 #include "ipc/ipc_message_utils.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorker.h"
22 // Singly-included section, not converted.
23 #ifndef CONTENT_COMMON_WORKER_MESSAGES_H_
24 #define CONTENT_COMMON_WORKER_MESSAGES_H_
26 typedef std::pair
<string16
, std::vector
<int> > QueuedMessage
;
28 #endif // CONTENT_COMMON_WORKER_MESSAGES_H_
30 #undef IPC_MESSAGE_EXPORT
31 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
32 #define IPC_MESSAGE_START WorkerMsgStart
34 // Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject,
35 // which has too many data parameters to be reasonably put in a predefined
36 // IPC message. The data members directly correspond to parameters of
37 // WebWorkerClient::postConsoleMessageToWorkerObject()
38 IPC_STRUCT_BEGIN(WorkerHostMsg_PostConsoleMessageToWorkerObject_Params
)
39 IPC_STRUCT_MEMBER(int, source_identifier
)
40 IPC_STRUCT_MEMBER(int, message_type
)
41 IPC_STRUCT_MEMBER(int, message_level
)
42 IPC_STRUCT_MEMBER(string16
, message
)
43 IPC_STRUCT_MEMBER(int, line_number
)
44 IPC_STRUCT_MEMBER(string16
, source_url
)
47 // Parameter structure for WorkerProcessMsg_CreateWorker.
48 IPC_STRUCT_BEGIN(WorkerProcessMsg_CreateWorker_Params
)
49 IPC_STRUCT_MEMBER(GURL
, url
)
50 IPC_STRUCT_MEMBER(string16
, name
)
51 IPC_STRUCT_MEMBER(int, route_id
)
52 IPC_STRUCT_MEMBER(int, creator_process_id
)
53 IPC_STRUCT_MEMBER(int64
, shared_worker_appcache_id
)
56 IPC_ENUM_TRAITS(WebKit::WebContentSecurityPolicyType
)
58 //-----------------------------------------------------------------------------
59 // WorkerProcess messages
60 // These are messages sent from the browser to the worker process.
61 IPC_MESSAGE_CONTROL1(WorkerProcessMsg_CreateWorker
,
62 WorkerProcessMsg_CreateWorker_Params
)
64 // Note: these Message Port related messages can also be sent to the
65 // renderer process. Putting them here since we don't have a shared place
66 // like common_messages_internal.h
67 IPC_MESSAGE_ROUTED3(WorkerProcessMsg_Message
,
68 string16
/* message */,
69 std::vector
<int> /* sent_message_port_ids */,
70 std::vector
<int> /* new_routing_ids */)
72 // Tells the Message Port Channel object that there are no more in-flight
74 IPC_MESSAGE_ROUTED0(WorkerProcessMsg_MessagesQueued
)
77 //-----------------------------------------------------------------------------
78 // WorkerProcessHost messages
79 // These are messages sent from the worker process to the browser process.
81 // Note: these Message Port related messages can also be sent out from the
82 // renderer process. Putting them here since we don't have a shared place
83 // like common_messages_internal.h
85 // Creates a new Message Port Channel object. The first paramaeter is the
86 // message port channel's routing id in this process. The second parameter
87 // is the process-wide-unique identifier for that port.
88 IPC_SYNC_MESSAGE_CONTROL0_2(WorkerProcessHostMsg_CreateMessagePort
,
90 int /* message_port_id */)
92 // Sent when a Message Port Channel object is destroyed.
93 IPC_MESSAGE_CONTROL1(WorkerProcessHostMsg_DestroyMessagePort
,
94 int /* message_port_id */)
96 // Sends a message to a message port. Optionally sends a message port as
97 // as well if sent_message_port_id != MSG_ROUTING_NONE.
98 IPC_MESSAGE_CONTROL3(WorkerProcessHostMsg_PostMessage
,
99 int /* sender_message_port_id */,
100 string16
/* message */,
101 std::vector
<int> /* sent_message_port_ids */)
103 // Causes messages sent to the remote port to be delivered to this local port.
104 IPC_MESSAGE_CONTROL2(WorkerProcessHostMsg_Entangle
,
105 int /* local_message_port_id */,
106 int /* remote_message_port_id */)
108 // Causes the browser to queue messages sent to this port until the the port
109 // has made sure that all in-flight messages were routed to the new
111 IPC_MESSAGE_CONTROL1(WorkerProcessHostMsg_QueueMessages
,
112 int /* message_port_id */)
114 // Sends the browser all the queued messages that arrived at this message port
115 // after it was sent in a postMessage call.
116 // NOTE: MSVS can't compile the macro if std::vector<std::pair<string16, int> >
117 // is used, so we typedef it in worker_messages.h.
118 IPC_MESSAGE_CONTROL2(WorkerProcessHostMsg_SendQueuedMessages
,
119 int /* message_port_id */,
120 std::vector
<QueuedMessage
> /* queued_messages */)
122 // Sent by the worker process to check whether access to web databases is
124 IPC_SYNC_MESSAGE_CONTROL5_1(WorkerProcessHostMsg_AllowDatabase
,
125 int /* worker_route_id */,
126 GURL
/* origin url */,
127 string16
/* database name */,
128 string16
/* database display name */,
129 unsigned long /* estimated size */,
132 // Sent by the worker process to check whether access to file system is allowed.
133 IPC_SYNC_MESSAGE_CONTROL2_1(WorkerProcessHostMsg_AllowFileSystem
,
134 int /* worker_route_id */,
135 GURL
/* origin url */,
138 // Sent by the worker process to check whether access to IndexedDB is allowed.
139 IPC_SYNC_MESSAGE_CONTROL3_1(WorkerProcessHostMsg_AllowIndexedDB
,
140 int /* worker_route_id */,
141 GURL
/* origin url */,
142 string16
/* database name */,
145 //-----------------------------------------------------------------------------
147 // These are messages sent from the renderer process to the worker process.
148 IPC_MESSAGE_ROUTED5(WorkerMsg_StartWorkerContext
,
150 string16
/* user_agent */,
151 string16
/* source_code */,
152 string16
/* content_security_policy */,
153 WebKit::WebContentSecurityPolicyType
)
155 IPC_MESSAGE_ROUTED0(WorkerMsg_TerminateWorkerContext
)
157 IPC_MESSAGE_ROUTED3(WorkerMsg_PostMessage
,
158 string16
/* message */,
159 std::vector
<int> /* sent_message_port_ids */,
160 std::vector
<int> /* new_routing_ids */)
162 IPC_MESSAGE_ROUTED2(WorkerMsg_Connect
,
163 int /* sent_message_port_id */,
164 int /* routing_id */)
166 IPC_MESSAGE_ROUTED0(WorkerMsg_WorkerObjectDestroyed
)
169 //-----------------------------------------------------------------------------
170 // WorkerHost messages
171 // These are messages sent from the worker process to the renderer process.
172 // WorkerMsg_PostMessage is also sent here.
173 IPC_MESSAGE_ROUTED3(WorkerHostMsg_PostExceptionToWorkerObject
,
174 string16
/* error_message */,
175 int /* line_number */,
176 string16
/* source_url*/)
178 IPC_MESSAGE_ROUTED1(WorkerHostMsg_PostConsoleMessageToWorkerObject
,
179 WorkerHostMsg_PostConsoleMessageToWorkerObject_Params
)
181 IPC_MESSAGE_ROUTED1(WorkerHostMsg_ConfirmMessageFromWorkerObject
,
182 bool /* bool has_pending_activity */)
184 IPC_MESSAGE_ROUTED1(WorkerHostMsg_ReportPendingActivity
,
185 bool /* bool has_pending_activity */)
187 IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerContextClosed
,
188 int /* worker_route_id */)
189 IPC_MESSAGE_ROUTED0(WorkerHostMsg_WorkerContextDestroyed
)