Changeset 251934 in webkit
- Timestamp:
- Nov 1, 2019 12:34:33 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251930 r251934 1 2019-11-01 Chris Dumez <cdumez@apple.com> 2 3 Port ServiceWorkerContainer to the HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=203680 5 6 Reviewed by Ryosuke Niwa. 7 8 * dom/AbstractEventLoop.h: 9 * workers/service/ServiceWorkerContainer.cpp: 10 (WebCore::ServiceWorkerContainer::ServiceWorkerContainer): 11 (WebCore::ServiceWorkerContainer::ready): 12 (WebCore::ServiceWorkerContainer::getRegistration): 13 (WebCore::ServiceWorkerContainer::getRegistrations): 14 (WebCore::ServiceWorkerContainer::jobFailedWithException): 15 (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): 16 (WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult): 17 (WebCore::ServiceWorkerContainer::jobFailedLoadingScript): 18 (WebCore::ServiceWorkerContainer::enqueueTask): 19 * workers/service/ServiceWorkerContainer.h: 20 1 21 2019-11-01 Ryosuke Niwa <rniwa@webkit.org> 2 22 -
trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp
r251691 r251934 66 66 void DeferredPromise::whenSettled(Function<void()>&& callback) 67 67 { 68 if (isSuspended()) 69 return; 70 68 71 DOMPromise::whenPromiseIsSettled(globalObject(), deferred(), WTFMove(callback)); 69 72 } -
trunk/Source/WebCore/dom/AbstractEventLoop.h
r251792 r251934 34 34 35 35 enum class TaskSource : uint8_t { 36 DOMManipulation, 36 37 IdleTask, 37 38 Networking, -
trunk/Source/WebCore/workers/WorkerEventLoop.cpp
r251792 r251934 47 47 : ActiveDOMObject(&context) 48 48 { 49 suspendIfNeeded(); 49 50 } 50 51 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp
r251244 r251934 29 29 #if ENABLE(SERVICE_WORKER) 30 30 31 #include "AbstractEventLoop.h" 31 32 #include "DOMPromiseProxy.h" 32 33 #include "Document.h" … … 74 75 , m_navigator(navigator) 75 76 , m_messageQueue(GenericEventQueue::create(*this)) 76 , m_taskQueue(SuspendableTaskQueue::create(context))77 77 { 78 78 suspendIfNeeded(); … … 110 110 auto& context = *scriptExecutionContext(); 111 111 ensureSWClientConnection().whenRegistrationReady(context.topOrigin().data(), context.url(), [this, protectedThis = makeRef(*this)](auto&& registrationData) mutable { 112 m_taskQueue->enqueueTask([this, registrationData = WTFMove(registrationData)]() mutable {112 enqueueTask([this, registrationData = WTFMove(registrationData)]() mutable { 113 113 auto registration = ServiceWorkerRegistration::getOrCreate(*scriptExecutionContext(), *this, WTFMove(registrationData)); 114 114 m_readyPromise->resolve(WTFMove(registration)); … … 272 272 273 273 ensureSWClientConnection().matchRegistration(SecurityOriginData { context.topOrigin().data() }, parsedURL, [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](auto&& result) mutable { 274 m_taskQueue->enqueueTask([this, promise = WTFMove(promise), result = WTFMove(result)]() mutable {274 enqueueTask([this, promise = WTFMove(promise), result = WTFMove(result)]() mutable { 275 275 if (!result) { 276 276 promise->resolve(); … … 304 304 auto& context = *scriptExecutionContext(); 305 305 ensureSWClientConnection().getRegistrations(SecurityOriginData { context.topOrigin().data() }, context.url(), [this, protectedThis = makeRef(*this), promise = WTFMove(promise)] (auto&& registrationDatas) mutable { 306 m_taskQueue->enqueueTask([this, promise = WTFMove(promise), registrationDatas = WTFMove(registrationDatas)]() mutable {306 enqueueTask([this, promise = WTFMove(promise), registrationDatas = WTFMove(registrationDatas)]() mutable { 307 307 auto registrations = WTF::map(WTFMove(registrationDatas), [&](auto&& registrationData) { 308 308 return ServiceWorkerRegistration::getOrCreate(*scriptExecutionContext(), *this, WTFMove(registrationData)); … … 336 336 return; 337 337 338 m_taskQueue->enqueueTask([promise = WTFMove(promise), exception]() mutable {338 enqueueTask([promise = WTFMove(promise), exception]() mutable { 339 339 promise->reject(exception); 340 340 }); … … 381 381 return; 382 382 383 m_taskQueue->enqueueTask([this, protectedThis = makeRef(*this), promise = WTFMove(promise), jobIdentifier = job.identifier(), data = WTFMove(data), shouldNotifyWhenResolved, notifyIfExitEarly = WTFMove(notifyIfExitEarly)]() mutable {383 enqueueTask([this, promise = WTFMove(promise), jobIdentifier = job.identifier(), data = WTFMove(data), shouldNotifyWhenResolved, notifyIfExitEarly = WTFMove(notifyIfExitEarly)]() mutable { 384 384 notifyIfExitEarly.release(); 385 385 … … 390 390 if (shouldNotifyWhenResolved == ShouldNotifyWhenResolved::Yes) { 391 391 m_ongoingSettledRegistrations.add(++m_lastOngoingSettledRegistrationIdentifier, registration->data().key); 392 promise->whenSettled([this, protectedThis = WTFMove(protectedThis), identifier = m_lastOngoingSettledRegistrationIdentifier] {392 promise->whenSettled([this, protectedThis = makeRef(*this), identifier = m_lastOngoingSettledRegistrationIdentifier] { 393 393 notifyRegistrationIsSettled(m_ongoingSettledRegistrations.take(identifier)); 394 394 }); … … 436 436 } 437 437 438 m_taskQueue->enqueueTask([promise = job.takePromise(), unregistrationResult]() mutable {438 enqueueTask([promise = job.takePromise(), unregistrationResult]() mutable { 439 439 promise->resolve<IDLBoolean>(unregistrationResult); 440 440 }); … … 483 483 484 484 if (auto promise = job.takePromise()) { 485 m_taskQueue->enqueueTask([promise = WTFMove(promise), exception = WTFMove(exception)]() mutable {485 enqueueTask([promise = WTFMove(promise), exception = WTFMove(exception)]() mutable { 486 486 promise->reject(WTFMove(exception)); 487 487 }); … … 553 553 #endif 554 554 555 if (m_isStopped) 556 return; 557 558 dispatchEvent(Event::create(eventNames().controllerchangeEvent, Event::CanBubble::No, Event::IsCancelable::No)); 555 enqueueTask([this] { 556 dispatchEvent(Event::create(eventNames().controllerchangeEvent, Event::CanBubble::No, Event::IsCancelable::No)); 557 }); 559 558 } 560 559 … … 620 619 } 621 620 621 void ServiceWorkerContainer::enqueueTask(Function<void()>&& task) 622 { 623 auto* context = scriptExecutionContext(); 624 if (!context) 625 return; 626 context->eventLoop().queueTask(TaskSource::DOMManipulation, *context, [protectedThis = makeRef(*this), pendingActivity = makePendingActivity(*this), task = WTFMove(task)] { 627 task(); 628 }); 629 } 630 622 631 } // namespace WebCore 623 632 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h
r251244 r251934 95 95 private: 96 96 bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { }) final; 97 void enqueueTask(Function<void()>&&); 97 98 98 99 void scheduleJob(std::unique_ptr<ServiceWorkerJob>&&); … … 145 146 HashMap<uint64_t, ServiceWorkerRegistrationKey> m_ongoingSettledRegistrations; 146 147 UniqueRef<GenericEventQueue> m_messageQueue; 147 UniqueRef<SuspendableTaskQueue> m_taskQueue;148 148 }; 149 149
Note: See TracChangeset
for help on using the changeset viewer.