A service worker process should app nap when all its clients app nap
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 May 2019 19:48:51 +0000 (19:48 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 May 2019 19:48:51 +0000 (19:48 +0000)
commit7b6d95b5e47e6e577e9cd11c089cef6b4e18ce6d
tree316ef2bffcdabee3c6ba983f188b4455d5ab3400
parentf41509c53d7adb68d09c7a8843333a70ab82f45f
A service worker process should app nap when all its clients app nap
https://bugs.webkit.org/show_bug.cgi?id=185626
<rdar://problem/46785908>

Reviewed by Alex Christensen.

Source/WebCore:

Update RegistrableDomain to work with SecurityOriginData.
Add internal API to enable accessing to service worker process throttle state.

Test: http/wpt/service-workers/mac/processSuppression.https.html

* platform/RegistrableDomain.h:
(WebCore::RegistrableDomain::RegistrableDomain):
(WebCore::RegistrableDomain::matches const):
(WebCore::RegistrableDomain::registrableDomainFromHost):
* testing/ServiceWorkerInternals.cpp:
(WebCore::ServiceWorkerInternals::isThrottleable const):
* testing/ServiceWorkerInternals.h:
* testing/ServiceWorkerInternals.idl:
* workers/service/SWClientConnection.h:
* workers/service/context/SWContextManager.cpp:
* workers/service/context/SWContextManager.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::serverToContextConnectionCreated):
* workers/service/server/SWServer.h:
(WebCore::SWServer::Connection::server const):
(WebCore::SWServer::connections const):
* workers/service/server/SWServerToContextConnection.h:

Source/WebKit:

Compute whether a given web process can be throttled on every page throttling change.
Send that information to network process which stores that information in WebSWServerConnection.
Every WebSWServerToContextConnection throttle state is then computed based on all WebSWServerConnection
that have a client that matches the registrable domain of the context connection.

* NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::registerServiceWorkerClient):
(WebKit::WebSWServerConnection::unregisterServiceWorkerClient):
(WebKit::WebSWServerConnection::hasMatchingClient const):
(WebKit::WebSWServerConnection::computeThrottleState const):
(WebKit::WebSWServerConnection::setThrottleState):
(WebKit::WebSWServerConnection::updateThrottleState):
(WebKit::WebSWServerConnection::serverToContextConnectionCreated):
* NetworkProcess/ServiceWorker/WebSWServerConnection.h:
(WebKit::WebSWServerConnection::isThrottleable const):
* NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in:
* NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::setThrottleState):
* NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
(WebKit::WebSWServerToContextConnection::isThrottleable const):
* UIProcess/ServiceWorkerProcessProxy.cpp:
* UIProcess/ServiceWorkerProcessProxy.h:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::WebSWClientConnection):
(WebKit::WebSWClientConnection::updateThrottleState):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::setThrottleState):
(WebKit::WebSWContextManagerConnection::isThrottleable const):
* WebProcess/Storage/WebSWContextManagerConnection.h:
* WebProcess/Storage/WebSWContextManagerConnection.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updateUserActivity):
(WebKit::WebPage::isThrottleable const):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::arePagesThrottleable const):
* WebProcess/WebProcess.h:

Tools:

Allow to enable app nap through test header.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):

LayoutTests:

* http/wpt/service-workers/mac/throttleable-worker.js: Added.
* http/wpt/service-workers/mac/throttleable.https-expected.txt: Added.
* http/wpt/service-workers/mac/throttleable.https.html: Added.
* platform/ios-wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245299 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/service-workers/mac/throttleable-worker.js [new file with mode: 0644]
LayoutTests/http/wpt/service-workers/mac/throttleable.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/service-workers/mac/throttleable.https.html [new file with mode: 0644]
LayoutTests/platform/ios-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/RegistrableDomain.h
Source/WebCore/testing/ServiceWorkerInternals.cpp
Source/WebCore/testing/ServiceWorkerInternals.h
Source/WebCore/testing/ServiceWorkerInternals.idl
Source/WebCore/workers/service/SWClientConnection.h
Source/WebCore/workers/service/context/SWContextManager.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerToContextConnection.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h