Changeset 249627 in webkit
- Timestamp:
- Sep 7, 2019 10:42:51 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-reuse-expected.txt
r224772 r249627 2 2 PASS: registration1 should not have a waiting worker 3 3 PASS: registration1 should have an active worker 4 PASS: Registration was reused4 PASS: Registration was not reused 5 5 -
trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-reuse.html
r224772 r249627 41 41 let registration2 = await navigator.serviceWorker.register("resources/basic-unregister-then-register-again-reuse-worker.js", { }); 42 42 if (registration1 === registration2) 43 log(" PASS: Registration was reused");43 log("FAIL: Registration was reused"); 44 44 else 45 log(" FAIL: Registration was not reused");45 log("PASS: Registration was not reused"); 46 46 } catch (e) { 47 47 log("FAIL: Got exception " + e); -
trunk/LayoutTests/imported/w3c/ChangeLog
r249615 r249627 1 2019-09-07 Chris Dumez <cdumez@apple.com> 2 3 [Service Workers] Drop support for registration resurrection 4 https://bugs.webkit.org/show_bug.cgi?id=201584 5 6 Reviewed by Alex Christensen. 7 8 Re-sync a couple of outdated WPT tests from upstream 820f0f86047e6e. 9 10 * web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https-expected.txt: 11 * web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https.html: 12 * web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt: 13 * web-platform-tests/service-workers/service-worker/unregister-then-register.https.html: 14 1 15 2019-09-07 Ryan Haddad <ryanhaddad@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https-expected.txt
r246363 r249627 1 1 2 2 PASS Registering a new script URL while an unregistered registration is in use 3 FAIL Registering a new script URL that 404s does not resurrect unregistered registration assert_equals: Document should not be controlled expected null but got object "[object ServiceWorker]" 4 FAIL Registering a new script URL that fails to install does not resurrect unregistered registration assert_equals: registration.active expected null but got object "[object ServiceWorker]" 3 PASS Registering a new script URL that 404s does not resurrect unregistered registration 4 PASS Registering a new script URL that fails to install does not resurrect unregistered registration 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https.html
r246363 r249627 23 23 24 24 assert_equals( 25 registration.installing .scriptURL,26 n ormalizeURL(newWorkerURL),25 registration.installing, 26 null, 27 27 'before activated registration.installing' 28 28 ); … … 48 48 ); 49 49 assert_equals( 50 newRegistration.active .scriptURL,51 n ormalizeURL(worker_url),50 newRegistration.active, 51 null, 52 52 'before activated newRegistration.active' 53 53 ); 54 54 iframe.remove(); 55 55 56 await wait_for_state(t, registration.installing, 'activated');56 await wait_for_state(t, newRegistration.installing, 'activated'); 57 57 58 58 assert_equals( … … 130 130 assert_equals(registration.installing, null, 'registration.installing'); 131 131 assert_equals(registration.waiting, null, 'registration.waiting'); 132 assert_equals(registration.active, null, 'registration.active'); 132 assert_equals(registration.active.scriptURL, normalizeURL(worker_url), 133 'registration.active'); 133 134 assert_not_equals(registration, newRegistration, 'New registration is different'); 134 135 }, 'Registering a new script URL that fails to install does not resurrect unregistered registration'); -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt
r246363 r249627 1 1 2 2 PASS Unregister then register resolves to a new value 3 FAIL Unregister then register does not resolve to the original value even if the registration is in use. assert_not_equals: Unregister and register should always create a new registration got disallowed value object "[object ServiceWorkerRegistration]" 3 PASS Unregister then register does not resolve to the original value even if the registration is in use. 4 4 PASS Unregister then register does not affect existing controllee 5 FAIL Unregister then register does not resurrect the registration assert_equals: Registration is new expected null but got object "[object ServiceWorker]" 5 PASS Unregister then register does not resurrect the registration 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https.html
r246363 r249627 67 67 return navigator.serviceWorker.register(worker_url, { scope: scope }); 68 68 }) 69 .then(function( registration) {69 .then(function(newRegistration) { 70 70 assert_equals(registration.installing, null, 71 71 'installing version is null'); -
trunk/Source/WebCore/ChangeLog
r249615 r249627 1 2019-09-07 Chris Dumez <cdumez@apple.com> 2 3 [Service Workers] Drop support for registration resurrection 4 https://bugs.webkit.org/show_bug.cgi?id=201584 5 6 Reviewed by Alex Christensen. 7 8 Drop support for registration resurrection (Unregistering then quickly re-registering would resurrect 9 the original registration instead of creating a new one). This behavior is no longer in the 10 specification (No more "isUninstalling" flag on the registration, and the registration is removed 11 from the "scope to registration map" right away upon unregistering). 12 13 This resurrection behavior was causing a lot of flakiness in the tests so it is likely we will be able 14 to unskip some tests. This is also what was causing the flakiness that caused Bug 201169 to be rolled 15 out. 16 17 No new tests, updated existing tests. 18 19 * workers/service/server/SWServer.cpp: 20 (WebCore::SWServer::activeWorkerFromRegistrationID): 21 (WebCore::SWServer::getRegistration): 22 (WebCore::SWServer::addRegistration): 23 (WebCore::SWServer::removeRegistration): 24 (WebCore::SWServer::getRegistrations): 25 (WebCore::SWServer::clearAll): 26 (WebCore::SWServer::clear): 27 (WebCore::SWServer::terminatePreinstallationWorker): 28 (WebCore::SWServer::didFinishActivation): 29 (WebCore::SWServer::claim): 30 (WebCore::SWServer::addClientServiceWorkerRegistration): 31 (WebCore::SWServer::removeClientServiceWorkerRegistration): 32 (WebCore::SWServer::installContextData): 33 (WebCore::SWServer::runServiceWorker): 34 (WebCore::SWServer::doRegistrationMatching): 35 (WebCore::SWServer::registrationFromServiceWorkerIdentifier): 36 (WebCore::SWServer::registerServiceWorkerClient): 37 (WebCore::SWServer::unregisterServiceWorkerClient): 38 (WebCore::SWServer::removeFromScopeToRegistrationMap): 39 (WebCore::SWServer::performGetOriginsWithRegistrationsCallbacks): 40 * workers/service/server/SWServer.h: 41 * workers/service/server/SWServerJobQueue.cpp: 42 (WebCore::SWServerJobQueue::runRegisterJob): 43 (WebCore::SWServerJobQueue::runUnregisterJob): 44 (WebCore::SWServerJobQueue::runUpdateJob): 45 * workers/service/server/SWServerRegistration.cpp: 46 (WebCore::SWServerRegistration::clear): 47 (WebCore::SWServerRegistration::handleClientUnload): 48 (WebCore::SWServerRegistration::isUnregistered const): 49 * workers/service/server/SWServerRegistration.h: 50 (WebCore::SWServerRegistration::scopeURLWithoutFragment const): 51 * workers/service/server/SWServerWorker.cpp: 52 (WebCore::SWServerWorker::SWServerWorker): 53 (WebCore::m_scriptResourceMap): 54 (WebCore::SWServerWorker::contextData const): 55 (WebCore::SWServerWorker::skipWaiting): 56 (WebCore::SWServerWorker::setHasPendingEvents): 57 (WebCore::SWServerWorker::setState): 58 (WebCore::SWServerWorker::registration const): 59 * workers/service/server/SWServerWorker.h: 60 1 61 2019-09-07 Ryan Haddad <ryanhaddad@apple.com> 2 62 -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r248846 r249627 112 112 SWServerWorker* SWServer::activeWorkerFromRegistrationID(ServiceWorkerRegistrationIdentifier identifier) 113 113 { 114 auto* registration = m_registrations ByID.get(identifier);114 auto* registration = m_registrations.get(identifier); 115 115 return registration ? registration->activeWorker() : nullptr; 116 116 } … … 118 118 SWServerRegistration* SWServer::getRegistration(const ServiceWorkerRegistrationKey& registrationKey) 119 119 { 120 return m_ registrations.get(registrationKey);120 return m_scopeToRegistrationMap.get(registrationKey).get(); 121 121 } 122 122 … … 143 143 { 144 144 // Pages should not have been able to make a new registration to this key while the import was still taking place. 145 ASSERT(!m_ registrations.contains(data.registration.key));145 ASSERT(!m_scopeToRegistrationMap.contains(data.registration.key)); 146 146 147 147 auto registration = makeUnique<SWServerRegistration>(*this, data.registration.key, data.registration.updateViaCache, data.registration.scopeURL, data.scriptURL); … … 157 157 void SWServer::addRegistration(std::unique_ptr<SWServerRegistration>&& registration) 158 158 { 159 auto key = registration->key(); 160 auto* registrationPtr = registration.get(); 161 auto addResult1 = m_registrations.add(key, WTFMove(registration)); 159 m_originStore->add(registration->key().topOrigin()); 160 auto registrationID = registration->identifier(); 161 ASSERT(!m_scopeToRegistrationMap.contains(registration->key())); 162 m_scopeToRegistrationMap.set(registration->key(), makeWeakPtr(*registration)); 163 auto addResult1 = m_registrations.add(registrationID, WTFMove(registration)); 162 164 ASSERT_UNUSED(addResult1, addResult1.isNewEntry); 163 164 auto addResult2 = m_registrationsByID.add(registrationPtr->identifier(), registrationPtr); 165 ASSERT_UNUSED(addResult2, addResult2.isNewEntry); 166 167 m_originStore->add(key.topOrigin()); 168 } 169 170 void SWServer::removeRegistration(const ServiceWorkerRegistrationKey& key) 171 { 172 auto topOrigin = key.topOrigin(); 173 auto registration = m_registrations.take(key); 165 } 166 167 void SWServer::removeRegistration(ServiceWorkerRegistrationIdentifier registrationID) 168 { 169 auto registration = m_registrations.take(registrationID); 174 170 ASSERT(registration); 175 bool wasRemoved = m_registrationsByID.remove(registration->identifier()); 176 ASSERT_UNUSED(wasRemoved, wasRemoved); 177 178 m_originStore->remove(topOrigin); 171 172 auto it = m_scopeToRegistrationMap.find(registration->key()); 173 if (it != m_scopeToRegistrationMap.end() && it->value == registration.get()) 174 m_scopeToRegistrationMap.remove(it); 175 176 m_originStore->remove(registration->key().topOrigin()); 179 177 if (m_registrationStore) 180 m_registrationStore->removeRegistration( key);178 m_registrationStore->removeRegistration(registration->key()); 181 179 } 182 180 … … 184 182 { 185 183 Vector<SWServerRegistration*> matchingRegistrations; 186 for (auto& item : m_registrations) { 187 if (!item.value->isUninstalling() && item.key.originIsMatching(topOrigin, clientURL)) 188 matchingRegistrations.append(item.value.get()); 184 for (auto& item : m_scopeToRegistrationMap) { 185 if (item.key.originIsMatching(topOrigin, clientURL)) { 186 auto* registration = item.value.get(); 187 ASSERT(registration); 188 if (registration) 189 matchingRegistrations.append(registration); 190 } 189 191 } 190 192 // The specification mandates that registrations are returned in the insertion order. … … 212 214 while (!m_registrations.isEmpty()) 213 215 m_registrations.begin()->value->clear(); 214 ASSERT(m_registrationsByID.isEmpty());215 216 m_pendingContextDatas.clear(); 216 217 m_originStore->clearAll(); … … 249 250 250 251 Vector<SWServerRegistration*> registrationsToRemove; 251 for (auto& keyAndValue : m_registrations) {252 if ( keyAndValue.key.relatesToOrigin(securityOrigin))253 registrationsToRemove.append( keyAndValue.value.get());252 for (auto& registration : m_registrations.values()) { 253 if (registration->key().relatesToOrigin(securityOrigin)) 254 registrationsToRemove.append(registration.get()); 254 255 } 255 256 … … 414 415 { 415 416 worker.terminate(); 416 auto* registration = getRegistration(worker.registrationKey());417 auto* registration = worker.registration(); 417 418 if (registration && registration->preInstallationWorker() == &worker) 418 419 registration->setPreInstallationWorker(nullptr); … … 437 438 RELEASE_LOG(ServiceWorker, "%p - SWServer::didFinishActivation: Finished activation for service worker %llu", this, worker.identifier().toUInt64()); 438 439 439 auto* registration = getRegistration(worker.registrationKey());440 auto* registration = worker.registration(); 440 441 if (!registration) 441 442 return; … … 495 496 return; 496 497 result.iterator->value = registration->identifier(); 497 if (auto* controllingRegistration = m_registrations ByID.get(previousIdentifier))498 if (auto* controllingRegistration = m_registrations.get(previousIdentifier)) 498 499 controllingRegistration->removeClientUsingRegistration(clientData.identifier); 499 500 } … … 512 513 void SWServer::addClientServiceWorkerRegistration(Connection& connection, ServiceWorkerRegistrationIdentifier identifier) 513 514 { 514 auto* registration = m_registrations ByID.get(identifier);515 auto* registration = m_registrations.get(identifier); 515 516 if (!registration) { 516 517 LOG_ERROR("Request to add client-side ServiceWorkerRegistration to non-existent server-side registration"); … … 523 524 void SWServer::removeClientServiceWorkerRegistration(Connection& connection, ServiceWorkerRegistrationIdentifier identifier) 524 525 { 525 if (auto* registration = m_registrations ByID.get(identifier))526 if (auto* registration = m_registrations.get(identifier)) 526 527 registration->removeClientServiceWorkerRegistration(connection.identifier()); 527 528 } … … 574 575 } 575 576 576 auto* registration = m_registrations.get(data.registration.key); 577 RELEASE_ASSERT(registration); 578 577 auto* registration = m_scopeToRegistrationMap.get(data.registration.key).get(); 579 578 auto worker = SWServerWorker::create(*this, *registration, data.scriptURL, data.script, data.contentSecurityPolicy, String { data.referrerPolicy }, data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap }); 580 579 … … 626 625 return false; 627 626 628 // If the registration for a work inghas been removed then the request to run627 // If the registration for a worker has been removed then the request to run 629 628 // the worker is moot. 630 if (! getRegistration(worker->registrationKey()))629 if (!worker->registration()) 631 630 return false; 632 631 … … 749 748 { 750 749 SWServerRegistration* selectedRegistration = nullptr; 751 for (auto& registration : m_registrations.values()) {752 if (! registration->key().isMatching(topOrigin, clientURL))750 for (auto& pair : m_scopeToRegistrationMap) { 751 if (!pair.key.isMatching(topOrigin, clientURL)) 753 752 continue; 754 if (!selectedRegistration || selectedRegistration->key().scopeLength() < registration->key().scopeLength())755 selectedRegistration = registration.get();756 } 757 758 return (selectedRegistration && !selectedRegistration->isUninstalling()) ? selectedRegistration : nullptr;753 if (!selectedRegistration || selectedRegistration->key().scopeLength() < pair.key.scopeLength()) 754 selectedRegistration = pair.value.get(); 755 } 756 757 return selectedRegistration; 759 758 } 760 759 … … 764 763 if (iterator == m_runningOrTerminatingWorkers.end()) 765 764 return nullptr; 766 767 return m_registrations.get(iterator->value->registrationKey()); 765 return iterator->value->registration(); 768 766 } 769 767 … … 795 793 return; 796 794 797 auto* controllingRegistration = m_registrations ByID.get(*controllingServiceWorkerRegistrationIdentifier);795 auto* controllingRegistration = m_registrations.get(*controllingServiceWorkerRegistrationIdentifier); 798 796 if (!controllingRegistration || !controllingRegistration->activeWorker()) 799 797 return; … … 851 849 return; 852 850 853 if (auto* registration = m_registrations ByID.get(registrationIterator->value))851 if (auto* registration = m_registrations.get(registrationIterator->value)) 854 852 registration->removeClientUsingRegistration(clientIdentifier); 855 853 856 854 m_clientToControllingRegistration.remove(registrationIterator); 855 } 856 857 void SWServer::removeFromScopeToRegistrationMap(const ServiceWorkerRegistrationKey& key) 858 { 859 m_scopeToRegistrationMap.remove(key); 857 860 } 858 861 … … 916 919 917 920 HashSet<SecurityOriginData> originsWithRegistrations; 918 for (auto& key : m_ registrations.keys()) {921 for (auto& key : m_scopeToRegistrationMap.keys()) { 919 922 originsWithRegistrations.add(key.topOrigin()); 920 923 originsWithRegistrations.add(SecurityOriginData { key.scope().protocol().toString(), key.scope().host().toString(), key.scope().port() }); -
trunk/Source/WebCore/workers/service/server/SWServer.h
r249287 r249627 133 133 WEBCORE_EXPORT SWServerRegistration* getRegistration(const ServiceWorkerRegistrationKey&); 134 134 void addRegistration(std::unique_ptr<SWServerRegistration>&&); 135 void removeRegistration( const ServiceWorkerRegistrationKey&);135 void removeRegistration(ServiceWorkerRegistrationIdentifier); 136 136 WEBCORE_EXPORT Vector<ServiceWorkerRegistrationData> getRegistrations(const SecurityOriginData& topOrigin, const URL& clientURL); 137 137 … … 194 194 void disableServiceWorkerProcessTerminationDelay() { m_shouldDisableServiceWorkerProcessTerminationDelay = true; } 195 195 196 void removeFromScopeToRegistrationMap(const ServiceWorkerRegistrationKey&); 197 196 198 private: 197 199 void scriptFetchFinished(Connection&, const ServiceWorkerFetchResult&); … … 222 224 223 225 HashMap<SWServerConnectionIdentifier, std::unique_ptr<Connection>> m_connections; 224 HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations;225 HashMap<ServiceWorkerRegistrationIdentifier, SWServerRegistration*> m_registrationsByID;226 HashMap<ServiceWorkerRegistrationKey, WeakPtr<SWServerRegistration>> m_scopeToRegistrationMap; 227 HashMap<ServiceWorkerRegistrationIdentifier, std::unique_ptr<SWServerRegistration>> m_registrations; 226 228 HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerJobQueue>> m_jobQueues; 227 229 -
trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp
r249287 r249627 274 274 // If registration is not null (in our parlance "empty"), then: 275 275 if (auto* registration = m_server.getRegistration(m_registrationKey)) { 276 registration->setIsUninstalling(false);277 276 auto* newestWorker = registration->getNewestWorker(); 278 277 if (newestWorker && equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()) && job.registrationOptions.updateViaCache == registration->updateViaCache()) { … … 307 306 308 307 // If registration is null, then: 309 if (!registration || registration->isUninstalling()) {308 if (!registration) { 310 309 // Invoke Resolve Job Promise with job and false. 311 310 m_server.resolveUnregistrationJob(job, m_registrationKey, false); … … 313 312 return; 314 313 } 315 316 // Set registration's uninstalling flag.317 registration->setIsUninstalling(true);314 315 // Remove scope to registration map[job’s scope url]. 316 m_server.removeFromScopeToRegistrationMap(m_registrationKey); 318 317 319 318 // Invoke Resolve Job Promise with job and true. … … 334 333 if (!registration) 335 334 return rejectCurrentJob(ExceptionData { TypeError, "Cannot update a null/nonexistent service worker registration"_s }); 336 if (registration->isUninstalling())337 return rejectCurrentJob(ExceptionData { TypeError, "Cannot update a service worker registration that is uninstalling"_s });338 335 339 336 // Let newestWorker be the result of running Get Newest Worker algorithm passing registration as the argument. -
trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp
r249287 r249627 260 260 261 261 // Remove scope to registration map[scopeString]. 262 m_server.removeRegistration( key());262 m_server.removeRegistration(identifier()); 263 263 } 264 264 … … 334 334 if (hasClientsUsingRegistration()) 335 335 return; 336 if (isUn installing() && tryClear())336 if (isUnregistered() && tryClear()) 337 337 return; 338 338 tryActivate(); 339 } 340 341 bool SWServerRegistration::isUnregistered() const 342 { 343 return m_server.getRegistration(key()) != this; 339 344 } 340 345 … … 348 353 identifiers.add(identifier.contextIdentifier); 349 354 m_server.connection(identifier.serverConnectionIdentifier)->notifyClientsOfControllerChange(identifiers, activeWorker()->data()); 350 }351 352 void SWServerRegistration::setIsUninstalling(bool value)353 {354 if (m_uninstalling == value)355 return;356 357 m_uninstalling = value;358 359 if (!m_uninstalling && activeWorker()) {360 // Registration with active worker has been resurrected, we need to check if any ready promises were waiting for this.361 m_server.resolveRegistrationReadyRequests(*this);362 }363 355 } 364 356 -
trunk/Source/WebCore/workers/service/server/SWServerRegistration.h
r249287 r249627 35 35 #include <wtf/MonotonicTime.h> 36 36 #include <wtf/WallTime.h> 37 #include <wtf/WeakPtr.h> 37 38 38 39 namespace WebCore { … … 46 47 struct ServiceWorkerFetchResult; 47 48 48 class SWServerRegistration {49 class SWServerRegistration : public CanMakeWeakPtr<SWServerRegistration> { 49 50 WTF_MAKE_FAST_ALLOCATED; 50 51 public: … … 57 58 SWServerWorker* getNewestWorker(); 58 59 WEBCORE_EXPORT ServiceWorkerRegistrationData data() const; 59 60 bool isUninstalling() const { return m_uninstalling; }61 void setIsUninstalling(bool);62 60 63 61 void setLastUpdateTime(WallTime); … … 95 93 void tryActivate(); 96 94 void didFinishActivation(ServiceWorkerIdentifier); 95 96 bool isUnregistered() const; 97 97 98 98 void forEachConnection(const WTF::Function<void(SWServer::Connection&)>&); … … 100 100 WEBCORE_EXPORT bool shouldSoftUpdate(const FetchOptions&) const; 101 101 WEBCORE_EXPORT void softUpdate(); 102 103 String scopeURLWithoutFragment() const { return m_scopeURL; } 102 104 103 105 private: … … 111 113 URL m_scriptURL; 112 114 113 bool m_uninstalling { false };114 115 RefPtr<SWServerWorker> m_preInstallationWorker; // Implementation detail, not part of the specification. 115 116 RefPtr<SWServerWorker> m_installingWorker; -
trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp
r249287 r249627 52 52 : m_server(makeWeakPtr(server)) 53 53 , m_registrationKey(registration.key()) 54 , m_registration(makeWeakPtr(registration)) 54 55 , m_data { identifier, scriptURL, ServiceWorkerState::Redundant, type, registration.identifier() } 55 56 , m_script(script) … … 64 65 ASSERT_UNUSED(result, result.isNewEntry); 65 66 66 ASSERT(m_server->getRegistration(m_registrationKey) );67 ASSERT(m_server->getRegistration(m_registrationKey) == ®istration); 67 68 } 68 69 … … 77 78 ServiceWorkerContextData SWServerWorker::contextData() const 78 79 { 79 auto* registration = m_server->getRegistration(m_registrationKey); 80 ASSERT(registration); 81 82 return { WTF::nullopt, registration->data(), m_data.identifier, m_script, m_contentSecurityPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, m_server->sessionID(), false, m_scriptResourceMap }; 80 ASSERT(m_registration); 81 82 return { WTF::nullopt, m_registration->data(), m_data.identifier, m_script, m_contentSecurityPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, m_server->sessionID(), false, m_scriptResourceMap }; 83 83 } 84 84 … … 178 178 m_isSkipWaitingFlagSet = true; 179 179 180 auto* registration = m_server->getRegistration(m_registrationKey); 181 ASSERT(registration || isTerminating()); 182 if (registration) 183 registration->tryActivate(); 180 ASSERT(m_registration || isTerminating()); 181 if (m_registration) 182 m_registration->tryActivate(); 184 183 } 185 184 … … 194 193 195 194 // Do tryClear/tryActivate, as per https://w3c.github.io/ServiceWorker/#wait-until-method. 196 auto* registration = m_server->getRegistration(m_registrationKey); 197 if (!registration) 198 return; 199 200 if (registration->isUninstalling() && registration->tryClear()) 201 return; 202 registration->tryActivate(); 195 if (!m_registration) 196 return; 197 198 if (m_registration->isUnregistered() && m_registration->tryClear()) 199 return; 200 m_registration->tryActivate(); 203 201 } 204 202 … … 219 217 m_data.state = state; 220 218 221 auto* registration = m_server->getRegistration(m_registrationKey); 222 ASSERT(registration || state == ServiceWorkerState::Redundant); 223 if (registration) { 224 registration->forEachConnection([&](auto& connection) { 219 ASSERT(m_registration || state == ServiceWorkerState::Redundant); 220 if (m_registration) { 221 m_registration->forEachConnection([&](auto& connection) { 225 222 connection.updateWorkerStateInClient(this->identifier(), state); 226 223 }); … … 240 237 void SWServerWorker::setState(State state) 241 238 { 242 ASSERT(state != State::Running || m_ server->getRegistration(m_registrationKey));239 ASSERT(state != State::Running || m_registration); 243 240 m_state = state; 244 241 … … 247 244 } 248 245 246 SWServerRegistration* SWServerWorker::registration() const 247 { 248 return m_registration.get(); 249 } 250 249 251 } // namespace WebCore 250 252 -
trunk/Source/WebCore/workers/service/server/SWServerWorker.h
r249287 r249627 114 114 115 115 bool shouldSkipFetchEvent() const { return m_shouldSkipHandleFetch; } 116 117 SWServerRegistration* registration() const; 116 118 117 119 private: … … 122 124 WeakPtr<SWServer> m_server; 123 125 ServiceWorkerRegistrationKey m_registrationKey; 126 WeakPtr<SWServerRegistration> m_registration; 124 127 ServiceWorkerData m_data; 125 128 String m_script;
Note: See TracChangeset
for help on using the changeset viewer.