Changeset 251439 in webkit
- Timestamp:
- Oct 22, 2019, 10:09:59 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251437 r251439 1 2019-10-22 youenn fablet <youenn@apple.com> 2 3 Remove mayHaveServiceWorkerRegisteredForOrigin 4 https://bugs.webkit.org/show_bug.cgi?id=203055 5 6 Reviewed by Alex Christensen. 7 8 Remove ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin and existingServiceWorkerConnection since they are no longer useful. 9 Creation of a service worker connection no longer requires any additional IPC once network connection is created. 10 Covered by existing tests. 11 12 * dom/Document.cpp: 13 (WebCore::Document::resume): 14 * loader/DocumentLoader.cpp: 15 (WebCore::DocumentLoader::matchRegistration): 16 (WebCore::DocumentLoader::commitData): 17 * testing/Internals.cpp: 18 (WebCore::Internals::terminateServiceWorker): 19 * testing/Internals.h: 20 * testing/Internals.idl: 21 * workers/service/SWClientConnection.h: 22 * workers/service/ServiceWorkerProvider.cpp: 23 * workers/service/ServiceWorkerProvider.h: 24 * workers/service/WorkerSWClientConnection.cpp: 25 * workers/service/WorkerSWClientConnection.h: 26 1 27 2019-10-21 Simon Fraser <simon.fraser@apple.com> 2 28 -
trunk/Source/WebCore/dom/Document.cpp
r251425 r251439 5238 5238 #if ENABLE(SERVICE_WORKER) 5239 5239 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reason == ReasonForSuspension::BackForwardCache) 5240 setServiceWorkerConnection( ServiceWorkerProvider::singleton().existingServiceWorkerConnection());5240 setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection()); 5241 5241 #endif 5242 5242 } -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r251409 r251439 506 506 507 507 auto origin = (!m_frame->isMainFrame() && m_frame->document()) ? m_frame->document()->topOrigin().data() : SecurityOriginData::fromURL(url); 508 auto& provider = ServiceWorkerProvider::singleton(); 509 if (!provider.mayHaveServiceWorkerRegisteredForOrigin(origin)) { 508 if (!ServiceWorkerProvider::singleton().serviceWorkerConnection().mayHaveServiceWorkerRegisteredForOrigin(origin)) { 510 509 callback(WTF::nullopt); 511 510 return; … … 1062 1061 1063 1062 if (m_frame->document()->activeServiceWorker() || LegacySchemeRegistry::canServiceWorkersHandleURLScheme(m_frame->document()->url().protocol().toStringWithoutCopying())) 1064 m_frame->document()->setServiceWorkerConnection( ServiceWorkerProvider::singleton().existingServiceWorkerConnection());1063 m_frame->document()->setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection()); 1065 1064 1066 1065 // We currently unregister the temporary service worker client since we now registered the real document. -
trunk/Source/WebCore/testing/Internals.cpp
r251425 r251439 5027 5027 ServiceWorkerProvider::singleton().serviceWorkerConnection().syncTerminateWorker(worker.identifier()); 5028 5028 } 5029 5030 bool Internals::hasServiceWorkerConnection()5031 {5032 if (!contextDocument())5033 return false;5034 5035 return ServiceWorkerProvider::singleton().existingServiceWorkerConnection();5036 }5037 5029 #endif 5038 5030 -
trunk/Source/WebCore/testing/Internals.h
r251425 r251439 766 766 void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&); 767 767 void terminateServiceWorker(ServiceWorker&); 768 bool hasServiceWorkerConnection();769 768 #endif 770 769 -
trunk/Source/WebCore/testing/Internals.idl
r251425 r251439 757 757 [Conditional=SERVICE_WORKER] Promise<boolean> hasServiceWorkerRegistration(DOMString scopeURL); 758 758 [Conditional=SERVICE_WORKER] void terminateServiceWorker(ServiceWorker worker); 759 [Conditional=SERVICE_WORKER] boolean hasServiceWorkerConnection();760 759 761 760 [CallWith=Document, Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator; -
trunk/Source/WebCore/workers/service/SWClientConnection.h
r249526 r251439 86 86 virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0; 87 87 88 virtual bool isThrottleable() const = 0;89 virtual void updateThrottleState() = 0;90 91 88 virtual void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&& callback) { callback(); } 92 89 -
trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp
r251067 r251439 55 55 } 56 56 57 bool ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData& origin)58 {59 auto* connection = existingServiceWorkerConnection();60 if (!connection)61 return m_mayHaveRegisteredServiceWorkers;62 63 return connection->mayHaveServiceWorkerRegisteredForOrigin(origin);64 }65 66 57 void ServiceWorkerProvider::registerServiceWorkerClients() 67 58 { -
trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h
r250287 r251439 41 41 static void setSharedProvider(ServiceWorkerProvider&); 42 42 43 bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData&);44 virtual SWClientConnection* existingServiceWorkerConnection() = 0;45 43 virtual SWClientConnection& serviceWorkerConnection() = 0; 46 44 -
trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp
r250104 r251439 185 185 } 186 186 187 bool WorkerSWClientConnection::isThrottleable() const188 {189 return true;190 }191 192 void WorkerSWClientConnection::updateThrottleState()193 {194 }195 196 187 void WorkerSWClientConnection::scheduleJob(DocumentOrWorkerIdentifier identifier, const ServiceWorkerJobData& data) 197 188 { -
trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h
r250104 r251439 56 56 void unregisterServiceWorkerClient(DocumentIdentifier) final; 57 57 void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) final; 58 bool isThrottleable() const final;59 void updateThrottleState() final;60 58 void scheduleJobInServer(const ServiceWorkerJobData&) final; 61 59 void scheduleJob(DocumentOrWorkerIdentifier, const ServiceWorkerJobData&) final; -
trunk/Source/WebKit/ChangeLog
r251438 r251439 1 2019-10-22 youenn fablet <youenn@apple.com> 2 3 Remove mayHaveServiceWorkerRegisteredForOrigin 4 https://bugs.webkit.org/show_bug.cgi?id=203055 5 6 Reviewed by Alex Christensen. 7 8 This optimization was used for ensuring we would not create a storage process when no service worker registration is stored on disk. 9 Now that we do not have a storage process and we are doing registration matching direclty in network process, we can safely remove that optimization. 10 We also move the throttle state handling in WK2 layer. This allows us to not create a network process connection to update throttle state until 11 there is a network process connection. This allows continuing passing an API test checking network process connections after crashes. 12 13 * Shared/WebPageCreationParameters.cpp: 14 (WebKit::WebPageCreationParameters::encode const): 15 (WebKit::WebPageCreationParameters::decode): 16 * Shared/WebPageCreationParameters.h: 17 * UIProcess/WebPageProxy.cpp: 18 (WebKit::WebPageProxy::creationParameters): 19 * UIProcess/WebProcessPool.cpp: 20 (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess): 21 (WebKit::WebProcessPool::updateServiceWorkerUserAgent): 22 * UIProcess/WebProcessPool.h: 23 * WebProcess/Network/NetworkProcessConnection.h: 24 * WebProcess/Storage/WebSWClientConnection.h: 25 * WebProcess/Storage/WebServiceWorkerProvider.cpp: 26 (WebKit::WebServiceWorkerProvider::serviceWorkerConnection): 27 (WebKit::WebServiceWorkerProvider::updateThrottleState): 28 * WebProcess/Storage/WebServiceWorkerProvider.h: 29 * WebProcess/WebPage/WebPage.cpp: 30 (WebKit::m_textAutoSizingAdjustmentTimer): 31 (WebKit::WebPage::updateThrottleState): 32 1 33 2019-10-22 Yury Semikhatsky <yurys@chromium.org> 2 34 -
trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp
r249939 r251439 118 118 encoder << applicationManifest; 119 119 #endif 120 #if ENABLE(SERVICE_WORKER)121 encoder << hasRegisteredServiceWorkers;122 #endif123 120 encoder << needsFontAttributes; 124 121 encoder << iceCandidateFilteringEnabled; … … 344 341 parameters.applicationManifest = WTFMove(*applicationManifest); 345 342 #endif 346 #if ENABLE(SERVICE_WORKER)347 if (!decoder.decode(parameters.hasRegisteredServiceWorkers))348 return WTF::nullopt;349 #endif350 351 343 if (!decoder.decode(parameters.needsFontAttributes)) 352 344 return WTF::nullopt; -
trunk/Source/WebKit/Shared/WebPageCreationParameters.h
r249939 r251439 183 183 #endif 184 184 185 #if ENABLE(SERVICE_WORKER)186 bool hasRegisteredServiceWorkers { true };187 #endif188 189 185 bool needsFontAttributes { false }; 190 186 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r251388 r251439 7385 7385 #endif 7386 7386 7387 #if ENABLE(SERVICE_WORKER)7388 parameters.hasRegisteredServiceWorkers = process.processPool().mayHaveRegisteredServiceWorkers(process.websiteDataStore());7389 #endif7390 7391 7387 parameters.needsFontAttributes = m_needsFontAttributes; 7392 7388 parameters.backgroundColor = m_backgroundColor; -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r251384 r251439 692 692 ASSERT_UNUSED(proxy, &proxy == m_networkProcess.get()); 693 693 694 m_mayHaveRegisteredServiceWorkers.clear();695 696 694 auto* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID); 697 695 … … 1264 1262 for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values()) 1265 1263 serviceWorkerProcess->setServiceWorkerUserAgent(m_serviceWorkerUserAgent); 1266 }1267 1268 bool WebProcessPool::mayHaveRegisteredServiceWorkers(const WebsiteDataStore& store)1269 {1270 if (!m_serviceWorkerProcesses.isEmpty())1271 return true;1272 1273 String serviceWorkerRegistrationDirectory = store.resolvedServiceWorkerRegistrationDirectory();1274 if (serviceWorkerRegistrationDirectory.isEmpty())1275 serviceWorkerRegistrationDirectory = WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();1276 1277 return m_mayHaveRegisteredServiceWorkers.ensure(serviceWorkerRegistrationDirectory, [&] {1278 // FIXME: Make this computation on a background thread.1279 return FileSystem::fileExists(WebCore::serviceWorkerRegistrationDatabaseFilename(serviceWorkerRegistrationDirectory));1280 }).iterator->value;1281 1264 } 1282 1265 #endif -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r251181 r251439 394 394 bool allowsAnySSLCertificateForServiceWorker() const { return m_allowsAnySSLCertificateForServiceWorker; } 395 395 void updateServiceWorkerUserAgent(const String& userAgent); 396 bool mayHaveRegisteredServiceWorkers(const WebsiteDataStore&);397 396 #endif 398 397 … … 613 612 String m_serviceWorkerUserAgent; 614 613 Optional<WebPreferencesStore> m_serviceWorkerPreferences; 615 HashMap<String, bool> m_mayHaveRegisteredServiceWorkers;616 614 #endif 617 615 -
trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
r251361 r251439 73 73 74 74 #if ENABLE(SERVICE_WORKER) 75 WebSWClientConnection* existingServiceWorkerConnection() { return m_swConnection.get(); }76 75 WebSWClientConnection& serviceWorkerConnection(); 77 76 #endif -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
r251409 r251439 65 65 void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final; 66 66 67 bool isThrottleable() const { return m_isThrottleable; } 68 void updateThrottleState(); 69 67 70 private: 68 71 WebSWClientConnection(); … … 85 88 86 89 void didResolveRegistrationPromise(const WebCore::ServiceWorkerRegistrationKey&) final; 87 void updateThrottleState() final;88 bool isThrottleable() const final { return m_isThrottleable; }89 90 void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&&) final; 90 91 -
trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
r251124 r251439 56 56 WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnection() 57 57 { 58 ASSERT(RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()); 58 59 return WebProcess::singleton().ensureNetworkProcessConnection().serviceWorkerConnection(); 59 60 } 60 61 61 WebCore::SWClientConnection* WebServiceWorkerProvider::existingServiceWorkerConnection()62 void WebServiceWorkerProvider::updateThrottleState(bool isThrottleable) 62 63 { 63 64 auto* networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection(); 64 65 if (!networkProcessConnection) 65 return nullptr; 66 return networkProcessConnection->existingServiceWorkerConnection(); 66 return; 67 auto& connection = networkProcessConnection->serviceWorkerConnection(); 68 if (isThrottleable != connection.isThrottleable()) 69 connection.updateThrottleState(); 67 70 } 68 71 -
trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h
r251124 r251439 42 42 43 43 void didReceiveServiceWorkerClientRegistrationMatch(IPC::Connection&, IPC::Decoder&); 44 void updateThrottleState(bool isThrottleable); 44 45 45 46 private: … … 47 48 WebServiceWorkerProvider(); 48 49 49 WebCore::SWClientConnection* existingServiceWorkerConnection() final;50 50 WebCore::SWClientConnection& serviceWorkerConnection() final; 51 51 }; // class WebServiceWorkerProvider -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r251425 r251439 120 120 #include "WebProcessProxyMessages.h" 121 121 #include "WebProgressTrackerClient.h" 122 #include "WebServiceWorkerProvider.h" 122 123 #include "WebSocketProvider.h" 123 124 #include "WebSpeechSynthesisClient.h" … … 218 219 #include <WebCore/ScriptController.h> 219 220 #include <WebCore/SerializedScriptValue.h> 220 #include <WebCore/ServiceWorkerProvider.h>221 221 #include <WebCore/Settings.h> 222 222 #include <WebCore/ShadowRoot.h> … … 652 652 #endif 653 653 654 #if ENABLE(SERVICE_WORKER)655 if (parameters.hasRegisteredServiceWorkers)656 ServiceWorkerProvider::singleton().setMayHaveRegisteredServiceWorkers();657 #endif658 659 654 m_needsFontAttributes = parameters.needsFontAttributes; 660 655 … … 793 788 794 789 #if ENABLE(SERVICE_WORKER) 795 RunLoop::main().dispatch([isThrottleable] { 796 if (auto* connection = ServiceWorkerProvider::singleton().existingServiceWorkerConnection()) { 797 if (isThrottleable != connection->isThrottleable()) 798 connection->updateThrottleState(); 799 } 800 }); 790 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) { 791 RunLoop::main().dispatch([isThrottleable] { 792 WebServiceWorkerProvider::singleton().updateThrottleState(isThrottleable); 793 }); 794 } 801 795 #endif 802 796 } -
trunk/Tools/ChangeLog
r251432 r251439 1 2019-10-22 youenn fablet <youenn@apple.com> 2 3 Remove mayHaveServiceWorkerRegisteredForOrigin 4 https://bugs.webkit.org/show_bug.cgi?id=203055 5 6 Reviewed by Alex Christensen. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: 9 Remove obsolete test. 10 1 11 2019-10-22 Antti Koivisto <antti@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
r251409 r251439 867 867 static const char* regularPageWithConnectionBytes = R"SWRESOURCE( 868 868 <script> 869 var result = window.internals.hasServiceWorkerConnection() ? "PASS" : "FAIL"; 870 window.webkit.messageHandlers.regularPage.postMessage(result); 869 window.webkit.messageHandlers.regularPage.postMessage("PASS"); 871 870 </script> 872 871 )SWRESOURCE"; … … 1045 1044 // Make sure that loading this page did start the service worker process. 1046 1045 EXPECT_EQ(1u, webView.get().configuration.processPool._serviceWorkerProcessCount); 1047 1048 [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {1049 done = true;1050 }];1051 TestWebKitAPI::Util::run(&done);1052 done = false;1053 }1054 1055 TEST(ServiceWorkers, HasServiceWorkerRegistrationBit)1056 {1057 [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];1058 1059 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);1060 setConfigurationInjectedBundlePath(configuration.get());1061 1062 done = false;1063 1064 [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {1065 done = true;1066 }];1067 TestWebKitAPI::Util::run(&done);1068 done = false;1069 1070 [[configuration websiteDataStore] fetchDataRecordsOfTypes:[NSSet setWithObject:WKWebsiteDataTypeServiceWorkerRegistrations] completionHandler:^(NSArray<WKWebsiteDataRecord *> *websiteDataRecords) {1071 1072 done = true;1073 }];1074 TestWebKitAPI::Util::run(&done);1075 done = false;1076 1077 RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);1078 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];1079 RetainPtr<RegularPageMessageHandler> regularPageMessageHandler = adoptNS([[RegularPageMessageHandler alloc] init]);1080 [[configuration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];1081 1082 ServiceWorkerTCPServer server({1083 { "text/html", mainBytesWithScope },1084 { "application/javascript", scriptBytes },1085 }, {1086 { "text/html", regularPageWithConnectionBytes },1087 }, {1088 { "text/html", regularPageWithConnectionBytes }1089 });1090 1091 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);1092 1093 // Load a page that registers a service worker.1094 [webView loadRequest:server.request()];1095 TestWebKitAPI::Util::run(&done);1096 done = false;1097 webView = nullptr;1098 1099 // Now that a sw is registered, let's create a new configuration and try loading a regular page1100 RetainPtr<WKWebViewConfiguration> newConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);1101 setConfigurationInjectedBundlePath(newConfiguration.get());1102 1103 [[newConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];1104 [[newConfiguration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];1105 1106 newConfiguration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];1107 [newConfiguration.get().websiteDataStore _setServiceWorkerRegistrationDirectory: @"~/nonexistingfolder"];1108 1109 webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);1110 [webView loadRequest:server.request()];1111 TestWebKitAPI::Util::run(&done);1112 done = false;1113 1114 // Let's use the web site data store that has service worker and load a page.1115 newConfiguration.get().websiteDataStore = [configuration websiteDataStore];1116 1117 webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);1118 EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);1119 [webView loadRequest:server.request()];1120 TestWebKitAPI::Util::run(&done);1121 done = false;1122 1123 // Make sure that loading the simple page did not start the service worker process.1124 EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);1125 1046 1126 1047 [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
Note:
See TracChangeset
for help on using the changeset viewer.