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 | |
36 | namespace PAL { |
37 | class SessionID; |
38 | } |
39 | |
40 | namespace WebCore { |
41 | struct CacheQueryOptions; |
42 | struct ClientOrigin; |
43 | class ResourceRequest; |
44 | } |
45 | |
46 | namespace Messages { |
47 | namespace CacheStorageEngineConnection { |
48 | |
49 | static inline IPC::StringReference messageReceiverName() |
50 | { |
51 | return IPC::StringReference("CacheStorageEngineConnection" ); |
52 | } |
53 | |
54 | class Reference { |
55 | public: |
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 | |
72 | private: |
73 | Arguments m_arguments; |
74 | }; |
75 | |
76 | class Dereference { |
77 | public: |
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 | |
94 | private: |
95 | Arguments m_arguments; |
96 | }; |
97 | |
98 | class Open { |
99 | public: |
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 | |
123 | private: |
124 | Arguments m_arguments; |
125 | }; |
126 | |
127 | class Remove { |
128 | public: |
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 | |
152 | private: |
153 | Arguments m_arguments; |
154 | }; |
155 | |
156 | class Caches { |
157 | public: |
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 | |
181 | private: |
182 | Arguments m_arguments; |
183 | }; |
184 | |
185 | class RetrieveRecords { |
186 | public: |
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 | |
210 | private: |
211 | Arguments m_arguments; |
212 | }; |
213 | |
214 | class DeleteMatchingRecords { |
215 | public: |
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 | |
239 | private: |
240 | Arguments m_arguments; |
241 | }; |
242 | |
243 | class PutRecords { |
244 | public: |
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 | |
268 | private: |
269 | Arguments m_arguments; |
270 | }; |
271 | |
272 | class ClearMemoryRepresentation { |
273 | public: |
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 | |
297 | private: |
298 | Arguments m_arguments; |
299 | }; |
300 | |
301 | class EngineRepresentation { |
302 | public: |
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 | |
326 | private: |
327 | Arguments m_arguments; |
328 | }; |
329 | |
330 | } // namespace CacheStorageEngineConnection |
331 | } // namespace Messages |
332 | |