Skip to content

Commit

Permalink
Remove NetworkResourceLoader::m_resultingClientIdentifier
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=256357
rdar://problem/108937686

Reviewed by Alex Christensen.

We no longer need NetworkResourceLoader::m_resultingClientIdentifier:
- We are consistently storing the identifier inside NetworkResourceLoader parameters.
- On same origin redirections, we reuse the same identifier and are doing so even if transferring to another web process.
- On cross origin redirections, we should not reuse the same identifier and use a different NetworkResourceLoader.

* Source/WebKit/NetworkProcess/NetworkResourceLoader.h:
* Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
(WebKit::ServiceWorkerFetchTask::startFetch):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::createFetchTask):

Canonical link: https://commits.webkit.org/264461@main
  • Loading branch information
youennf committed May 24, 2023
1 parent fe4af8b commit fd2fc6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 0 additions & 3 deletions Source/WebKit/NetworkProcess/NetworkResourceLoader.h
Expand Up @@ -160,8 +160,6 @@ class NetworkResourceLoader final
#if ENABLE(SERVICE_WORKER)
void startWithServiceWorker();
void serviceWorkerDidNotHandle(ServiceWorkerFetchTask*);
void setResultingClientIdentifier(String&& identifier) { m_resultingClientIdentifier = WTFMove(identifier); }
const String& resultingClientIdentifier() const { return m_resultingClientIdentifier; }
void setServiceWorkerRegistration(WebCore::SWServerRegistration& serviceWorkerRegistration) { m_serviceWorkerRegistration = serviceWorkerRegistration; }
void setWorkerStart(MonotonicTime);
MonotonicTime workerStart() const { return m_workerStart; }
Expand Down Expand Up @@ -314,7 +312,6 @@ class NetworkResourceLoader final
std::optional<NetworkActivityTracker> m_networkActivityTracker;
#if ENABLE(SERVICE_WORKER)
std::unique_ptr<ServiceWorkerFetchTask> m_serviceWorkerFetchTask;
String m_resultingClientIdentifier;
WeakPtr<WebCore::SWServerRegistration> m_serviceWorkerRegistration;
MonotonicTime m_workerStart;
#endif
Expand Down
Expand Up @@ -174,8 +174,11 @@ void ServiceWorkerFetchTask::startFetch()
if (auto identifier = m_loader.parameters().options.clientIdentifier)
clientIdentifier = identifier->toString();
}
String resultingClientIdentifier;
if (auto& identifier = m_loader.parameters().options.resultingClientIdentifier)
resultingClientIdentifier = identifier->toString();

bool isSent = sendToServiceWorker(Messages::WebSWContextManagerConnection::StartFetch { m_serverConnectionIdentifier, m_serviceWorkerIdentifier, m_fetchIdentifier, request, options, IPC::FormDataReference { m_currentRequest.httpBody() }, referrer, m_preloader && m_preloader->isServiceWorkerNavigationPreloadEnabled(), clientIdentifier, m_loader.resultingClientIdentifier() });
bool isSent = sendToServiceWorker(Messages::WebSWContextManagerConnection::StartFetch { m_serverConnectionIdentifier, m_serviceWorkerIdentifier, m_fetchIdentifier, request, options, IPC::FormDataReference { m_currentRequest.httpBody() }, referrer, m_preloader && m_preloader->isServiceWorkerNavigationPreloadEnabled(), clientIdentifier, resultingClientIdentifier });
ASSERT_UNUSED(isSent, isSent);
}

Expand Down
Expand Up @@ -217,7 +217,6 @@ std::unique_ptr<ServiceWorkerFetchTask> WebSWServerConnection::createFetchTask(N

serviceWorkerRegistrationIdentifier = registration->identifier();
controlClient(loader.parameters(), *registration, request, loader.connectionToWebProcess().webProcessIdentifier());
loader.setResultingClientIdentifier(resultingClientIdentifier->toString());
loader.setServiceWorkerRegistration(*registration);
} else {
if (!loader.parameters().serviceWorkerRegistrationIdentifier)
Expand Down

0 comments on commit fd2fc6d

Please sign in to comment.