RESOLVED FIXED 230675
Make StorageManager available in Worker
https://bugs.webkit.org/show_bug.cgi?id=230675
Summary Make StorageManager available in Worker
Sihui Liu
Reported 2021-09-23 01:29:47 PDT
...
Attachments
Patch (32.06 KB, patch)
2021-09-23 01:42 PDT, Sihui Liu
no flags
Patch (32.54 KB, patch)
2021-09-23 08:20 PDT, Sihui Liu
no flags
Patch (96.39 KB, patch)
2021-09-24 08:42 PDT, Sihui Liu
no flags
Patch (91.80 KB, patch)
2021-09-27 11:43 PDT, Sihui Liu
ews-feeder: commit-queue-
Patch (99.56 KB, patch)
2021-09-27 11:49 PDT, Sihui Liu
no flags
Patch (99.65 KB, patch)
2021-09-27 13:11 PDT, Sihui Liu
no flags
Patch (102.40 KB, patch)
2021-09-27 14:39 PDT, Sihui Liu
no flags
Patch (102.42 KB, patch)
2021-09-27 21:49 PDT, Sihui Liu
no flags
Patch for landing (106.22 KB, patch)
2021-09-28 10:20 PDT, Sihui Liu
no flags
Sihui Liu
Comment 1 2021-09-23 01:42:21 PDT
Sihui Liu
Comment 2 2021-09-23 08:20:41 PDT
Radar WebKit Bug Importer
Comment 3 2021-09-23 08:25:55 PDT
Sihui Liu
Comment 4 2021-09-24 08:42:56 PDT
Sihui Liu
Comment 5 2021-09-27 11:43:14 PDT
Sihui Liu
Comment 6 2021-09-27 11:49:17 PDT
youenn fablet
Comment 7 2021-09-27 12:41:15 PDT
Comment on attachment 439374 [details] Patch Looks good to me overall, a few improvement ideas below. View in context: https://bugs.webkit.org/attachment.cgi?id=439374&action=review > Source/WebCore/Modules/storage/StorageConnection.h:37 > +class StorageConnection : public ThreadSafeRefCounted<StorageConnection> { I would mark it as DestructionThread::MainRunLoop for extra safety. > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:52 > + callOnMainThreadAndWait([mainThreadConnection = WTFMove(m_mainThreadConnection)]() mutable { }); Not needed with DestructionThread::Main/MainRunLoop > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:66 > + if (!m_scope) I would add ASSERT(m_scope). > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:76 > + downcast<WorkerStorageConnection>(*storageConnection).didGetPersisted(callbackIdentifier, result); Ideally, we would not need that, WorkerGlobalScope could just return a WorkerStorageConnection, which would remove the need for isWorker(). > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:91 > + if (!m_scope) Ditto here > Source/WebCore/Modules/storage/WorkerStorageConnection.h:40 > + void didGetPersisted(uint64_t callbackIdentifier, bool result); Should be private > Source/WebCore/Modules/storage/WorkerStorageConnection.h:43 > + WorkerStorageConnection(WorkerGlobalScope&); explicit > Source/WebCore/Modules/storage/WorkerStorageConnection.h:50 > + RefPtr<WorkerGlobalScope> m_scope; WeakPtr to cut ref cycles? > Source/WebCore/workers/WorkerGlobalScope.cpp:221 > +StorageConnection* WorkerGlobalScope::storageConnection() Should be &, ideally WorkerStorageConnection& > Source/WebCore/workers/WorkerGlobalScope.h:85 > + StorageConnection* storageConnection() final; Not sure whether we need a virtual storageConnection(), maybe we can have one for Document and one for WorkerGlobalScope, but not on ScriptExecutionContext.
Sihui Liu
Comment 8 2021-09-27 13:11:59 PDT
Sihui Liu
Comment 9 2021-09-27 14:39:19 PDT
Sihui Liu
Comment 10 2021-09-27 21:49:00 PDT
youenn fablet
Comment 11 2021-09-28 00:47:43 PDT
Comment on attachment 439432 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=439432&action=review > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:46 > + m_mainThreadConnection = scope.thread().workerLoaderProxy().storageConnection(); storageConnection() is currently a pointer so m_mainThreadConnection can be nullptr for instance in getPersisted. Maybe we can guarantee to have a reference here which will make sure m_mainThreadConnection is not null. > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:71 > + callOnMainThread([callbackIdentifier, workerThread = Ref { m_scope->thread() }, mainThreadConnection = m_mainThreadConnection, origin = origin.isolatedCopy()]() mutable { Since we are taking a ref to the worker thread, another strategy is to not have m_mainThreadConnection and retrieve it from worker thread loader proxy each time we need it from main thread. I would tend to do this plus a null check on the connection. > Source/WebCore/Modules/storage/WorkerStorageConnection.cpp:72 > + auto mainThreadCallback = [callbackIdentifier, workerThread = WTFMove(workerThread)](auto result) mutable { Let's use bool here. If in the future, we want to have ExceptionOr<bool>, we will need to change the code and maybe isolate copy it.
Sihui Liu
Comment 12 2021-09-28 10:20:56 PDT
Created attachment 439492 [details] Patch for landing
EWS
Comment 13 2021-09-28 11:09:00 PDT
Committed r283184 (242232@main): <https://commits.webkit.org/242232@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 439492 [details].
Note You need to log in before you can comment on or make changes to this bug.