1/*
2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#pragma once
26
27#include "ArgumentCoders.h"
28#include "Connection.h"
29#include <WebCore/ProcessIdentifier.h>
30#include <WebCore/ServiceWorkerClientIdentifier.h>
31#include <WebCore/ServiceWorkerIdentifier.h>
32#include <WebCore/ServiceWorkerTypes.h>
33#include <wtf/Forward.h>
34#include <wtf/ThreadSafeRefCounted.h>
35#include <wtf/text/WTFString.h>
36
37namespace PAL {
38class SessionID;
39}
40
41namespace WebCore {
42struct ServiceWorkerClientIdentifier;
43struct MessageWithMessagePorts;
44}
45
46namespace WebKit {
47class UserData;
48struct StatisticsData;
49}
50
51namespace Messages {
52namespace WebProcessPool {
53
54static inline IPC::StringReference messageReceiverName()
55{
56 return IPC::StringReference("WebProcessPool");
57}
58
59class HandleMessage {
60public:
61 typedef std::tuple<const String&, const WebKit::UserData&> Arguments;
62
63 static IPC::StringReference receiverName() { return messageReceiverName(); }
64 static IPC::StringReference name() { return IPC::StringReference("HandleMessage"); }
65 static const bool isSync = false;
66
67 HandleMessage(const String& messageName, const WebKit::UserData& messageBody)
68 : m_arguments(messageName, messageBody)
69 {
70 }
71
72 const Arguments& arguments() const
73 {
74 return m_arguments;
75 }
76
77private:
78 Arguments m_arguments;
79};
80
81class HandleSynchronousMessage {
82public:
83 typedef std::tuple<const String&, const WebKit::UserData&> Arguments;
84
85 static IPC::StringReference receiverName() { return messageReceiverName(); }
86 static IPC::StringReference name() { return IPC::StringReference("HandleSynchronousMessage"); }
87 static const bool isSync = true;
88
89 using DelayedReply = CompletionHandler<void(const WebKit::UserData& returnData)>;
90 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebKit::UserData& returnData);
91 using Reply = std::tuple<WebKit::UserData&>;
92 using ReplyArguments = std::tuple<WebKit::UserData>;
93 HandleSynchronousMessage(const String& messageName, const WebKit::UserData& messageBody)
94 : m_arguments(messageName, messageBody)
95 {
96 }
97
98 const Arguments& arguments() const
99 {
100 return m_arguments;
101 }
102
103private:
104 Arguments m_arguments;
105};
106
107class DidGetStatistics {
108public:
109 typedef std::tuple<const WebKit::StatisticsData&, uint64_t> Arguments;
110
111 static IPC::StringReference receiverName() { return messageReceiverName(); }
112 static IPC::StringReference name() { return IPC::StringReference("DidGetStatistics"); }
113 static const bool isSync = false;
114
115 DidGetStatistics(const WebKit::StatisticsData& statisticsData, uint64_t callbackID)
116 : m_arguments(statisticsData, callbackID)
117 {
118 }
119
120 const Arguments& arguments() const
121 {
122 return m_arguments;
123 }
124
125private:
126 Arguments m_arguments;
127};
128
129#if ENABLE(GAMEPAD)
130class StartedUsingGamepads {
131public:
132 typedef std::tuple<> Arguments;
133
134 static IPC::StringReference receiverName() { return messageReceiverName(); }
135 static IPC::StringReference name() { return IPC::StringReference("StartedUsingGamepads"); }
136 static const bool isSync = false;
137
138 const Arguments& arguments() const
139 {
140 return m_arguments;
141 }
142
143private:
144 Arguments m_arguments;
145};
146#endif
147
148#if ENABLE(GAMEPAD)
149class StoppedUsingGamepads {
150public:
151 typedef std::tuple<> Arguments;
152
153 static IPC::StringReference receiverName() { return messageReceiverName(); }
154 static IPC::StringReference name() { return IPC::StringReference("StoppedUsingGamepads"); }
155 static const bool isSync = false;
156
157 const Arguments& arguments() const
158 {
159 return m_arguments;
160 }
161
162private:
163 Arguments m_arguments;
164};
165#endif
166
167class AddPlugInAutoStartOriginHash {
168public:
169 typedef std::tuple<const String&, uint32_t, const PAL::SessionID&> Arguments;
170
171 static IPC::StringReference receiverName() { return messageReceiverName(); }
172 static IPC::StringReference name() { return IPC::StringReference("AddPlugInAutoStartOriginHash"); }
173 static const bool isSync = false;
174
175 AddPlugInAutoStartOriginHash(const String& pageOrigin, uint32_t hash, const PAL::SessionID& sessionID)
176 : m_arguments(pageOrigin, hash, sessionID)
177 {
178 }
179
180 const Arguments& arguments() const
181 {
182 return m_arguments;
183 }
184
185private:
186 Arguments m_arguments;
187};
188
189class PlugInDidReceiveUserInteraction {
190public:
191 typedef std::tuple<uint32_t, const PAL::SessionID&> Arguments;
192
193 static IPC::StringReference receiverName() { return messageReceiverName(); }
194 static IPC::StringReference name() { return IPC::StringReference("PlugInDidReceiveUserInteraction"); }
195 static const bool isSync = false;
196
197 PlugInDidReceiveUserInteraction(uint32_t hash, const PAL::SessionID& sessionID)
198 : m_arguments(hash, sessionID)
199 {
200 }
201
202 const Arguments& arguments() const
203 {
204 return m_arguments;
205 }
206
207private:
208 Arguments m_arguments;
209};
210
211class ReportWebContentCPUTime {
212public:
213 typedef std::tuple<const Seconds&, uint64_t> Arguments;
214
215 static IPC::StringReference receiverName() { return messageReceiverName(); }
216 static IPC::StringReference name() { return IPC::StringReference("ReportWebContentCPUTime"); }
217 static const bool isSync = false;
218
219 ReportWebContentCPUTime(const Seconds& cpuTime, uint64_t activityState)
220 : m_arguments(cpuTime, activityState)
221 {
222 }
223
224 const Arguments& arguments() const
225 {
226 return m_arguments;
227 }
228
229private:
230 Arguments m_arguments;
231};
232
233class SetWebProcessHasUploads {
234public:
235 typedef std::tuple<const WebCore::ProcessIdentifier&> Arguments;
236
237 static IPC::StringReference receiverName() { return messageReceiverName(); }
238 static IPC::StringReference name() { return IPC::StringReference("SetWebProcessHasUploads"); }
239 static const bool isSync = false;
240
241 explicit SetWebProcessHasUploads(const WebCore::ProcessIdentifier& processID)
242 : m_arguments(processID)
243 {
244 }
245
246 const Arguments& arguments() const
247 {
248 return m_arguments;
249 }
250
251private:
252 Arguments m_arguments;
253};
254
255class ClearWebProcessHasUploads {
256public:
257 typedef std::tuple<const WebCore::ProcessIdentifier&> Arguments;
258
259 static IPC::StringReference receiverName() { return messageReceiverName(); }
260 static IPC::StringReference name() { return IPC::StringReference("ClearWebProcessHasUploads"); }
261 static const bool isSync = false;
262
263 explicit ClearWebProcessHasUploads(const WebCore::ProcessIdentifier& processID)
264 : m_arguments(processID)
265 {
266 }
267
268 const Arguments& arguments() const
269 {
270 return m_arguments;
271 }
272
273private:
274 Arguments m_arguments;
275};
276
277#if ENABLE(SERVICE_WORKER)
278class PostMessageToServiceWorkerClient {
279public:
280 typedef std::tuple<const WebCore::ServiceWorkerClientIdentifier&, const WebCore::MessageWithMessagePorts&, const WebCore::ServiceWorkerIdentifier&, const String&> Arguments;
281
282 static IPC::StringReference receiverName() { return messageReceiverName(); }
283 static IPC::StringReference name() { return IPC::StringReference("PostMessageToServiceWorkerClient"); }
284 static const bool isSync = false;
285
286 PostMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const WebCore::MessageWithMessagePorts& message, const WebCore::ServiceWorkerIdentifier& sourceIdentifier, const String& sourceOrigin)
287 : m_arguments(destinationIdentifier, message, sourceIdentifier, sourceOrigin)
288 {
289 }
290
291 const Arguments& arguments() const
292 {
293 return m_arguments;
294 }
295
296private:
297 Arguments m_arguments;
298};
299#endif
300
301#if ENABLE(SERVICE_WORKER)
302class PostMessageToServiceWorker {
303public:
304 typedef std::tuple<const WebCore::ServiceWorkerIdentifier&, const WebCore::MessageWithMessagePorts&, const WebCore::ServiceWorkerOrClientIdentifier&, const WebCore::SWServerConnectionIdentifier&> Arguments;
305
306 static IPC::StringReference receiverName() { return messageReceiverName(); }
307 static IPC::StringReference name() { return IPC::StringReference("PostMessageToServiceWorker"); }
308 static const bool isSync = false;
309
310 PostMessageToServiceWorker(const WebCore::ServiceWorkerIdentifier& destination, const WebCore::MessageWithMessagePorts& message, const WebCore::ServiceWorkerOrClientIdentifier& source, const WebCore::SWServerConnectionIdentifier& connectionIdentifier)
311 : m_arguments(destination, message, source, connectionIdentifier)
312 {
313 }
314
315 const Arguments& arguments() const
316 {
317 return m_arguments;
318 }
319
320private:
321 Arguments m_arguments;
322};
323#endif
324
325} // namespace WebProcessPool
326} // namespace Messages
327