Changeset 232891 in webkit
- Timestamp:
- Jun 15, 2018 1:11:41 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232880 r232891 1 2018-06-15 Chris Dumez <cdumez@apple.com> 2 3 Add API test coverage for SW RegistrationDatabase destruction and fix issues found by the test 4 https://bugs.webkit.org/show_bug.cgi?id=186681 5 6 Reviewed by Brady Eidson. 7 8 * workers/service/server/RegistrationDatabase.cpp: 9 (WebCore::RegistrationDatabase::RegistrationDatabase): 10 (WebCore::RegistrationDatabase::importRecords): 11 * workers/service/server/RegistrationDatabase.h: 12 Rename m_session to m_sessionID for clarity. 13 14 * workers/service/server/RegistrationStore.cpp: 15 (WebCore::RegistrationStore::~RegistrationStore): 16 Drop bad assertion now that the RegistrationDatabase is refcounted 17 and can outlive the RegistrationStore. The RegistrationDatabase will 18 take care of closing / destroying the SQLiteDatabase on the background 19 thread when destroyed. 20 1 21 2018-06-15 Timothy Hatcher <timothy@apple.com> 2 22 -
trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp
r232874 r232891 96 96 : m_workQueue(WorkQueue::create("ServiceWorker I/O Thread", WorkQueue::Type::Serial)) 97 97 , m_store(makeWeakPtr(store)) 98 , m_session (m_store->server().sessionID())98 , m_sessionID(m_store->server().sessionID()) 99 99 , m_databaseDirectory(WTFMove(databaseDirectory)) 100 100 , m_databaseFilePath(FileSystem::pathByAppendingComponent(m_databaseDirectory, databaseFilename())) … … 405 405 auto serviceWorkerData = ServiceWorkerData { workerIdentifier, scriptURL, ServiceWorkerState::Activated, *workerType, registrationIdentifier }; 406 406 auto registration = ServiceWorkerRegistrationData { WTFMove(*key), registrationIdentifier, URL(originURL, scopePath), *updateViaCache, lastUpdateCheckTime, std::nullopt, std::nullopt, WTFMove(serviceWorkerData) }; 407 auto contextData = ServiceWorkerContextData { std::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(scriptURL), *workerType, m_session , true, WTFMove(scriptResourceMap) };407 auto contextData = ServiceWorkerContextData { std::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(scriptURL), *workerType, m_sessionID, true, WTFMove(scriptResourceMap) }; 408 408 409 409 callOnMainThread([protectedThis = makeRef(*this), contextData = contextData.isolatedCopy()]() mutable { -
trunk/Source/WebCore/workers/service/server/RegistrationDatabase.h
r232874 r232891 78 78 Ref<WorkQueue> m_workQueue; 79 79 WeakPtr<RegistrationStore> m_store; 80 PAL::SessionID m_session ;80 PAL::SessionID m_sessionID; 81 81 String m_databaseDirectory; 82 82 String m_databaseFilePath; -
trunk/Source/WebCore/workers/service/server/RegistrationStore.cpp
r232874 r232891 42 42 RegistrationStore::~RegistrationStore() 43 43 { 44 ASSERT(m_database->isClosed());45 44 } 46 45 -
trunk/Source/WebKit/ChangeLog
r232888 r232891 1 2018-06-15 Chris Dumez <cdumez@apple.com> 2 3 Add API test coverage for SW RegistrationDatabase destruction and fix issues found by the test 4 https://bugs.webkit.org/show_bug.cgi?id=186681 5 6 Reviewed by Brady Eidson. 7 8 Make sure StorageProcess::unregisterSWServerConnection() does not unnecessarily 9 create a SWServer. Otherwise, we were in quick session destroying the SWServer 10 and then re-constructing it for the same sessionID, merely to try ot unregister 11 a SWServerConnection. 12 13 * StorageProcess/StorageProcess.cpp: 14 (WebKit::StorageProcess::existingSWOriginStoreForSession const): 15 (WebKit::StorageProcess::unregisterSWServerConnection): 16 * StorageProcess/StorageProcess.h: 17 1 18 2018-06-15 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 19 -
trunk/Source/WebKit/StorageProcess/StorageProcess.cpp
r232484 r232891 457 457 } 458 458 459 WebSWOriginStore* StorageProcess::existingSWOriginStoreForSession(PAL::SessionID sessionID) const 460 { 461 auto* swServer = m_swServers.get(sessionID); 462 if (!swServer) 463 return nullptr; 464 return &static_cast<WebSWOriginStore&>(swServer->originStore()); 465 } 466 459 467 WebSWServerToContextConnection* StorageProcess::serverToContextConnectionForOrigin(const SecurityOriginData& securityOrigin) 460 468 { … … 534 542 ASSERT(m_swServerConnections.get(connection.identifier()) == &connection); 535 543 m_swServerConnections.remove(connection.identifier()); 536 swOriginStoreForSession(connection.sessionID()).unregisterSWServerConnection(connection); 544 if (auto* store = existingSWOriginStoreForSession(connection.sessionID())) 545 store->unregisterSWServerConnection(connection); 537 546 } 538 547 -
trunk/Source/WebKit/StorageProcess/StorageProcess.h
r232484 r232891 152 152 153 153 WebSWOriginStore& swOriginStoreForSession(PAL::SessionID); 154 WebSWOriginStore* existingSWOriginStoreForSession(PAL::SessionID) const; 154 155 bool needsServerToContextConnectionForOrigin(const WebCore::SecurityOriginData&) const; 155 156 #endif -
trunk/Tools/ChangeLog
r232886 r232891 1 2018-06-15 Chris Dumez <cdumez@apple.com> 2 3 Add API test coverage for SW RegistrationDatabase destruction and fix issues found by the test 4 https://bugs.webkit.org/show_bug.cgi?id=186681 5 6 Reviewed by Brady Eidson. 7 8 Add API test coverage. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: 11 1 12 2018-06-15 Brady Eidson <beidson@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
r232580 r232891 1419 1419 } 1420 1420 1421 TEST(ServiceWorkers, RestoreFromDiskNonDefaultStore) 1422 { 1423 ASSERT(mainRegisteringWorkerBytes); 1424 ASSERT(scriptBytes); 1425 ASSERT(mainRegisteringAlreadyExistingWorkerBytes); 1426 1427 [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins]; 1428 1429 NSURL *swDBPath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/CustomWebsiteData/ServiceWorkers/" stringByExpandingTildeInPath]]; 1430 [[NSFileManager defaultManager] removeItemAtURL:swDBPath error:nil]; 1431 EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:swDBPath.path]); 1432 [[NSFileManager defaultManager] createDirectoryAtURL:swDBPath withIntermediateDirectories:YES attributes:nil error:nil]; 1433 EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:swDBPath.path]); 1434 1435 // We protect the process pool so that it outlives the WebsiteDataStore. 1436 RetainPtr<WKProcessPool> protectedProcessPool; 1437 1438 @autoreleasepool { 1439 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 1440 1441 auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]); 1442 websiteDataStoreConfiguration.get()._serviceWorkerRegistrationDirectory = swDBPath; 1443 auto nonDefaultDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]); 1444 configuration.get().websiteDataStore = nonDefaultDataStore.get(); 1445 1446 auto messageHandler = adoptNS([[SWMessageHandlerForRestoreFromDiskTest alloc] initWithExpectedMessage:@"PASS: Registration was successful and service worker was activated"]); 1447 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"]; 1448 1449 auto handler = adoptNS([[SWSchemes alloc] init]); 1450 handler->resources.set("sw://host/main.html", ResourceInfo { @"text/html", mainRegisteringWorkerBytes }); 1451 handler->resources.set("sw://host/sw.js", ResourceInfo { @"application/javascript", scriptBytes }); 1452 [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"]; 1453 1454 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 1455 [webView.get().configuration.processPool _registerURLSchemeServiceWorkersCanHandle:@"sw"]; 1456 protectedProcessPool = webView.get().configuration.processPool; 1457 1458 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/main.html"]]]; 1459 1460 TestWebKitAPI::Util::run(&done); 1461 done = false; 1462 1463 [webView.get().configuration.processPool _terminateServiceWorkerProcesses]; 1464 } 1465 1466 @autoreleasepool { 1467 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 1468 1469 auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]); 1470 websiteDataStoreConfiguration.get()._serviceWorkerRegistrationDirectory = swDBPath; 1471 auto nonDefaultDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]); 1472 configuration.get().websiteDataStore = nonDefaultDataStore.get(); 1473 1474 auto messageHandler = adoptNS([[SWMessageHandlerForRestoreFromDiskTest alloc] initWithExpectedMessage:@"PASS: Registration already has an active worker"]); 1475 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"]; 1476 1477 auto handler = adoptNS([[SWSchemes alloc] init]); 1478 handler->resources.set("sw://host/main.html", ResourceInfo { @"text/html", mainRegisteringAlreadyExistingWorkerBytes }); 1479 handler->resources.set("sw://host/sw.js", ResourceInfo { @"application/javascript", scriptBytes }); 1480 [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"]; 1481 1482 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 1483 [webView.get().configuration.processPool _registerURLSchemeServiceWorkersCanHandle:@"sw"]; 1484 1485 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/main.html"]]]; 1486 1487 TestWebKitAPI::Util::run(&done); 1488 done = false; 1489 } 1490 } 1491 1421 1492 #endif // WK_API_ENABLED
Note: See TracChangeset
for help on using the changeset viewer.