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/DOMCacheEngine.h>
30#include <wtf/Forward.h>
31#include <wtf/Optional.h>
32#include <wtf/ThreadSafeRefCounted.h>
33#include <wtf/Vector.h>
34#include <wtf/text/WTFString.h>
35
36namespace PAL {
37class SessionID;
38}
39
40namespace WebCore {
41struct CacheQueryOptions;
42struct ClientOrigin;
43class ResourceRequest;
44}
45
46namespace Messages {
47namespace CacheStorageEngineConnection {
48
49static inline IPC::StringReference messageReceiverName()
50{
51 return IPC::StringReference("CacheStorageEngineConnection");
52}
53
54class Reference {
55public:
56 typedef std::tuple<const PAL::SessionID&, uint64_t> Arguments;
57
58 static IPC::StringReference receiverName() { return messageReceiverName(); }
59 static IPC::StringReference name() { return IPC::StringReference("Reference"); }
60 static const bool isSync = false;
61
62 Reference(const PAL::SessionID& sessionID, uint64_t cacheIdentifier)
63 : m_arguments(sessionID, cacheIdentifier)
64 {
65 }
66
67 const Arguments& arguments() const
68 {
69 return m_arguments;
70 }
71
72private:
73 Arguments m_arguments;
74};
75
76class Dereference {
77public:
78 typedef std::tuple<const PAL::SessionID&, uint64_t> Arguments;
79
80 static IPC::StringReference receiverName() { return messageReceiverName(); }
81 static IPC::StringReference name() { return IPC::StringReference("Dereference"); }
82 static const bool isSync = false;
83
84 Dereference(const PAL::SessionID& sessionID, uint64_t cacheIdentifier)
85 : m_arguments(sessionID, cacheIdentifier)
86 {
87 }
88
89 const Arguments& arguments() const
90 {
91 return m_arguments;
92 }
93
94private:
95 Arguments m_arguments;
96};
97
98class Open {
99public:
100 typedef std::tuple<const PAL::SessionID&, const WebCore::ClientOrigin&, const String&> Arguments;
101
102 static IPC::StringReference receiverName() { return messageReceiverName(); }
103 static IPC::StringReference name() { return IPC::StringReference("Open"); }
104 static const bool isSync = false;
105
106 static void callReply(IPC::Decoder&, CompletionHandler<void(WebCore::DOMCacheEngine::CacheIdentifierOrError&&)>&&);
107 static void cancelReply(CompletionHandler<void(WebCore::DOMCacheEngine::CacheIdentifierOrError&&)>&&);
108 static IPC::StringReference asyncMessageReplyName() { return { "OpenReply" }; }
109 using AsyncReply = CompletionHandler<void(const WebCore::DOMCacheEngine::CacheIdentifierOrError& result)>;
110 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebCore::DOMCacheEngine::CacheIdentifierOrError& result);
111 using Reply = std::tuple<WebCore::DOMCacheEngine::CacheIdentifierOrError&>;
112 using ReplyArguments = std::tuple<WebCore::DOMCacheEngine::CacheIdentifierOrError>;
113 Open(const PAL::SessionID& sessionID, const WebCore::ClientOrigin& origin, const String& cacheName)
114 : m_arguments(sessionID, origin, cacheName)
115 {
116 }
117
118 const Arguments& arguments() const
119 {
120 return m_arguments;
121 }
122
123private:
124 Arguments m_arguments;
125};
126
127class Remove {
128public:
129 typedef std::tuple<const PAL::SessionID&, uint64_t> Arguments;
130
131 static IPC::StringReference receiverName() { return messageReceiverName(); }
132 static IPC::StringReference name() { return IPC::StringReference("Remove"); }
133 static const bool isSync = false;
134
135 static void callReply(IPC::Decoder&, CompletionHandler<void(WebCore::DOMCacheEngine::CacheIdentifierOrError&&)>&&);
136 static void cancelReply(CompletionHandler<void(WebCore::DOMCacheEngine::CacheIdentifierOrError&&)>&&);
137 static IPC::StringReference asyncMessageReplyName() { return { "RemoveReply" }; }
138 using AsyncReply = CompletionHandler<void(const WebCore::DOMCacheEngine::CacheIdentifierOrError& result)>;
139 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebCore::DOMCacheEngine::CacheIdentifierOrError& result);
140 using Reply = std::tuple<WebCore::DOMCacheEngine::CacheIdentifierOrError&>;
141 using ReplyArguments = std::tuple<WebCore::DOMCacheEngine::CacheIdentifierOrError>;
142 Remove(const PAL::SessionID& sessionID, uint64_t cacheIdentifier)
143 : m_arguments(sessionID, cacheIdentifier)
144 {
145 }
146
147 const Arguments& arguments() const
148 {
149 return m_arguments;
150 }
151
152private:
153 Arguments m_arguments;
154};
155
156class Caches {
157public:
158 typedef std::tuple<const PAL::SessionID&, const WebCore::ClientOrigin&, uint64_t> Arguments;
159
160 static IPC::StringReference receiverName() { return messageReceiverName(); }
161 static IPC::StringReference name() { return IPC::StringReference("Caches"); }
162 static const bool isSync = false;
163
164 static void callReply(IPC::Decoder&, CompletionHandler<void(WebCore::DOMCacheEngine::CacheInfosOrError&&)>&&);
165 static void cancelReply(CompletionHandler<void(WebCore::DOMCacheEngine::CacheInfosOrError&&)>&&);
166 static IPC::StringReference asyncMessageReplyName() { return { "CachesReply" }; }
167 using AsyncReply = CompletionHandler<void(const WebCore::DOMCacheEngine::CacheInfosOrError& result)>;
168 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebCore::DOMCacheEngine::CacheInfosOrError& result);
169 using Reply = std::tuple<WebCore::DOMCacheEngine::CacheInfosOrError&>;
170 using ReplyArguments = std::tuple<WebCore::DOMCacheEngine::CacheInfosOrError>;
171 Caches(const PAL::SessionID& sessionID, const WebCore::ClientOrigin& origin, uint64_t updateCounter)
172 : m_arguments(sessionID, origin, updateCounter)
173 {
174 }
175
176 const Arguments& arguments() const
177 {
178 return m_arguments;
179 }
180
181private:
182 Arguments m_arguments;
183};
184
185class RetrieveRecords {
186public:
187 typedef std::tuple<const PAL::SessionID&, uint64_t, const URL&> Arguments;
188
189 static IPC::StringReference receiverName() { return messageReceiverName(); }
190 static IPC::StringReference name() { return IPC::StringReference("RetrieveRecords"); }
191 static const bool isSync = false;
192
193 static void callReply(IPC::Decoder&, CompletionHandler<void(WebCore::DOMCacheEngine::RecordsOrError&&)>&&);
194 static void cancelReply(CompletionHandler<void(WebCore::DOMCacheEngine::RecordsOrError&&)>&&);
195 static IPC::StringReference asyncMessageReplyName() { return { "RetrieveRecordsReply" }; }
196 using AsyncReply = CompletionHandler<void(const WebCore::DOMCacheEngine::RecordsOrError& result)>;
197 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebCore::DOMCacheEngine::RecordsOrError& result);
198 using Reply = std::tuple<WebCore::DOMCacheEngine::RecordsOrError&>;
199 using ReplyArguments = std::tuple<WebCore::DOMCacheEngine::RecordsOrError>;
200 RetrieveRecords(const PAL::SessionID& sessionID, uint64_t cacheIdentifier, const URL& url)
201 : m_arguments(sessionID, cacheIdentifier, url)
202 {
203 }
204
205 const Arguments& arguments() const
206 {
207 return m_arguments;
208 }
209
210private:
211 Arguments m_arguments;
212};
213
214class DeleteMatchingRecords {
215public:
216 typedef std::tuple<const PAL::SessionID&, uint64_t, const WebCore::ResourceRequest&, const WebCore::CacheQueryOptions&> Arguments;
217
218 static IPC::StringReference receiverName() { return messageReceiverName(); }
219 static IPC::StringReference name() { return IPC::StringReference("DeleteMatchingRecords"); }
220 static const bool isSync = false;
221
222 static void callReply(IPC::Decoder&, CompletionHandler<void(WebCore::DOMCacheEngine::RecordIdentifiersOrError&&)>&&);
223 static void cancelReply(CompletionHandler<void(WebCore::DOMCacheEngine::RecordIdentifiersOrError&&)>&&);
224 static IPC::StringReference asyncMessageReplyName() { return { "DeleteMatchingRecordsReply" }; }
225 using AsyncReply = CompletionHandler<void(const WebCore::DOMCacheEngine::RecordIdentifiersOrError& result)>;
226 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebCore::DOMCacheEngine::RecordIdentifiersOrError& result);
227 using Reply = std::tuple<WebCore::DOMCacheEngine::RecordIdentifiersOrError&>;
228 using ReplyArguments = std::tuple<WebCore::DOMCacheEngine::RecordIdentifiersOrError>;
229 DeleteMatchingRecords(const PAL::SessionID& sessionID, uint64_t cacheIdentifier, const WebCore::ResourceRequest& request, const WebCore::CacheQueryOptions& options)
230 : m_arguments(sessionID, cacheIdentifier, request, options)
231 {
232 }
233
234 const Arguments& arguments() const
235 {
236 return m_arguments;
237 }
238
239private:
240 Arguments m_arguments;
241};
242
243class PutRecords {
244public:
245 typedef std::tuple<const PAL::SessionID&, uint64_t, const Vector<WebCore::DOMCacheEngine::Record>&> Arguments;
246
247 static IPC::StringReference receiverName() { return messageReceiverName(); }
248 static IPC::StringReference name() { return IPC::StringReference("PutRecords"); }
249 static const bool isSync = false;
250
251 static void callReply(IPC::Decoder&, CompletionHandler<void(WebCore::DOMCacheEngine::RecordIdentifiersOrError&&)>&&);
252 static void cancelReply(CompletionHandler<void(WebCore::DOMCacheEngine::RecordIdentifiersOrError&&)>&&);
253 static IPC::StringReference asyncMessageReplyName() { return { "PutRecordsReply" }; }
254 using AsyncReply = CompletionHandler<void(const WebCore::DOMCacheEngine::RecordIdentifiersOrError& result)>;
255 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebCore::DOMCacheEngine::RecordIdentifiersOrError& result);
256 using Reply = std::tuple<WebCore::DOMCacheEngine::RecordIdentifiersOrError&>;
257 using ReplyArguments = std::tuple<WebCore::DOMCacheEngine::RecordIdentifiersOrError>;
258 PutRecords(const PAL::SessionID& sessionID, uint64_t cacheIdentifier, const Vector<WebCore::DOMCacheEngine::Record>& record)
259 : m_arguments(sessionID, cacheIdentifier, record)
260 {
261 }
262
263 const Arguments& arguments() const
264 {
265 return m_arguments;
266 }
267
268private:
269 Arguments m_arguments;
270};
271
272class ClearMemoryRepresentation {
273public:
274 typedef std::tuple<const PAL::SessionID&, const WebCore::ClientOrigin&> Arguments;
275
276 static IPC::StringReference receiverName() { return messageReceiverName(); }
277 static IPC::StringReference name() { return IPC::StringReference("ClearMemoryRepresentation"); }
278 static const bool isSync = false;
279
280 static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<WebCore::DOMCacheEngine::Error>&&)>&&);
281 static void cancelReply(CompletionHandler<void(Optional<WebCore::DOMCacheEngine::Error>&&)>&&);
282 static IPC::StringReference asyncMessageReplyName() { return { "ClearMemoryRepresentationReply" }; }
283 using AsyncReply = CompletionHandler<void(const Optional<WebCore::DOMCacheEngine::Error>& error)>;
284 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<WebCore::DOMCacheEngine::Error>& error);
285 using Reply = std::tuple<Optional<WebCore::DOMCacheEngine::Error>&>;
286 using ReplyArguments = std::tuple<Optional<WebCore::DOMCacheEngine::Error>>;
287 ClearMemoryRepresentation(const PAL::SessionID& sessionID, const WebCore::ClientOrigin& origin)
288 : m_arguments(sessionID, origin)
289 {
290 }
291
292 const Arguments& arguments() const
293 {
294 return m_arguments;
295 }
296
297private:
298 Arguments m_arguments;
299};
300
301class EngineRepresentation {
302public:
303 typedef std::tuple<const PAL::SessionID&> Arguments;
304
305 static IPC::StringReference receiverName() { return messageReceiverName(); }
306 static IPC::StringReference name() { return IPC::StringReference("EngineRepresentation"); }
307 static const bool isSync = false;
308
309 static void callReply(IPC::Decoder&, CompletionHandler<void(String&&)>&&);
310 static void cancelReply(CompletionHandler<void(String&&)>&&);
311 static IPC::StringReference asyncMessageReplyName() { return { "EngineRepresentationReply" }; }
312 using AsyncReply = CompletionHandler<void(const String& representation)>;
313 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const String& representation);
314 using Reply = std::tuple<String&>;
315 using ReplyArguments = std::tuple<String>;
316 explicit EngineRepresentation(const PAL::SessionID& sessionID)
317 : m_arguments(sessionID)
318 {
319 }
320
321 const Arguments& arguments() const
322 {
323 return m_arguments;
324 }
325
326private:
327 Arguments m_arguments;
328};
329
330} // namespace CacheStorageEngineConnection
331} // namespace Messages
332