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/ThreadSafeRefCounted.h>
32#include <wtf/Vector.h>
33#include <wtf/text/WTFString.h>
34
35namespace PAL {
36class SessionID;
37}
38
39namespace WebCore {
40struct CacheQueryOptions;
41struct ClientOrigin;
42class ResourceRequest;
43}
44
45namespace Messages {
46namespace CacheStorageEngineConnection {
47
48static inline IPC::StringReference messageReceiverName()
49{
50 return IPC::StringReference("CacheStorageEngineConnection");
51}
52
53class Reference {
54public:
55 typedef std::tuple<const PAL::SessionID&, uint64_t> Arguments;
56
57 static IPC::StringReference receiverName() { return messageReceiverName(); }
58 static IPC::StringReference name() { return IPC::StringReference("Reference"); }
59 static const bool isSync = false;
60
61 Reference(const PAL::SessionID& sessionID, uint64_t cacheIdentifier)
62 : m_arguments(sessionID, cacheIdentifier)
63 {
64 }
65
66 const Arguments& arguments() const
67 {
68 return m_arguments;
69 }
70
71private:
72 Arguments m_arguments;
73};
74
75class Dereference {
76public:
77 typedef std::tuple<const PAL::SessionID&, uint64_t> Arguments;
78
79 static IPC::StringReference receiverName() { return messageReceiverName(); }
80 static IPC::StringReference name() { return IPC::StringReference("Dereference"); }
81 static const bool isSync = false;
82
83 Dereference(const PAL::SessionID& sessionID, uint64_t cacheIdentifier)
84 : m_arguments(sessionID, cacheIdentifier)
85 {
86 }
87
88 const Arguments& arguments() const
89 {
90 return m_arguments;
91 }
92
93private:
94 Arguments m_arguments;
95};
96
97class Open {
98public:
99 typedef std::tuple<const PAL::SessionID&, uint64_t, const WebCore::ClientOrigin&, const String&> Arguments;
100
101 static IPC::StringReference receiverName() { return messageReceiverName(); }
102 static IPC::StringReference name() { return IPC::StringReference("Open"); }
103 static const bool isSync = false;
104
105 Open(const PAL::SessionID& sessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin& origin, const String& cacheName)
106 : m_arguments(sessionID, requestIdentifier, origin, cacheName)
107 {
108 }
109
110 const Arguments& arguments() const
111 {
112 return m_arguments;
113 }
114
115private:
116 Arguments m_arguments;
117};
118
119class Remove {
120public:
121 typedef std::tuple<const PAL::SessionID&, uint64_t, uint64_t> Arguments;
122
123 static IPC::StringReference receiverName() { return messageReceiverName(); }
124 static IPC::StringReference name() { return IPC::StringReference("Remove"); }
125 static const bool isSync = false;
126
127 Remove(const PAL::SessionID& sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier)
128 : m_arguments(sessionID, requestIdentifier, cacheIdentifier)
129 {
130 }
131
132 const Arguments& arguments() const
133 {
134 return m_arguments;
135 }
136
137private:
138 Arguments m_arguments;
139};
140
141class Caches {
142public:
143 typedef std::tuple<const PAL::SessionID&, uint64_t, const WebCore::ClientOrigin&, uint64_t> Arguments;
144
145 static IPC::StringReference receiverName() { return messageReceiverName(); }
146 static IPC::StringReference name() { return IPC::StringReference("Caches"); }
147 static const bool isSync = false;
148
149 Caches(const PAL::SessionID& sessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin& origin, uint64_t updateCounter)
150 : m_arguments(sessionID, requestIdentifier, origin, updateCounter)
151 {
152 }
153
154 const Arguments& arguments() const
155 {
156 return m_arguments;
157 }
158
159private:
160 Arguments m_arguments;
161};
162
163class ClearMemoryRepresentation {
164public:
165 typedef std::tuple<const PAL::SessionID&, uint64_t, const WebCore::ClientOrigin&> Arguments;
166
167 static IPC::StringReference receiverName() { return messageReceiverName(); }
168 static IPC::StringReference name() { return IPC::StringReference("ClearMemoryRepresentation"); }
169 static const bool isSync = false;
170
171 ClearMemoryRepresentation(const PAL::SessionID& sessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin& origin)
172 : m_arguments(sessionID, requestIdentifier, origin)
173 {
174 }
175
176 const Arguments& arguments() const
177 {
178 return m_arguments;
179 }
180
181private:
182 Arguments m_arguments;
183};
184
185class EngineRepresentation {
186public:
187 typedef std::tuple<const PAL::SessionID&, uint64_t> Arguments;
188
189 static IPC::StringReference receiverName() { return messageReceiverName(); }
190 static IPC::StringReference name() { return IPC::StringReference("EngineRepresentation"); }
191 static const bool isSync = false;
192
193 EngineRepresentation(const PAL::SessionID& sessionID, uint64_t requestIdentifier)
194 : m_arguments(sessionID, requestIdentifier)
195 {
196 }
197
198 const Arguments& arguments() const
199 {
200 return m_arguments;
201 }
202
203private:
204 Arguments m_arguments;
205};
206
207class RetrieveRecords {
208public:
209 typedef std::tuple<const PAL::SessionID&, uint64_t, uint64_t, const URL&> Arguments;
210
211 static IPC::StringReference receiverName() { return messageReceiverName(); }
212 static IPC::StringReference name() { return IPC::StringReference("RetrieveRecords"); }
213 static const bool isSync = false;
214
215 RetrieveRecords(const PAL::SessionID& sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, const URL& url)
216 : m_arguments(sessionID, requestIdentifier, cacheIdentifier, url)
217 {
218 }
219
220 const Arguments& arguments() const
221 {
222 return m_arguments;
223 }
224
225private:
226 Arguments m_arguments;
227};
228
229class DeleteMatchingRecords {
230public:
231 typedef std::tuple<const PAL::SessionID&, uint64_t, uint64_t, const WebCore::ResourceRequest&, const WebCore::CacheQueryOptions&> Arguments;
232
233 static IPC::StringReference receiverName() { return messageReceiverName(); }
234 static IPC::StringReference name() { return IPC::StringReference("DeleteMatchingRecords"); }
235 static const bool isSync = false;
236
237 DeleteMatchingRecords(const PAL::SessionID& sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, const WebCore::ResourceRequest& request, const WebCore::CacheQueryOptions& options)
238 : m_arguments(sessionID, requestIdentifier, cacheIdentifier, request, options)
239 {
240 }
241
242 const Arguments& arguments() const
243 {
244 return m_arguments;
245 }
246
247private:
248 Arguments m_arguments;
249};
250
251class PutRecords {
252public:
253 typedef std::tuple<const PAL::SessionID&, uint64_t, uint64_t, const Vector<WebCore::DOMCacheEngine::Record>&> Arguments;
254
255 static IPC::StringReference receiverName() { return messageReceiverName(); }
256 static IPC::StringReference name() { return IPC::StringReference("PutRecords"); }
257 static const bool isSync = false;
258
259 PutRecords(const PAL::SessionID& sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, const Vector<WebCore::DOMCacheEngine::Record>& record)
260 : m_arguments(sessionID, requestIdentifier, cacheIdentifier, record)
261 {
262 }
263
264 const Arguments& arguments() const
265 {
266 return m_arguments;
267 }
268
269private:
270 Arguments m_arguments;
271};
272
273} // namespace CacheStorageEngineConnection
274} // namespace Messages
275