Changeset 295189 in webkit
- Timestamp:
- Jun 2, 2022, 11:45:44 PM (4 years ago)
- Location:
- branches/safari-613-branch/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
Modules/cache/WorkerCacheStorageConnection.cpp (modified) (3 diffs)
-
Modules/cache/WorkerCacheStorageConnection.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-613-branch/Source/WebCore/ChangeLog
r295187 r295189 1 2022-05-10 Youenn Fablet <youenn@apple.com> 2 3 Create a stopped CacheStorageConnection for workers in case of detached documents 4 https://bugs.webkit.org/show_bug.cgi?id=240224 5 <rdar://problem/92853663> 6 7 Reviewed by Chris Dumez. 8 9 A worker might not always have a main thread connection as its document may be detached. 10 In that case, we now create a StoppedCacheStorageConnection that will always return Error::Stopped to any callback. 11 12 Covered by existing tests. 13 14 * Modules/cache/WorkerCacheStorageConnection.cpp: 15 (WebCore::StoppedCacheStorageConnection::create): 16 (WebCore::createMainThreadConnection): 17 (WebCore::WorkerCacheStorageConnection::WorkerCacheStorageConnection): 18 (WebCore::WorkerCacheStorageConnection::~WorkerCacheStorageConnection): 19 (WebCore::WorkerCacheStorageConnection::create): Deleted. 20 * Modules/cache/WorkerCacheStorageConnection.h: 21 1 22 2022-05-13 Brent Fulgham <bfulgham@apple.com> 2 23 -
branches/safari-613-branch/Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
r282860 r295189 32 32 #include "ClientOrigin.h" 33 33 #include "Document.h" 34 #include "Logging.h" 34 35 #include "Page.h" 35 36 #include "WorkerGlobalScope.h" … … 114 115 } 115 116 116 Ref<WorkerCacheStorageConnection> WorkerCacheStorageConnection::create(WorkerGlobalScope& scope) 117 { 118 auto connection = adoptRef(*new WorkerCacheStorageConnection(scope)); 119 callOnMainThreadAndWait([workerThread = Ref { scope.thread() }, connection = connection.ptr()]() mutable { 120 connection->m_mainThreadConnection = workerThread->workerLoaderProxy().createCacheStorageConnection(); 121 }); 122 ASSERT(connection->m_mainThreadConnection); 123 return connection; 117 class StoppedCacheStorageConnection final : public CacheStorageConnection { 118 public: 119 static Ref<CacheStorageConnection> create() { return adoptRef(*new StoppedCacheStorageConnection); } 120 121 private: 122 void open(const ClientOrigin&, const String&, DOMCacheEngine::CacheIdentifierCallback&& callback) final { callback(makeUnexpected(DOMCacheEngine::Error::Stopped)); } 123 void remove(uint64_t, DOMCacheEngine::CacheIdentifierCallback&& callback) final { callback(makeUnexpected(DOMCacheEngine::Error::Stopped)); } 124 void retrieveCaches(const ClientOrigin&, uint64_t, DOMCacheEngine::CacheInfosCallback&& callback) final { callback(makeUnexpected(DOMCacheEngine::Error::Stopped)); } 125 void retrieveRecords(uint64_t, RetrieveRecordsOptions&&, DOMCacheEngine::RecordsCallback&& callback) final { callback(makeUnexpected(DOMCacheEngine::Error::Stopped)); } 126 void batchDeleteOperation(uint64_t, const ResourceRequest&, CacheQueryOptions&&, DOMCacheEngine::RecordIdentifiersCallback&& callback) final { callback(makeUnexpected(DOMCacheEngine::Error::Stopped)); } 127 void batchPutOperation(uint64_t, Vector<DOMCacheEngine::Record>&&, DOMCacheEngine::RecordIdentifiersCallback&& callback) final { callback(makeUnexpected(DOMCacheEngine::Error::Stopped)); } 128 void reference(uint64_t) final { } 129 void dereference(uint64_t) final { } 130 }; 131 132 static Ref<CacheStorageConnection> createMainThreadConnection(WorkerGlobalScope& scope) 133 { 134 RefPtr<CacheStorageConnection> mainThreadConnection; 135 callOnMainThreadAndWait([workerThread = Ref { scope.thread() }, &mainThreadConnection]() mutable { 136 mainThreadConnection = workerThread->workerLoaderProxy().createCacheStorageConnection(); 137 if (!mainThreadConnection) { 138 RELEASE_LOG_INFO(ServiceWorker, "Creating stopped WorkerCacheStorageConnection"); 139 mainThreadConnection = StoppedCacheStorageConnection::create(); 140 } 141 }); 142 return mainThreadConnection.releaseNonNull(); 124 143 } 125 144 126 145 WorkerCacheStorageConnection::WorkerCacheStorageConnection(WorkerGlobalScope& scope) 127 146 : m_scope(scope) 147 , m_mainThreadConnection(createMainThreadConnection(scope)) 128 148 { 129 149 } … … 131 151 WorkerCacheStorageConnection::~WorkerCacheStorageConnection() 132 152 { 133 if (m_mainThreadConnection) 134 callOnMainThread([mainThreadConnection = WTFMove(m_mainThreadConnection)]() mutable { }); 153 callOnMainThread([mainThreadConnection = WTFMove(m_mainThreadConnection)]() mutable { }); 135 154 } 136 155 -
branches/safari-613-branch/Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h
r283069 r295189 38 38 class WorkerCacheStorageConnection final : public CacheStorageConnection { 39 39 public: 40 static Ref<WorkerCacheStorageConnection> create(WorkerGlobalScope& );40 static Ref<WorkerCacheStorageConnection> create(WorkerGlobalScope& scope) { return adoptRef(*new WorkerCacheStorageConnection(scope)); } 41 41 ~WorkerCacheStorageConnection(); 42 42 … … 73 73 WorkerGlobalScope& m_scope; 74 74 75 Ref Ptr<CacheStorageConnection> m_mainThreadConnection;75 Ref<CacheStorageConnection> m_mainThreadConnection; 76 76 77 77 HashMap<uint64_t, DOMCacheEngine::CacheIdentifierCallback> m_openAndRemoveCachePendingRequests;
Note:
See TracChangeset
for help on using the changeset viewer.