Changeset 228071 in webkit
- Timestamp:
- Feb 4, 2018 9:30:39 PM (6 years ago)
- Location:
- branches/safari-605-branch
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-605-branch/Source/WebCore/ChangeLog
r228069 r228071 1 2018-02-04 Jason Marcell <jmarcell@apple.com> 2 3 Cherry-pick r228025. rdar://problem/37220140 4 5 2018-02-02 Youenn Fablet <youenn@apple.com> 6 7 Clearing all service worker registrations should wait for importing service worker registration to finish 8 https://bugs.webkit.org/show_bug.cgi?id=182407 9 10 Reviewed by Chris Dumez. 11 12 Covered by existing tests and the service worker API test being no longer flaky. 13 14 * workers/service/server/SWServer.cpp: 15 (WebCore::SWServer::registrationStoreImportComplete): 16 (WebCore::SWServer::clearAll): 17 (WebCore::SWServer::clear): 18 (WebCore::SWServer::getOriginsWithRegistrations): 19 * workers/service/server/SWServer.h: 20 1 21 2018-02-04 Jason Marcell <jmarcell@apple.com> 2 22 -
branches/safari-605-branch/Source/WebCore/workers/service/server/SWServer.cpp
r228061 r228071 115 115 m_importCompleted = true; 116 116 m_originStore->importComplete(); 117 118 auto clearCallbacks = WTFMove(m_clearCompletionCallbacks); 119 for (auto& callback : clearCallbacks) 120 callback(); 121 117 122 performGetOriginsWithRegistrationsCallbacks(); 118 123 } … … 183 188 } 184 189 185 void SWServer::clearAll(WTF::CompletionHandler<void()>&& completionHandler) 186 { 190 void SWServer::clearAll(CompletionHandler<void()>&& completionHandler) 191 { 192 if (!m_importCompleted) { 193 m_clearCompletionCallbacks.append([this, completionHandler = WTFMove(completionHandler)] () mutable { 194 ASSERT(m_importCompleted); 195 clearAll(WTFMove(completionHandler)); 196 }); 197 return; 198 } 199 187 200 m_jobQueues.clear(); 188 201 while (!m_registrations.isEmpty()) … … 194 207 } 195 208 196 void SWServer::clear(const SecurityOrigin& origin, WTF::CompletionHandler<void()>&& completionHandler) 197 { 209 void SWServer::clear(const SecurityOrigin& origin, CompletionHandler<void()>&& completionHandler) 210 { 211 if (!m_importCompleted) { 212 m_clearCompletionCallbacks.append([this, origin = makeRef(origin), completionHandler = WTFMove(completionHandler)] () mutable { 213 ASSERT(m_importCompleted); 214 clear(origin, WTFMove(completionHandler)); 215 }); 216 return; 217 } 218 198 219 m_jobQueues.removeIf([&](auto& keyAndValue) { 199 220 return keyAndValue.key.relatesToOrigin(origin); … … 209 230 return contextData.registration.key.relatesToOrigin(origin); 210 231 }); 232 233 if (registrationsToRemove.isEmpty()) 234 return; 211 235 212 236 // Calling SWServerRegistration::clear() takes care of updating m_registrations, m_originStore and m_registrationStore. … … 770 794 } 771 795 772 void SWServer::getOriginsWithRegistrations( WTF::Function<void(const HashSet<SecurityOriginData>&)>callback)796 void SWServer::getOriginsWithRegistrations(Function<void(const HashSet<SecurityOriginData>&)>&& callback) 773 797 { 774 798 m_getOriginsWithRegistrationsCallbacks.append(WTFMove(callback)); -
branches/safari-605-branch/Source/WebCore/workers/service/server/SWServer.h
r228061 r228071 176 176 void registrationStoreDatabaseFailedToOpen(); 177 177 178 WEBCORE_EXPORT void getOriginsWithRegistrations( WTF::Function<void(const HashSet<SecurityOriginData>&)>);178 WEBCORE_EXPORT void getOriginsWithRegistrations(Function<void(const HashSet<SecurityOriginData>&)>&&); 179 179 180 180 private: … … 227 227 PAL::SessionID m_sessionID; 228 228 bool m_importCompleted { false }; 229 Vector<WTF::Function<void(const HashSet<SecurityOriginData>&)>> m_getOriginsWithRegistrationsCallbacks; 229 Vector<CompletionHandler<void()>> m_clearCompletionCallbacks; 230 Vector<Function<void(const HashSet<SecurityOriginData>&)>> m_getOriginsWithRegistrationsCallbacks; 230 231 }; 231 232 -
branches/safari-605-branch/Source/WebKit/ChangeLog
r228070 r228071 1 2018-02-04 Jason Marcell <jmarcell@apple.com> 2 3 Cherry-pick r228025. rdar://problem/37220140 4 5 2018-02-02 Youenn Fablet <youenn@apple.com> 6 7 Clearing all service worker registrations should wait for importing service worker registration to finish 8 https://bugs.webkit.org/show_bug.cgi?id=182407 9 10 Reviewed by Chris Dumez. 11 12 Updating API to take a completion handler. 13 14 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 15 (WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations): 16 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 17 1 18 2018-02-04 Jason Marcell <jmarcell@apple.com> 2 19 -
branches/safari-605-branch/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r226349 r228071 385 385 } 386 386 387 void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef )387 void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback) 388 388 { 389 389 #if ENABLE(SERVICE_WORKER) 390 390 OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::ServiceWorkerRegistrations; 391 WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [] { }); 391 WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [context, callback] { 392 callback(context); 393 }); 392 394 #else 393 395 UNUSED_PARAM(dataStoreRef); -
branches/safari-605-branch/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r226346 r228071 81 81 WK_EXPORT void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveFetchCacheRemovalFunction callback); 82 82 83 typedef void (*WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback)(void* functionContext); 84 WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback); 85 83 86 WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef); 84 WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef);85 87 86 88 typedef void (*WKWebsiteDataStoreGetFetchCacheOriginsFunction)(WKArrayRef, void*); -
branches/safari-605-branch/Tools/ChangeLog
r228070 r228071 1 2018-02-04 Jason Marcell <jmarcell@apple.com> 2 3 Cherry-pick r228025. rdar://problem/37220140 4 5 2018-02-02 Youenn Fablet <youenn@apple.com> 6 7 Clearing all service worker registrations should wait for importing service worker registration to finish 8 https://bugs.webkit.org/show_bug.cgi?id=182407 9 10 Reviewed by Chris Dumez. 11 12 Make sure we finish clearing service worker registrations before running tests. 13 14 * WebKitTestRunner/TestController.cpp: 15 (WTR::TestController::resetStateToConsistentValues): 16 (WTR::ClearServiceWorkerRegistrationsCallbackContext::ClearServiceWorkerRegistrationsCallbackContext): 17 (WTR::clearServiceWorkerRegistrationsCallback): 18 (WTR::TestController::clearServiceWorkerRegistrations): 19 * WebKitTestRunner/TestController.h: 20 1 21 2018-02-04 Jason Marcell <jmarcell@apple.com> 2 22 -
branches/safari-605-branch/Tools/WebKitTestRunner/TestController.cpp
r228070 r228071 783 783 WKContextClearCachedCredentials(TestController::singleton().context()); 784 784 785 WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKContextGetWebsiteDataStore(platformContext())); 786 785 clearServiceWorkerRegistrations(); 787 786 clearDOMCaches(); 788 787 … … 2330 2329 2331 2330 #if PLATFORM(COCOA) && WK_API_ENABLED 2331 struct ClearServiceWorkerRegistrationsCallbackContext { 2332 explicit ClearServiceWorkerRegistrationsCallbackContext(TestController& controller) 2333 : testController(controller) 2334 { 2335 } 2336 2337 TestController& testController; 2338 bool done { false }; 2339 }; 2340 2341 static void clearServiceWorkerRegistrationsCallback(void* userData) 2342 { 2343 auto* context = static_cast<ClearServiceWorkerRegistrationsCallbackContext*>(userData); 2344 context->done = true; 2345 context->testController.notifyDone(); 2346 } 2347 #endif 2348 2349 void TestController::clearServiceWorkerRegistrations() 2350 { 2351 #if PLATFORM(COCOA) && WK_API_ENABLED 2352 auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext()); 2353 ClearServiceWorkerRegistrationsCallbackContext context(*this); 2354 2355 WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(websiteDataStore, &context, clearServiceWorkerRegistrationsCallback); 2356 2357 if (!context.done) 2358 runUntil(context.done, m_currentInvocation->shortTimeout()); 2359 #endif 2360 } 2361 2362 #if PLATFORM(COCOA) && WK_API_ENABLED 2332 2363 struct ClearDOMCacheCallbackContext { 2333 2364 explicit ClearDOMCacheCallbackContext(TestController& controller) -
branches/safari-605-branch/Tools/WebKitTestRunner/TestController.h
r225622 r228071 193 193 void removeAllSessionCredentials(); 194 194 195 void clearServiceWorkerRegistrations(); 196 195 197 void clearDOMCache(WKStringRef origin); 196 198 void clearDOMCaches();
Note: See TracChangeset
for help on using the changeset viewer.