Skip to content
Permalink
Browse files
Add a SW context process (where SW scripts will actually execute).
https://bugs.webkit.org/show_bug.cgi?id=178156
Source/WebCore:

Reviewed by Andy Estes.

No new tests (Covered by changes to existing tests).

This patch adds an auxiliary "ServiceWorker context" WebProcess to a WebProcessPool.

This process is where ServiceWorker scripts will execute, separate from the client WebProcess
hosting the page(s) they are serving.

This patch also adds all of the plumbing to pass along a fetched service worker script to this
context WebProcess, as well as message back failure to actually start the script so we can test.

Touches lots of code sites but is basically just a lot of plumbing.

* WebCore.xcodeproj/project.pbxproj:

* workers/service/ServiceWorkerContextData.h: Copied from Source/WebCore/workers/service/server/SWServerWorker.h.
(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::finishFetchingScriptInServer):
(WebCore::SWServer::Connection::scriptContextFailedToStart):
(WebCore::SWServer::scriptFetchFinished):
(WebCore::SWServer::scriptContextFailedToStart):
(WebCore::SWServer::createWorker):
* workers/service/server/SWServer.h:

* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::scriptFetchFinished):
(WebCore::SWServerRegistration::scriptContextFailedToStart):
* workers/service/server/SWServerRegistration.h:

* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::SWServerWorker):
(WebCore::SWServerWorker::~SWServerWorker):
* workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::create):
(WebCore::SWServerWorker::scriptURL const):
(WebCore::SWServerWorker::script const):
(WebCore::SWServerWorker::type const):
(WebCore::SWServerWorker::workerID const):

Source/WebKit:

Reviewed by Andy Estes.

This patch adds an auxiliary "ServiceWorker context" WebProcess to a WebProcessPool.

This process is where ServiceWorker scripts will execute, separate from the client WebProcess
hosting the page(s) they are serving.

This patch also adds all of the plumbing to pass along a fetched service worker script to this
context WebProcess, as well as message back failure to actually start the script so we can test.

Touches lots of code sites but is basically just a lot of plumbing.

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::WebSWServerConnection):
(WebKit::WebSWServerConnection::startServiceWorkerContext):
(WebKit::WebSWServerConnection::sendToContextProcess):
(WebKit::WebSWServerConnection::setContextConnection):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::workerContextProcessConnection):
(WebKit::StorageProcess::createWorkerContextProcessConnection):
(WebKit::StorageProcess::didGetWorkerContextProcessConnection):
(WebKit::StorageProcess::serviceWorkerContextFailedToStart):
(WebKit::StorageProcess::registerSWServerConnection):
(WebKit::StorageProcess::unregisterSWServerConnection):
* StorageProcess/StorageProcess.h:
* StorageProcess/StorageProcess.messages.in:

* StorageProcess/StorageToWebProcessConnection.cpp:
(WebKit::StorageToWebProcessConnection::~StorageToWebProcessConnection):
(WebKit::StorageToWebProcessConnection::establishSWServerConnection):
(WebKit::StorageToWebProcessConnection::removeSWServerConnection):
(WebKit::StorageToWebProcessConnection::workerContextProcessConnectionCreated):
* StorageProcess/StorageToWebProcessConnection.h:

* UIProcess/Storage/StorageProcessProxy.cpp:
(WebKit::StorageProcessProxy::create):
(WebKit::StorageProcessProxy::StorageProcessProxy):
(WebKit::StorageProcessProxy::didClose):
(WebKit::StorageProcessProxy::getWorkerContextProcessConnection):
(WebKit::StorageProcessProxy::didGetWorkerContextProcessConnection):
* UIProcess/Storage/StorageProcessProxy.h:
* UIProcess/Storage/StorageProcessProxy.messages.in:

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore):
(WebKit::WebProcessPool::getWorkerContextProcessConnection):
(WebKit::WebProcessPool::didGetWorkerContextProcessConnection):
(WebKit::WebProcessPool::disconnectProcess):
(WebKit::WebProcessPool::createWebPage):
* UIProcess/WebProcessPool.h:

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didGetWorkerContextConnection):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::getWorkerContextConnection):
(WebKit::WebProcess::startServiceWorkerContext):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

LayoutTests:

Reviewed by Andy Estes.

* http/tests/workers/service/basic-register-exceptions-expected.txt:
* http/tests/workers/service/basic-register-expected.txt:
* http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt:


Canonical link: https://commits.webkit.org/194423@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
beidson committed Oct 11, 2017
1 parent 1fe2866 commit 30643ffd7c34a4a831204009200c3ba1fe4c72a4
Showing 32 changed files with 605 additions and 44 deletions.
@@ -1,3 +1,14 @@
2017-10-11 Brady Eidson <beidson@apple.com>

Add a SW context process (where SW scripts will actually execute).
https://bugs.webkit.org/show_bug.cgi?id=178156

Reviewed by Andy Estes.

* http/tests/workers/service/basic-register-exceptions-expected.txt:
* http/tests/workers/service/basic-register-expected.txt:
* http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt:

2017-10-11 Joanmarie Diggs <jdiggs@igalia.com>

[ATK] Expose value of aria-keyshortcuts as object attribute
@@ -4,7 +4,7 @@ CONSOLE MESSAGE: line 40: Registration failed with error: TypeError: serviceWork
CONSOLE MESSAGE: line 50: Registration failed with error: TypeError: serviceWorker.register() must be called with a script URL whose path does not contain '%2f' or '%5c'
CONSOLE MESSAGE: line 60: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() must be either HTTP or HTTPS
CONSOLE MESSAGE: line 70: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() cannot have a path that contains '%2f' or '%5c'
CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/image-mime-type.php fetched with 0 characters, but we're not using the result yet
CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Failed to start service worker script of length 0
CONSOLE MESSAGE: line 80: Registration failed with error: SecurityError: Script origin does not match the registering client's origin
CONSOLE MESSAGE: line 91: Registration failed with error: SecurityError: Scope origin does not match the registering client's origin

@@ -1,3 +1,3 @@
CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 characters, but we're not using the result yet
CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker-doesnt-exist.js fetched with 0 characters, but we're not using the result yet
CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Failed to start service worker script of length 41
CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Failed to start service worker script of length 0

@@ -1,2 +1,2 @@
ALERT: Done
ALERT: Unexpected error received from server: UnknownError: Failed to start service worker script of length 41

@@ -1,3 +1,51 @@
2017-10-11 Brady Eidson <beidson@apple.com>

Add a SW context process (where SW scripts will actually execute).
https://bugs.webkit.org/show_bug.cgi?id=178156

Reviewed by Andy Estes.

No new tests (Covered by changes to existing tests).

This patch adds an auxiliary "ServiceWorker context" WebProcess to a WebProcessPool.

This process is where ServiceWorker scripts will execute, separate from the client WebProcess
hosting the page(s) they are serving.

This patch also adds all of the plumbing to pass along a fetched service worker script to this
context WebProcess, as well as message back failure to actually start the script so we can test.

Touches lots of code sites but is basically just a lot of plumbing.

* WebCore.xcodeproj/project.pbxproj:

* workers/service/ServiceWorkerContextData.h: Copied from Source/WebCore/workers/service/server/SWServerWorker.h.
(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::finishFetchingScriptInServer):
(WebCore::SWServer::Connection::scriptContextFailedToStart):
(WebCore::SWServer::scriptFetchFinished):
(WebCore::SWServer::scriptContextFailedToStart):
(WebCore::SWServer::createWorker):
* workers/service/server/SWServer.h:

* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::scriptFetchFinished):
(WebCore::SWServerRegistration::scriptContextFailedToStart):
* workers/service/server/SWServerRegistration.h:

* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::SWServerWorker):
(WebCore::SWServerWorker::~SWServerWorker):
* workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::create):
(WebCore::SWServerWorker::scriptURL const):
(WebCore::SWServerWorker::script const):
(WebCore::SWServerWorker::type const):
(WebCore::SWServerWorker::workerID const):

2017-10-11 Joanmarie Diggs <jdiggs@igalia.com>

[ATK] Expose value of aria-keyshortcuts as object attribute
@@ -2464,6 +2464,7 @@
51C61B0B1DE536E7008A212D /* ScrollingMomentumCalculator.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C61B091DE536E7008A212D /* ScrollingMomentumCalculator.h */; settings = {ATTRIBUTES = (Private, ); }; };
51C81B890C4422F70019ECE3 /* FTPDirectoryParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */; };
51C81B8A0C4422F70019ECE3 /* FTPDirectoryParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */; };
51CA7EE91F883390003D3131 /* ServiceWorkerContextData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */; settings = {ATTRIBUTES = (Private, ); }; };
51CBFC990D10E483002DBF51 /* CachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */; settings = {ATTRIBUTES = (Private, ); }; };
51D1248B1E73627F002B2820 /* NetworkStorageSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */; };
51D1248D1E7364AA002B2820 /* CookieCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248C1E736456002B2820 /* CookieCocoa.mm */; };
@@ -10363,6 +10364,7 @@
51C61B091DE536E7008A212D /* ScrollingMomentumCalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingMomentumCalculator.h; sourceTree = "<group>"; };
51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FTPDirectoryParser.cpp; sourceTree = "<group>"; };
51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryParser.h; sourceTree = "<group>"; };
51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerContextData.h; sourceTree = "<group>"; };
51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFramePlatformData.h; sourceTree = "<group>"; };
51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStorageSessionCocoa.mm; sourceTree = "<group>"; };
51D1248C1E736456002B2820 /* CookieCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieCocoa.mm; sourceTree = "<group>"; };
@@ -19212,6 +19214,7 @@
51F175581F3EBC0C00C74950 /* ServiceWorkerContainer.cpp */,
51F175571F3EBC0C00C74950 /* ServiceWorkerContainer.h */,
51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */,
51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */,
517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */,
51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
51F175541F3EBC0C00C74950 /* ServiceWorkerGlobalScope.h */,
@@ -30152,6 +30155,7 @@
2D93AEE319DF5641002A86C3 /* ServicesOverlayController.h in Headers */,
51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */,
51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */,
51CA7EE91F883390003D3131 /* ServiceWorkerContextData.h in Headers */,
517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */,
51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */,
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include "ServiceWorkerRegistrationKey.h"

#if ENABLE(SERVICE_WORKER)

namespace WebCore {

struct ServiceWorkerContextData {
ServiceWorkerRegistrationKey registrationKey;
String workerID;
String script;

template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ServiceWorkerContextData> decode(Decoder&);
};

template<class Encoder>
void ServiceWorkerContextData::encode(Encoder& encoder) const
{
encoder << registrationKey << workerID << script;
}

template<class Decoder>
std::optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder& decoder)
{
auto registrationKey = ServiceWorkerRegistrationKey::decode(decoder);
if (!registrationKey)
return std::nullopt;

String workerID;
if (!decoder.decode(workerID))
return std::nullopt;

String script;
if (!decoder.decode(script))
return std::nullopt;

return {{ WTFMove(*registrationKey), WTFMove(workerID), WTFMove(script) }};
}

} // namespace WebCore

#endif // ENABLE(SERVICE_WORKER)
@@ -32,8 +32,11 @@
#include "ExceptionData.h"
#include "Logging.h"
#include "SWServerRegistration.h"
#include "SWServerWorker.h"
#include "ServiceWorkerContextData.h"
#include "ServiceWorkerFetchResult.h"
#include "ServiceWorkerJobData.h"
#include <wtf/UUID.h>
#include <wtf/text/WTFString.h>

namespace WebCore {
@@ -75,7 +78,12 @@ void SWServer::Connection::scheduleJobInServer(const ServiceWorkerJobData& jobDa

void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
{
m_server.scriptFetchFinished(result);
m_server.scriptFetchFinished(*this, result);
}

void SWServer::Connection::scriptContextFailedToStart(const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message)
{
m_server.scriptContextFailedToStart(*this, registrationKey, workerID, message);
}

SWServer::SWServer()
@@ -128,7 +136,7 @@ void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData)
connection->startScriptFetchInClient(jobData.identifier());
}

void SWServer::scriptFetchFinished(const ServiceWorkerFetchResult& result)
void SWServer::scriptFetchFinished(Connection& connection, const ServiceWorkerFetchResult& result)
{
LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %" PRIu64 "-%" PRIu64 " in client", result.connectionIdentifier, result.jobIdentifier);

@@ -138,7 +146,27 @@ void SWServer::scriptFetchFinished(const ServiceWorkerFetchResult& result)
if (!registration)
return;

registration->scriptFetchFinished(result);
registration->scriptFetchFinished(connection, result);
}

void SWServer::scriptContextFailedToStart(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message)
{
ASSERT(m_connections.contains(connection.identifier()));

if (auto* registration = m_registrations.get(registrationKey))
registration->scriptContextFailedToStart(connection, workerID, message);
}

Ref<SWServerWorker> SWServer::createWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
{
String workerID = createCanonicalUUIDString();

auto result = m_workersByID.add(workerID, SWServerWorker::create(registrationKey, url, script, type, workerID));
ASSERT(result.isNewEntry);

connection.startServiceWorkerContext({ registrationKey, workerID, script });

return result.iterator->value.get();
}

void SWServer::taskThreadEntryPoint()
@@ -27,7 +27,6 @@

#if ENABLE(SERVICE_WORKER)

#include "SWServerRegistration.h"
#include "ServiceWorkerJob.h"
#include "ServiceWorkerRegistrationKey.h"
#include <wtf/CrossThreadQueue.h>
@@ -42,7 +41,9 @@
namespace WebCore {

class SWServerRegistration;
class SWServerWorker;
struct ExceptionData;
struct ServiceWorkerContextData;
struct ServiceWorkerFetchResult;
struct ServiceWorkerRegistrationData;

@@ -53,6 +54,8 @@ class SWServer {
public:
WEBCORE_EXPORT virtual ~Connection();

WEBCORE_EXPORT void scriptContextFailedToStart(const ServiceWorkerRegistrationKey&, const String& workerID, const String& message);

protected:
WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier);
SWServer& server() { return m_server; }
@@ -61,10 +64,14 @@ class SWServer {
WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);

private:
// Messages to the client WebProcess
virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0;
virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;

// Messages to the SW host WebProcess
virtual void startServiceWorkerContext(const ServiceWorkerContextData&) = 0;

SWServer& m_server;
};

@@ -79,18 +86,23 @@ class SWServer {
void postTask(CrossThreadTask&&);
void postTaskReply(CrossThreadTask&&);

Ref<SWServerWorker> createWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);

private:
void registerConnection(Connection&);
void unregisterConnection(Connection&);

void taskThreadEntryPoint();
void handleTaskRepliesOnMainThread();

void scriptFetchFinished(const ServiceWorkerFetchResult&);
void scriptFetchFinished(Connection&, const ServiceWorkerFetchResult&);
void scriptContextFailedToStart(Connection&, const ServiceWorkerRegistrationKey&, const String& workerID, const String& message);

HashMap<uint64_t, Connection*> m_connections;
HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations;

HashMap<String, Ref<SWServerWorker>> m_workersByID;

RefPtr<Thread> m_taskThread;
Lock m_taskThreadLock;

@@ -64,18 +64,32 @@ void SWServerRegistration::enqueueJob(const ServiceWorkerJobData& jobData)
m_jobTimer.startOneShot(0_s);
}

void SWServerRegistration::scriptFetchFinished(const ServiceWorkerFetchResult& result)
void SWServerRegistration::scriptFetchFinished(SWServer::Connection& connection, const ServiceWorkerFetchResult& result)
{
ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier);

// FIXME: We fetched the script contents but don't do anything with them yet.
// These errors are for testing the current state of the feature.
if (!result.scriptError.isNull()) {
rejectCurrentJob(ExceptionData { UnknownError, makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription()) });

// If newestWorker is null, invoke Clear Registration algorithm passing this registration as its argument.
// FIXME: We don't have "clear registration" yet.

String message;
if (result.scriptError.isNull())
message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetched with ", String::number(result.script.length()), " characters, but we're not using the result yet");
else
message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription());
return;
}

m_lastUpdateTime = currentTime();

// FIXME: If the script data matches byte-for-byte with the existing newestWorker,
// then resolve and finish the job without doing anything further.

// FIXME: Support the proper worker type (classic vs module)
m_server.createWorker(connection, m_registrationKey, m_currentJob->scriptURL, result.script, WorkerType::Classic);
}

void SWServerRegistration::scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message)
{
ASSERT(m_currentJob);
UNUSED_PARAM(workerID);

rejectCurrentJob(ExceptionData { UnknownError, message });
}
@@ -27,6 +27,7 @@

#if ENABLE(SERVICE_WORKER)

#include "SWServer.h"
#include "ServiceWorkerJobData.h"
#include "ServiceWorkerRegistrationData.h"
#include "Timer.h"
@@ -47,8 +48,9 @@ class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
~SWServerRegistration();

void enqueueJob(const ServiceWorkerJobData&);
void scriptFetchFinished(const ServiceWorkerFetchResult&);

void scriptFetchFinished(SWServer::Connection&, const ServiceWorkerFetchResult&);
void scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message);

ServiceWorkerRegistrationData data() const;

private:
@@ -77,6 +79,8 @@ class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
std::unique_ptr<SWServerWorker> m_activeWorker;
URL m_scopeURL;
std::optional<ServiceWorkerUpdateViaCache> m_updateViaCache;

double m_lastUpdateTime { 0 };

Timer m_jobTimer;
SWServer& m_server;

0 comments on commit 30643ff

Please sign in to comment.