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#if ENABLE(INDEXED_DATABASE)
28
29#include "ArgumentCoders.h"
30#include "Connection.h"
31#include <WebCore/IndexedDB.h>
32#include <wtf/Forward.h>
33#include <wtf/ThreadSafeRefCounted.h>
34#include <wtf/text/WTFString.h>
35
36namespace WebCore {
37struct IDBGetAllRecordsData;
38class IDBValue;
39struct IDBKeyRangeData;
40class IDBTransactionInfo;
41class IDBIndexInfo;
42class IDBCursorInfo;
43class IDBResourceIdentifier;
44struct SecurityOriginData;
45class IDBKeyData;
46struct IDBIterateCursorData;
47class IDBObjectStoreInfo;
48struct IDBGetRecordData;
49class IDBRequestData;
50}
51
52namespace Messages {
53namespace WebIDBConnectionToClient {
54
55static inline IPC::StringReference messageReceiverName()
56{
57 return IPC::StringReference("WebIDBConnectionToClient");
58}
59
60class DeleteDatabase {
61public:
62 typedef std::tuple<const WebCore::IDBRequestData&> Arguments;
63
64 static IPC::StringReference receiverName() { return messageReceiverName(); }
65 static IPC::StringReference name() { return IPC::StringReference("DeleteDatabase"); }
66 static const bool isSync = false;
67
68 explicit DeleteDatabase(const WebCore::IDBRequestData& requestData)
69 : m_arguments(requestData)
70 {
71 }
72
73 const Arguments& arguments() const
74 {
75 return m_arguments;
76 }
77
78private:
79 Arguments m_arguments;
80};
81
82class OpenDatabase {
83public:
84 typedef std::tuple<const WebCore::IDBRequestData&> Arguments;
85
86 static IPC::StringReference receiverName() { return messageReceiverName(); }
87 static IPC::StringReference name() { return IPC::StringReference("OpenDatabase"); }
88 static const bool isSync = false;
89
90 explicit OpenDatabase(const WebCore::IDBRequestData& requestData)
91 : m_arguments(requestData)
92 {
93 }
94
95 const Arguments& arguments() const
96 {
97 return m_arguments;
98 }
99
100private:
101 Arguments m_arguments;
102};
103
104class AbortTransaction {
105public:
106 typedef std::tuple<const WebCore::IDBResourceIdentifier&> Arguments;
107
108 static IPC::StringReference receiverName() { return messageReceiverName(); }
109 static IPC::StringReference name() { return IPC::StringReference("AbortTransaction"); }
110 static const bool isSync = false;
111
112 explicit AbortTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier)
113 : m_arguments(transactionIdentifier)
114 {
115 }
116
117 const Arguments& arguments() const
118 {
119 return m_arguments;
120 }
121
122private:
123 Arguments m_arguments;
124};
125
126class CommitTransaction {
127public:
128 typedef std::tuple<const WebCore::IDBResourceIdentifier&> Arguments;
129
130 static IPC::StringReference receiverName() { return messageReceiverName(); }
131 static IPC::StringReference name() { return IPC::StringReference("CommitTransaction"); }
132 static const bool isSync = false;
133
134 explicit CommitTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier)
135 : m_arguments(transactionIdentifier)
136 {
137 }
138
139 const Arguments& arguments() const
140 {
141 return m_arguments;
142 }
143
144private:
145 Arguments m_arguments;
146};
147
148class DidFinishHandlingVersionChangeTransaction {
149public:
150 typedef std::tuple<uint64_t, const WebCore::IDBResourceIdentifier&> Arguments;
151
152 static IPC::StringReference receiverName() { return messageReceiverName(); }
153 static IPC::StringReference name() { return IPC::StringReference("DidFinishHandlingVersionChangeTransaction"); }
154 static const bool isSync = false;
155
156 DidFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& transactionIdentifier)
157 : m_arguments(databaseConnectionIdentifier, transactionIdentifier)
158 {
159 }
160
161 const Arguments& arguments() const
162 {
163 return m_arguments;
164 }
165
166private:
167 Arguments m_arguments;
168};
169
170class CreateObjectStore {
171public:
172 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBObjectStoreInfo&> Arguments;
173
174 static IPC::StringReference receiverName() { return messageReceiverName(); }
175 static IPC::StringReference name() { return IPC::StringReference("CreateObjectStore"); }
176 static const bool isSync = false;
177
178 CreateObjectStore(const WebCore::IDBRequestData& requestData, const WebCore::IDBObjectStoreInfo& info)
179 : m_arguments(requestData, info)
180 {
181 }
182
183 const Arguments& arguments() const
184 {
185 return m_arguments;
186 }
187
188private:
189 Arguments m_arguments;
190};
191
192class DeleteObjectStore {
193public:
194 typedef std::tuple<const WebCore::IDBRequestData&, const String&> Arguments;
195
196 static IPC::StringReference receiverName() { return messageReceiverName(); }
197 static IPC::StringReference name() { return IPC::StringReference("DeleteObjectStore"); }
198 static const bool isSync = false;
199
200 DeleteObjectStore(const WebCore::IDBRequestData& requestData, const String& objectStoreName)
201 : m_arguments(requestData, objectStoreName)
202 {
203 }
204
205 const Arguments& arguments() const
206 {
207 return m_arguments;
208 }
209
210private:
211 Arguments m_arguments;
212};
213
214class RenameObjectStore {
215public:
216 typedef std::tuple<const WebCore::IDBRequestData&, uint64_t, const String&> Arguments;
217
218 static IPC::StringReference receiverName() { return messageReceiverName(); }
219 static IPC::StringReference name() { return IPC::StringReference("RenameObjectStore"); }
220 static const bool isSync = false;
221
222 RenameObjectStore(const WebCore::IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& newName)
223 : m_arguments(requestData, objectStoreIdentifier, newName)
224 {
225 }
226
227 const Arguments& arguments() const
228 {
229 return m_arguments;
230 }
231
232private:
233 Arguments m_arguments;
234};
235
236class ClearObjectStore {
237public:
238 typedef std::tuple<const WebCore::IDBRequestData&, uint64_t> Arguments;
239
240 static IPC::StringReference receiverName() { return messageReceiverName(); }
241 static IPC::StringReference name() { return IPC::StringReference("ClearObjectStore"); }
242 static const bool isSync = false;
243
244 ClearObjectStore(const WebCore::IDBRequestData& requestData, uint64_t objectStoreIdentifier)
245 : m_arguments(requestData, objectStoreIdentifier)
246 {
247 }
248
249 const Arguments& arguments() const
250 {
251 return m_arguments;
252 }
253
254private:
255 Arguments m_arguments;
256};
257
258class CreateIndex {
259public:
260 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&> Arguments;
261
262 static IPC::StringReference receiverName() { return messageReceiverName(); }
263 static IPC::StringReference name() { return IPC::StringReference("CreateIndex"); }
264 static const bool isSync = false;
265
266 CreateIndex(const WebCore::IDBRequestData& requestData, const WebCore::IDBIndexInfo& info)
267 : m_arguments(requestData, info)
268 {
269 }
270
271 const Arguments& arguments() const
272 {
273 return m_arguments;
274 }
275
276private:
277 Arguments m_arguments;
278};
279
280class DeleteIndex {
281public:
282 typedef std::tuple<const WebCore::IDBRequestData&, uint64_t, const String&> Arguments;
283
284 static IPC::StringReference receiverName() { return messageReceiverName(); }
285 static IPC::StringReference name() { return IPC::StringReference("DeleteIndex"); }
286 static const bool isSync = false;
287
288 DeleteIndex(const WebCore::IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& indexName)
289 : m_arguments(requestData, objectStoreIdentifier, indexName)
290 {
291 }
292
293 const Arguments& arguments() const
294 {
295 return m_arguments;
296 }
297
298private:
299 Arguments m_arguments;
300};
301
302class RenameIndex {
303public:
304 typedef std::tuple<const WebCore::IDBRequestData&, uint64_t, uint64_t, const String&> Arguments;
305
306 static IPC::StringReference receiverName() { return messageReceiverName(); }
307 static IPC::StringReference name() { return IPC::StringReference("RenameIndex"); }
308 static const bool isSync = false;
309
310 RenameIndex(const WebCore::IDBRequestData& requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
311 : m_arguments(requestData, objectStoreIdentifier, indexIdentifier, newName)
312 {
313 }
314
315 const Arguments& arguments() const
316 {
317 return m_arguments;
318 }
319
320private:
321 Arguments m_arguments;
322};
323
324class PutOrAdd {
325public:
326 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, const WebCore::IDBValue&, const WebCore::IndexedDB::ObjectStoreOverwriteMode&> Arguments;
327
328 static IPC::StringReference receiverName() { return messageReceiverName(); }
329 static IPC::StringReference name() { return IPC::StringReference("PutOrAdd"); }
330 static const bool isSync = false;
331
332 PutOrAdd(const WebCore::IDBRequestData& requestData, const WebCore::IDBKeyData& key, const WebCore::IDBValue& value, const WebCore::IndexedDB::ObjectStoreOverwriteMode& overwriteMode)
333 : m_arguments(requestData, key, value, overwriteMode)
334 {
335 }
336
337 const Arguments& arguments() const
338 {
339 return m_arguments;
340 }
341
342private:
343 Arguments m_arguments;
344};
345
346class GetRecord {
347public:
348 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBGetRecordData&> Arguments;
349
350 static IPC::StringReference receiverName() { return messageReceiverName(); }
351 static IPC::StringReference name() { return IPC::StringReference("GetRecord"); }
352 static const bool isSync = false;
353
354 GetRecord(const WebCore::IDBRequestData& requestData, const WebCore::IDBGetRecordData& getRecordData)
355 : m_arguments(requestData, getRecordData)
356 {
357 }
358
359 const Arguments& arguments() const
360 {
361 return m_arguments;
362 }
363
364private:
365 Arguments m_arguments;
366};
367
368class GetAllRecords {
369public:
370 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBGetAllRecordsData&> Arguments;
371
372 static IPC::StringReference receiverName() { return messageReceiverName(); }
373 static IPC::StringReference name() { return IPC::StringReference("GetAllRecords"); }
374 static const bool isSync = false;
375
376 GetAllRecords(const WebCore::IDBRequestData& requestData, const WebCore::IDBGetAllRecordsData& getAllRecordsData)
377 : m_arguments(requestData, getAllRecordsData)
378 {
379 }
380
381 const Arguments& arguments() const
382 {
383 return m_arguments;
384 }
385
386private:
387 Arguments m_arguments;
388};
389
390class GetCount {
391public:
392 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&> Arguments;
393
394 static IPC::StringReference receiverName() { return messageReceiverName(); }
395 static IPC::StringReference name() { return IPC::StringReference("GetCount"); }
396 static const bool isSync = false;
397
398 GetCount(const WebCore::IDBRequestData& requestData, const WebCore::IDBKeyRangeData& range)
399 : m_arguments(requestData, range)
400 {
401 }
402
403 const Arguments& arguments() const
404 {
405 return m_arguments;
406 }
407
408private:
409 Arguments m_arguments;
410};
411
412class DeleteRecord {
413public:
414 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&> Arguments;
415
416 static IPC::StringReference receiverName() { return messageReceiverName(); }
417 static IPC::StringReference name() { return IPC::StringReference("DeleteRecord"); }
418 static const bool isSync = false;
419
420 DeleteRecord(const WebCore::IDBRequestData& requestData, const WebCore::IDBKeyRangeData& range)
421 : m_arguments(requestData, range)
422 {
423 }
424
425 const Arguments& arguments() const
426 {
427 return m_arguments;
428 }
429
430private:
431 Arguments m_arguments;
432};
433
434class OpenCursor {
435public:
436 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBCursorInfo&> Arguments;
437
438 static IPC::StringReference receiverName() { return messageReceiverName(); }
439 static IPC::StringReference name() { return IPC::StringReference("OpenCursor"); }
440 static const bool isSync = false;
441
442 OpenCursor(const WebCore::IDBRequestData& requestData, const WebCore::IDBCursorInfo& info)
443 : m_arguments(requestData, info)
444 {
445 }
446
447 const Arguments& arguments() const
448 {
449 return m_arguments;
450 }
451
452private:
453 Arguments m_arguments;
454};
455
456class IterateCursor {
457public:
458 typedef std::tuple<const WebCore::IDBRequestData&, const WebCore::IDBIterateCursorData&> Arguments;
459
460 static IPC::StringReference receiverName() { return messageReceiverName(); }
461 static IPC::StringReference name() { return IPC::StringReference("IterateCursor"); }
462 static const bool isSync = false;
463
464 IterateCursor(const WebCore::IDBRequestData& requestData, const WebCore::IDBIterateCursorData& data)
465 : m_arguments(requestData, data)
466 {
467 }
468
469 const Arguments& arguments() const
470 {
471 return m_arguments;
472 }
473
474private:
475 Arguments m_arguments;
476};
477
478class EstablishTransaction {
479public:
480 typedef std::tuple<uint64_t, const WebCore::IDBTransactionInfo&> Arguments;
481
482 static IPC::StringReference receiverName() { return messageReceiverName(); }
483 static IPC::StringReference name() { return IPC::StringReference("EstablishTransaction"); }
484 static const bool isSync = false;
485
486 EstablishTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBTransactionInfo& info)
487 : m_arguments(databaseConnectionIdentifier, info)
488 {
489 }
490
491 const Arguments& arguments() const
492 {
493 return m_arguments;
494 }
495
496private:
497 Arguments m_arguments;
498};
499
500class DatabaseConnectionPendingClose {
501public:
502 typedef std::tuple<uint64_t> Arguments;
503
504 static IPC::StringReference receiverName() { return messageReceiverName(); }
505 static IPC::StringReference name() { return IPC::StringReference("DatabaseConnectionPendingClose"); }
506 static const bool isSync = false;
507
508 explicit DatabaseConnectionPendingClose(uint64_t databaseConnectionIdentifier)
509 : m_arguments(databaseConnectionIdentifier)
510 {
511 }
512
513 const Arguments& arguments() const
514 {
515 return m_arguments;
516 }
517
518private:
519 Arguments m_arguments;
520};
521
522class DatabaseConnectionClosed {
523public:
524 typedef std::tuple<uint64_t> Arguments;
525
526 static IPC::StringReference receiverName() { return messageReceiverName(); }
527 static IPC::StringReference name() { return IPC::StringReference("DatabaseConnectionClosed"); }
528 static const bool isSync = false;
529
530 explicit DatabaseConnectionClosed(uint64_t databaseConnectionIdentifier)
531 : m_arguments(databaseConnectionIdentifier)
532 {
533 }
534
535 const Arguments& arguments() const
536 {
537 return m_arguments;
538 }
539
540private:
541 Arguments m_arguments;
542};
543
544class AbortOpenAndUpgradeNeeded {
545public:
546 typedef std::tuple<uint64_t, const WebCore::IDBResourceIdentifier&> Arguments;
547
548 static IPC::StringReference receiverName() { return messageReceiverName(); }
549 static IPC::StringReference name() { return IPC::StringReference("AbortOpenAndUpgradeNeeded"); }
550 static const bool isSync = false;
551
552 AbortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& transactionIdentifier)
553 : m_arguments(databaseConnectionIdentifier, transactionIdentifier)
554 {
555 }
556
557 const Arguments& arguments() const
558 {
559 return m_arguments;
560 }
561
562private:
563 Arguments m_arguments;
564};
565
566class DidFireVersionChangeEvent {
567public:
568 typedef std::tuple<uint64_t, const WebCore::IDBResourceIdentifier&> Arguments;
569
570 static IPC::StringReference receiverName() { return messageReceiverName(); }
571 static IPC::StringReference name() { return IPC::StringReference("DidFireVersionChangeEvent"); }
572 static const bool isSync = false;
573
574 DidFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier)
575 : m_arguments(databaseConnectionIdentifier, requestIdentifier)
576 {
577 }
578
579 const Arguments& arguments() const
580 {
581 return m_arguments;
582 }
583
584private:
585 Arguments m_arguments;
586};
587
588class OpenDBRequestCancelled {
589public:
590 typedef std::tuple<const WebCore::IDBRequestData&> Arguments;
591
592 static IPC::StringReference receiverName() { return messageReceiverName(); }
593 static IPC::StringReference name() { return IPC::StringReference("OpenDBRequestCancelled"); }
594 static const bool isSync = false;
595
596 explicit OpenDBRequestCancelled(const WebCore::IDBRequestData& requestData)
597 : m_arguments(requestData)
598 {
599 }
600
601 const Arguments& arguments() const
602 {
603 return m_arguments;
604 }
605
606private:
607 Arguments m_arguments;
608};
609
610class ConfirmDidCloseFromServer {
611public:
612 typedef std::tuple<uint64_t> Arguments;
613
614 static IPC::StringReference receiverName() { return messageReceiverName(); }
615 static IPC::StringReference name() { return IPC::StringReference("ConfirmDidCloseFromServer"); }
616 static const bool isSync = false;
617
618 explicit ConfirmDidCloseFromServer(uint64_t databaseConnectionIdentifier)
619 : m_arguments(databaseConnectionIdentifier)
620 {
621 }
622
623 const Arguments& arguments() const
624 {
625 return m_arguments;
626 }
627
628private:
629 Arguments m_arguments;
630};
631
632class GetAllDatabaseNames {
633public:
634 typedef std::tuple<uint64_t, const WebCore::SecurityOriginData&, const WebCore::SecurityOriginData&, uint64_t> Arguments;
635
636 static IPC::StringReference receiverName() { return messageReceiverName(); }
637 static IPC::StringReference name() { return IPC::StringReference("GetAllDatabaseNames"); }
638 static const bool isSync = false;
639
640 GetAllDatabaseNames(uint64_t serverConnectionIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID)
641 : m_arguments(serverConnectionIdentifier, topOrigin, openingOrigin, callbackID)
642 {
643 }
644
645 const Arguments& arguments() const
646 {
647 return m_arguments;
648 }
649
650private:
651 Arguments m_arguments;
652};
653
654} // namespace WebIDBConnectionToClient
655} // namespace Messages
656
657#endif // ENABLE(INDEXED_DATABASE)
658