Changeset 225491 in webkit
- Timestamp:
- Dec 4, 2017 1:56:25 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r225490 r225491 1 2017-12-04 Chris Dumez <cdumez@apple.com> 2 3 ServiceWorkerGlobalScope::skipWaiting(Ref<DeferredPromise>&&) is unsafe 4 https://bugs.webkit.org/show_bug.cgi?id=180372 5 6 Reviewed by Youenn Fablet. 7 8 Ref the WorkerThread and capture it in the lambda. Keep the pending promises in 9 a HashMap on the ServiceWorkerGlobalScope so that they stay on the worker thread. 10 11 * workers/service/ServiceWorkerGlobalScope.cpp: 12 (WebCore::ServiceWorkerGlobalScope::skipWaiting): 13 * workers/service/ServiceWorkerGlobalScope.h: 14 1 15 2017-12-04 Brady Eidson <beidson@apple.com> 2 16 -
trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp
r225460 r225491 51 51 void ServiceWorkerGlobalScope::skipWaiting(Ref<DeferredPromise>&& promise) 52 52 { 53 callOnMainThread([this, protectedThis = makeRef(*this), threadIdentifier = thread().identifier(), promise = WTFMove(promise)]() mutable { 53 uint64_t requestIdentifier = ++m_lastRequestIdentifier; 54 m_pendingSkipWaitingPromises.add(requestIdentifier, WTFMove(promise)); 55 56 callOnMainThread([workerThread = makeRef(thread()), requestIdentifier]() mutable { 54 57 if (auto* connection = SWContextManager::singleton().connection()) { 55 connection->skipWaiting(threadIdentifier, [this, protectedThis = WTFMove(protectedThis), promise = WTFMove(promise)]() mutable { 56 thread().runLoop().postTask([promise = WTFMove(promise), protectedThis = WTFMove(protectedThis)](auto&) { 57 promise->resolve(); 58 connection->skipWaiting(workerThread->identifier(), [workerThread = WTFMove(workerThread), requestIdentifier] { 59 workerThread->runLoop().postTask([requestIdentifier](auto& context) { 60 auto& scope = downcast<ServiceWorkerGlobalScope>(context); 61 if (auto promise = scope.m_pendingSkipWaitingPromises.take(requestIdentifier)) 62 promise->resolve(); 58 63 }); 59 64 }); -
trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h
r225351 r225491 78 78 HashMap<ServiceWorkerClientIdentifier, ServiceWorkerClient*> m_clientMap; 79 79 Vector<Ref<ExtendableEvent>> m_extendedEvents; 80 81 uint64_t m_lastRequestIdentifier { 0 }; 82 HashMap<uint64_t, RefPtr<DeferredPromise>> m_pendingSkipWaitingPromises; 80 83 }; 81 84
Note: See TracChangeset
for help on using the changeset viewer.