FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WebKit/Source/WebKitLegacy/Storage/InProcessIDBServer.cpp at main · DaRkZ2012/WebKit · GitHub
DaRkZ2012
/
WebKit
Public
forked from
WebKit/WebKit
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
WebKit
/
Source
/
WebKitLegacy
/
Storage
/
InProcessIDBServer.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
512 lines (445 loc) · 22.8 KB
Breadcrumbs
WebKit
/
Source
/
WebKitLegacy
/
Storage
/
InProcessIDBServer.cpp
Copy path
File metadata and controls
512 lines (445 loc) · 22.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
/*
* Copyright (C) 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#
include
"
InProcessIDBServer.h
"
#
include
<
WebCore/ClientOrigin.h
>
#
include
<
WebCore/IDBConnectionToClient.h
>
#
include
<
WebCore/IDBConnectionToServer.h
>
#
include
<
WebCore/IDBCursorInfo.h
>
#
include
<
WebCore/IDBGetRecordData.h
>
#
include
<
WebCore/IDBIterateCursorData.h
>
#
include
<
WebCore/IDBKeyRangeData.h
>
#
include
<
WebCore/IDBOpenDBRequest.h
>
#
include
<
WebCore/IDBRequestData.h
>
#
include
<
WebCore/IDBResultData.h
>
#
include
<
WebCore/IDBTransactionInfo.h
>
#
include
<
WebCore/IDBValue.h
>
#
include
<
wtf/WorkQueue.h
>
#
include
<
wtf/threads/BinarySemaphore.h
>
using
namespace
WebCore
;
Ref<InProcessIDBServer>
InProcessIDBServer::create
(
PAL
::SessionID sessionID)
{
ASSERT
(sessionID.
isEphemeral
());
return
adoptRef
(*
new
InProcessIDBServer
(sessionID));
}
Ref<InProcessIDBServer>
InProcessIDBServer::create
(
PAL
::SessionID sessionID,
const
String& databaseDirectoryPath)
{
ASSERT
(!sessionID.
isEphemeral
());
return
adoptRef
(*
new
InProcessIDBServer
(sessionID, databaseDirectoryPath));
}
InProcessIDBServer::~InProcessIDBServer
()
{
BinarySemaphore semaphore;
dispatchTask
([
this
, &semaphore] {
{
Locker locker { m_serverLock };
m_server =
nullptr
;
}
m_connectionToClient =
nullptr
;
semaphore.
signal
();
});
semaphore.
wait
();
}
InProcessIDBServer::InProcessIDBServer
(
PAL
::SessionID sessionID,
const
String& databaseDirectoryPath)
: m_queue(WorkQueue::create(
"
com.apple.WebKit.IndexedDBServer
"
_s))
{
ASSERT
(
isMainThread
());
m_connectionToServer =
IDBClient::IDBConnectionToServer::create
(*
this
, sessionID);
dispatchTask
([
this
, protectedThis = Ref { *
this
}, directory = databaseDirectoryPath.
isolatedCopy
()] ()
mutable
{
Ref connectionToClient =
IDBServer::IDBConnectionToClient::create
(*
this
);
m_connectionToClient = connectionToClient.
copyRef
();
Locker locker { m_serverLock };
m_server = makeUnique<IDBServer::IDBServer>(directory, [](
const
ClientOrigin&,
uint64_t
) {
return
true
;
}, m_serverLock);
m_server->
registerConnection
(connectionToClient);
});
}
std::optional<IDBConnectionIdentifier>
InProcessIDBServer::identifier
()
const
{
//
An instance of InProcessIDBServer always has a 1:1 relationship with its instance of IDBServer.
//
Therefore the connection identifier between the two can always be "1".
return
Process::identifier
();
}
IDBClient::IDBConnectionToServer&
InProcessIDBServer::connectionToServer
()
const
{
return
*m_connectionToServer;
}
IDBServer::IDBConnectionToClient&
InProcessIDBServer::connectionToClient
()
const
{
return
*m_connectionToClient;
}
void
InProcessIDBServer::deleteDatabase
(
const
WebCore::IDBOpenRequestData& requestData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
deleteDatabase
(requestData);
});
}
void
InProcessIDBServer::didDeleteDatabase
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didDeleteDatabase
(resultData);
});
}
void
InProcessIDBServer::openDatabase
(
const
WebCore::IDBOpenRequestData& requestData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
openDatabase
(requestData);
});
}
void
InProcessIDBServer::didOpenDatabase
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didOpenDatabase
(resultData);
});
}
void
InProcessIDBServer::didAbortTransaction
(
const
WebCore::IDBResourceIdentifier& transactionIdentifier,
const
IDBError& error)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, transactionIdentifier = transactionIdentifier.
isolatedCopy
(), error = error.
isolatedCopy
()] {
m_connectionToServer->
didAbortTransaction
(transactionIdentifier, error);
});
}
void
InProcessIDBServer::didCommitTransaction
(
const
WebCore::IDBResourceIdentifier& transactionIdentifier,
const
IDBError& error)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, transactionIdentifier = transactionIdentifier.
isolatedCopy
(), error = error.
isolatedCopy
()] {
m_connectionToServer->
didCommitTransaction
(transactionIdentifier, error);
});
}
void
InProcessIDBServer::didCreateObjectStore
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didCreateObjectStore
(resultData);
});
}
void
InProcessIDBServer::didDeleteObjectStore
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didDeleteObjectStore
(resultData);
});
}
void
InProcessIDBServer::didRenameObjectStore
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didRenameObjectStore
(resultData);
});
}
void
InProcessIDBServer::didClearObjectStore
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didClearObjectStore
(resultData);
});
}
void
InProcessIDBServer::didCreateIndex
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didCreateIndex
(resultData);
});
}
void
InProcessIDBServer::didDeleteIndex
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didDeleteIndex
(resultData);
});
}
void
InProcessIDBServer::didRenameIndex
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didRenameIndex
(resultData);
});
}
void
InProcessIDBServer::didPutOrAdd
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didPutOrAdd
(resultData);
});
}
void
InProcessIDBServer::didGetRecord
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didGetRecord
(resultData);
});
}
void
InProcessIDBServer::didGetAllRecords
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didGetAllRecords
(resultData);
});
}
void
InProcessIDBServer::didGetCount
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didGetCount
(resultData);
});
}
void
InProcessIDBServer::didDeleteRecord
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didDeleteRecord
(resultData);
});
}
void
InProcessIDBServer::didOpenCursor
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didOpenCursor
(resultData);
});
}
void
InProcessIDBServer::didIterateCursor
(
const
IDBResultData& resultData)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
()] {
m_connectionToServer->
didIterateCursor
(resultData);
});
}
void
InProcessIDBServer::abortTransaction
(
const
WebCore::IDBResourceIdentifier& resourceIdentifier)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, resourceIdentifier = resourceIdentifier.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
abortTransaction
(resourceIdentifier);
});
}
void
InProcessIDBServer::commitTransaction
(
const
WebCore::IDBResourceIdentifier& resourceIdentifier,
uint64_t
pendingCountRequest)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, resourceIdentifier = resourceIdentifier.
isolatedCopy
(), pendingCountRequest] {
Locker locker { m_serverLock };
m_server->
commitTransaction
(resourceIdentifier, pendingCountRequest);
});
}
void
InProcessIDBServer::didFinishHandlingVersionChangeTransaction
(IDBDatabaseConnectionIdentifier databaseConnectionIdentifier,
const
WebCore::IDBResourceIdentifier& transactionIdentifier)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier, transactionIdentifier = transactionIdentifier.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
didFinishHandlingVersionChangeTransaction
(databaseConnectionIdentifier, transactionIdentifier);
});
}
void
InProcessIDBServer::createObjectStore
(
const
WebCore::IDBRequestData& resultData,
const
IDBObjectStoreInfo& info)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, resultData = resultData.
isolatedCopy
(), info = info.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
createObjectStore
(resultData, info);
});
}
void
InProcessIDBServer::deleteObjectStore
(
const
WebCore::IDBRequestData& requestData,
const
String& objectStoreName)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), objectStoreName = objectStoreName.
isolatedCopy
()] ()
mutable
{
Locker locker { m_serverLock };
m_server->
deleteObjectStore
(requestData, objectStoreName);
});
}
void
InProcessIDBServer::renameObjectStore
(
const
WebCore::IDBRequestData& requestData, WebCore::IDBObjectStoreIdentifier objectStoreIdentifier,
const
String& newName)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), objectStoreIdentifier, newName = newName.
isolatedCopy
()] ()
mutable
{
Locker locker { m_serverLock };
m_server->
renameObjectStore
(requestData, objectStoreIdentifier, newName);
});
}
void
InProcessIDBServer::clearObjectStore
(
const
WebCore::IDBRequestData& requestData, WebCore::IDBObjectStoreIdentifier objectStoreIdentifier)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), objectStoreIdentifier] {
Locker locker { m_serverLock };
m_server->
clearObjectStore
(requestData, objectStoreIdentifier);
});
}
void
InProcessIDBServer::createIndex
(
const
WebCore::IDBRequestData& requestData,
const
IDBIndexInfo& info)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), info = info.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
createIndex
(requestData, info);
});
}
void
InProcessIDBServer::deleteIndex
(
const
WebCore::IDBRequestData& requestData, WebCore::IDBObjectStoreIdentifier objectStoreIdentifier,
const
String& indexName)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), objectStoreIdentifier, indexName = indexName.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
deleteIndex
(requestData, objectStoreIdentifier, indexName);
});
}
void
InProcessIDBServer::renameIndex
(
const
WebCore::IDBRequestData& requestData, WebCore::IDBObjectStoreIdentifier objectStoreIdentifier, WebCore::IDBIndexIdentifier indexIdentifier,
const
String& newName)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), objectStoreIdentifier, indexIdentifier, newName = newName.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
renameIndex
(requestData, objectStoreIdentifier, indexIdentifier, newName);
});
}
void
InProcessIDBServer::putOrAdd
(
const
WebCore::IDBRequestData& requestData,
const
IDBKeyData& keyData,
const
IDBValue& value,
const
IndexIDToIndexKeyMap& indexKeys,
const
IndexedDB::ObjectStoreOverwriteMode overwriteMode)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), keyData = keyData.
isolatedCopy
(), value = value.
isolatedCopy
(), indexKeys =
crossThreadCopy
(indexKeys), overwriteMode] {
Locker locker { m_serverLock };
m_server->
putOrAdd
(requestData, keyData, value, indexKeys, overwriteMode);
});
}
void
InProcessIDBServer::getRecord
(
const
WebCore::IDBRequestData& requestData,
const
IDBGetRecordData& getRecordData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), getRecordData = getRecordData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
getRecord
(requestData, getRecordData);
});
}
void
InProcessIDBServer::getAllRecords
(
const
WebCore::IDBRequestData& requestData,
const
IDBGetAllRecordsData& getAllRecordsData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), getAllRecordsData = getAllRecordsData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
getAllRecords
(requestData, getAllRecordsData);
});
}
void
InProcessIDBServer::getCount
(
const
WebCore::IDBRequestData& requestData,
const
IDBKeyRangeData& keyRangeData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), keyRangeData = keyRangeData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
getCount
(requestData, keyRangeData);
});
}
void
InProcessIDBServer::deleteRecord
(
const
WebCore::IDBRequestData& requestData,
const
IDBKeyRangeData& keyRangeData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), keyRangeData = keyRangeData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
deleteRecord
(requestData, keyRangeData);
});
}
void
InProcessIDBServer::openCursor
(
const
WebCore::IDBRequestData& requestData,
const
IDBCursorInfo& info)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), info = info.
isolatedCopy
()] ()
mutable
{
Locker locker { m_serverLock };
m_server->
openCursor
(requestData, info);
});
}
void
InProcessIDBServer::iterateCursor
(
const
WebCore::IDBRequestData& requestData,
const
IDBIterateCursorData& data)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
(), data = data.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
iterateCursor
(requestData, data);
});
}
void
InProcessIDBServer::establishTransaction
(IDBDatabaseConnectionIdentifier databaseConnectionIdentifier,
const
IDBTransactionInfo& info)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier, info = info.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
establishTransaction
(databaseConnectionIdentifier, info);
});
}
void
InProcessIDBServer::fireVersionChangeEvent
(IDBServer::UniqueIDBDatabaseConnection& connection,
const
WebCore::IDBResourceIdentifier& requestIdentifier,
uint64_t
requestedVersion)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier = connection.
identifier
(), requestIdentifier = requestIdentifier.
isolatedCopy
(), requestedVersion] {
m_connectionToServer->
fireVersionChangeEvent
(databaseConnectionIdentifier, requestIdentifier, requestedVersion);
});
}
void
InProcessIDBServer::generateIndexKeyForRecord
(
const
WebCore::IDBResourceIdentifier& requestIdentifier,
const
WebCore::IDBIndexInfo& indexInfo,
const
std::optional<WebCore::IDBKeyPath>& keyPath,
const
WebCore::IDBKeyData& key,
const
WebCore::IDBValue& value, std::optional<
int64_t
> recordID)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, requestIdentifier =
crossThreadCopy
(requestIdentifier), indexInfo =
crossThreadCopy
(indexInfo), keyPath =
crossThreadCopy
(keyPath), key =
crossThreadCopy
(key), value =
crossThreadCopy
(value), recordID] {
m_connectionToServer->
generateIndexKeyForRecord
(requestIdentifier, indexInfo, keyPath, key, value, recordID);
});
}
void
InProcessIDBServer::didStartTransaction
(
const
WebCore::IDBResourceIdentifier& transactionIdentifier,
const
IDBError& error)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, transactionIdentifier = transactionIdentifier.
isolatedCopy
(), error = error.
isolatedCopy
()] {
m_connectionToServer->
didStartTransaction
(transactionIdentifier, error);
});
}
void
InProcessIDBServer::didCloseFromServer
(IDBServer::UniqueIDBDatabaseConnection& connection,
const
IDBError& error)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier = connection.
identifier
(), error = error.
isolatedCopy
()] {
m_connectionToServer->
didCloseFromServer
(databaseConnectionIdentifier, error);
});
}
void
InProcessIDBServer::notifyOpenDBRequestBlocked
(
const
WebCore::IDBResourceIdentifier& requestIdentifier,
uint64_t
oldVersion,
uint64_t
newVersion)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, requestIdentifier = requestIdentifier.
isolatedCopy
(), oldVersion, newVersion] {
m_connectionToServer->
notifyOpenDBRequestBlocked
(requestIdentifier, oldVersion, newVersion);
});
}
void
InProcessIDBServer::databaseConnectionPendingClose
(IDBDatabaseConnectionIdentifier databaseConnectionIdentifier)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier] {
Locker locker { m_serverLock };
m_server->
databaseConnectionPendingClose
(databaseConnectionIdentifier);
});
}
void
InProcessIDBServer::databaseConnectionClosed
(IDBDatabaseConnectionIdentifier databaseConnectionIdentifier)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier] {
Locker locker { m_serverLock };
m_server->
databaseConnectionClosed
(databaseConnectionIdentifier);
});
}
void
InProcessIDBServer::abortOpenAndUpgradeNeeded
(IDBDatabaseConnectionIdentifier databaseConnectionIdentifier,
const
std::optional<WebCore::IDBResourceIdentifier>& transactionIdentifier)
{
std::optional<WebCore::IDBResourceIdentifier> transactionIdentifierCopy;
if
(transactionIdentifier)
transactionIdentifierCopy = transactionIdentifier->
isolatedCopy
();
dispatchTask
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier, transactionIdentifier =
WTFMove
(transactionIdentifierCopy)] {
Locker locker { m_serverLock };
m_server->
abortOpenAndUpgradeNeeded
(databaseConnectionIdentifier, transactionIdentifier);
});
}
void
InProcessIDBServer::didFireVersionChangeEvent
(IDBDatabaseConnectionIdentifier databaseConnectionIdentifier,
const
WebCore::IDBResourceIdentifier& requestIdentifier,
const
IndexedDB::ConnectionClosedOnBehalfOfServer connectionClosed)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, databaseConnectionIdentifier, requestIdentifier =
crossThreadCopy
(requestIdentifier), connectionClosed] {
Locker locker { m_serverLock };
m_server->
didFireVersionChangeEvent
(databaseConnectionIdentifier, requestIdentifier, connectionClosed);
});
}
void
InProcessIDBServer::didGenerateIndexKeyForRecord
(
const
IDBResourceIdentifier& transactionIdentifier,
const
IDBResourceIdentifier& requestIdentifier,
const
IDBIndexInfo& indexInfo,
const
IDBKeyData& key,
const
IndexKey& indexKey, std::optional<
int64_t
> recordID)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, transactionIdentifier =
crossThreadCopy
(transactionIdentifier), requestIdentifier =
crossThreadCopy
(requestIdentifier), indexInfo =
crossThreadCopy
(indexInfo), key =
crossThreadCopy
(key), indexKey =
crossThreadCopy
(indexKey), recordID] {
Locker locker { m_serverLock };
m_server->
didGenerateIndexKeyForRecord
(transactionIdentifier, requestIdentifier, indexInfo, key, indexKey, recordID);
});
}
void
InProcessIDBServer::openDBRequestCancelled
(
const
WebCore::IDBOpenRequestData& requestData)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, requestData = requestData.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
openDBRequestCancelled
(requestData);
});
}
void
InProcessIDBServer::getAllDatabaseNamesAndVersions
(
const
WebCore::IDBResourceIdentifier& requestIdentifier,
const
ClientOrigin& origin)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, identifier = m_connectionToServer->
identifier
(), requestIdentifier, origin = origin.
isolatedCopy
()] {
Locker locker { m_serverLock };
m_server->
getAllDatabaseNamesAndVersions
(identifier, requestIdentifier, origin);
});
}
void
InProcessIDBServer::didGetAllDatabaseNamesAndVersions
(
const
WebCore::IDBResourceIdentifier& requestIdentifier, Vector<WebCore::IDBDatabaseNameAndVersion>&& databases)
{
dispatchTaskReply
([
this
, protectedThis = Ref { *
this
}, requestIdentifier, databases =
crossThreadCopy
(
WTFMove
(databases))]()
mutable
{
m_connectionToServer->
didGetAllDatabaseNamesAndVersions
(requestIdentifier,
WTFMove
(databases));
});
}
void
InProcessIDBServer::closeAndDeleteDatabasesModifiedSince
(WallTime modificationTime)
{
dispatchTask
([
this
, protectedThis = Ref { *
this
}, modificationTime] {
Locker locker { m_serverLock };
m_server->
closeAndDeleteDatabasesModifiedSince
(modificationTime);
});
}
void
InProcessIDBServer::dispatchTask
(Function<
void
()>&& function)
{
ASSERT
(
isMainThread
());
m_queue->
dispatch
(
WTFMove
(function));
}
void
InProcessIDBServer::dispatchTaskReply
(Function<
void
()>&& function)
{
ASSERT
(!
isMainThread
());
callOnMainThread
(
WTFMove
(function));
}
Back
|
FazBrowse Home
|
New Git URL