Changeset 226003 in webkit
- Timestamp:
- Dec 16, 2017 10:54:04 AM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r225998 r226003 1 2017-12-16 Brady Eidson <beidson@apple.com> 2 3 Implement getting ServiceWorker registrations for the WKWebsiteDataStore API 4 https://bugs.webkit.org/show_bug.cgi?id=180886 5 6 Reviewed by Chris Dumez. 7 8 No new tests (API test coming soon). 9 10 * workers/service/server/SWServer.cpp: 11 (WebCore::SWServer::registrationStoreImportComplete): 12 (WebCore::SWServer::SWServer): 13 (WebCore::SWServer::getOriginsWithRegistrations): 14 (WebCore::SWServer::performGetOriginsWithRegistrationsCallbacks): 15 * workers/service/server/SWServer.h: 16 1 17 2017-12-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 18 -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r225976 r226003 109 109 void SWServer::registrationStoreImportComplete() 110 110 { 111 ASSERT(!m_importCompleted); 112 m_importCompleted = true; 111 113 m_originStore->importComplete(); 114 performGetOriginsWithRegistrationsCallbacks(); 112 115 } 113 116 … … 229 232 } 230 233 231 234 SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore, String&& registrationDatabaseDirectory, PAL::SessionID sessionID) 232 235 : m_originStore(WTFMove(originStore)) 233 236 , m_registrationStore(*this, WTFMove(registrationDatabaseDirectory)) … … 769 772 } 770 773 774 void SWServer::getOriginsWithRegistrations(WTF::Function<void(const HashSet<SecurityOriginData>&)> callback) 775 { 776 m_getOriginsWithRegistrationsCallbacks.append(WTFMove(callback)); 777 778 if (m_importCompleted) 779 performGetOriginsWithRegistrationsCallbacks(); 780 } 781 782 void SWServer::performGetOriginsWithRegistrationsCallbacks() 783 { 784 ASSERT(isMainThread()); 785 ASSERT(m_importCompleted); 786 787 if (m_getOriginsWithRegistrationsCallbacks.isEmpty()) 788 return; 789 790 HashSet<SecurityOriginData> originsWithRegistrations; 791 for (auto& key : m_registrations.keys()) { 792 originsWithRegistrations.add(key.topOrigin()); 793 originsWithRegistrations.add(SecurityOriginData { key.scope().protocol().toString(), key.scope().host(), key.scope().port() }); 794 } 795 796 auto callbacks = WTFMove(m_getOriginsWithRegistrationsCallbacks); 797 for (auto& callback : callbacks) 798 callback(originsWithRegistrations); 799 } 800 771 801 } // namespace WebCore 772 802 -
trunk/Source/WebCore/workers/service/server/SWServer.h
r225992 r226003 175 175 void registrationStoreImportComplete(); 176 176 177 WEBCORE_EXPORT void getOriginsWithRegistrations(WTF::Function<void(const HashSet<SecurityOriginData>&)>); 178 177 179 private: 178 180 void registerConnection(Connection&); … … 197 199 SWServerRegistration* registrationFromServiceWorkerIdentifier(ServiceWorkerIdentifier); 198 200 void forEachClientForOrigin(const ClientOrigin&, const WTF::Function<void(ServiceWorkerClientData&)>&); 201 202 void performGetOriginsWithRegistrationsCallbacks(); 199 203 200 204 enum TerminationMode { … … 232 236 HashMap<ServiceWorkerIdentifier, Vector<RunServiceWorkerCallback>> m_serviceWorkerRunRequests; 233 237 PAL::SessionID m_sessionID; 238 bool m_importCompleted { false }; 239 Vector<WTF::Function<void(const HashSet<SecurityOriginData>&)>> m_getOriginsWithRegistrationsCallbacks; 234 240 }; 235 241 -
trunk/Source/WebKit/ChangeLog
r225999 r226003 1 2017-12-16 Brady Eidson <beidson@apple.com> 2 3 Implement getting ServiceWorker registrations for the WKWebsiteDataStore API 4 https://bugs.webkit.org/show_bug.cgi?id=180886 5 6 Reviewed by Chris Dumez. 7 8 * StorageProcess/StorageProcess.cpp: 9 (WebKit::StorageProcess::fetchWebsiteData): 10 1 11 2017-12-16 Brent Fulgham <bfulgham@apple.com> 2 12 -
trunk/Source/WebKit/StorageProcess/StorageProcess.cpp
r225935 r226003 266 266 void StorageProcess::fetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, uint64_t callbackID) 267 267 { 268 auto completionHandler = [this, callbackID](const WebsiteData& websiteData) { 269 parentProcessConnection()->send(Messages::StorageProcessProxy::DidFetchWebsiteData(callbackID, websiteData), 0); 270 }; 271 272 #if ENABLE(SERVICE_WORKER) 273 if (websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) 274 notImplemented(); 268 auto websiteData = std::make_unique<WebsiteData>(); 269 WebsiteData* rawWebsiteData = websiteData.get(); 270 auto callbackAggregator = CallbackAggregator::create([this, websiteData = WTFMove(websiteData), callbackID]() { 271 parentProcessConnection()->send(Messages::StorageProcessProxy::DidFetchWebsiteData(callbackID, *websiteData), 0); 272 }); 273 274 String path; 275 #if ENABLE(SERVICE_WORKER) 276 path = m_swDatabasePaths.get(sessionID); 277 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) { 278 swServerForSession(sessionID).getOriginsWithRegistrations([rawWebsiteData, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& origins) mutable { 279 for (auto& origin : origins) 280 rawWebsiteData->entries.append({ origin, WebsiteDataType::ServiceWorkerRegistrations, 0 }); 281 }); 282 } 275 283 #endif 276 284 277 285 #if ENABLE(INDEXED_DATABASE) 278 Stringpath = m_idbDatabasePaths.get(sessionID);286 path = m_idbDatabasePaths.get(sessionID); 279 287 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) { 280 288 // FIXME: Pick the right database store based on the session ID. 281 postStorageTask(CrossThreadTask([this, completionHandler = WTFMove(completionHandler), path = WTFMove(path)]() mutable { 282 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), securityOrigins = indexedDatabaseOrigins(path)] { 283 WebsiteData websiteData; 289 postStorageTask(CrossThreadTask([this, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), rawWebsiteData]() mutable { 290 RunLoop::main().dispatch([callbackAggregator = WTFMove(callbackAggregator), rawWebsiteData, securityOrigins = indexedDatabaseOrigins(path)] { 284 291 for (const auto& securityOrigin : securityOrigins) 285 websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 }); 286 287 completionHandler(websiteData); 292 rawWebsiteData->entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 }); 288 293 }); 289 294 })); 290 return; 291 } 292 #endif 293 294 completionHandler({ }); 295 } 296 #endif 295 297 } 296 298
Note: See TracChangeset
for help on using the changeset viewer.