WebServiceWorkerProvider.cpp [plain text]
#include "config.h"
#include "WebServiceWorkerProvider.h"
#if ENABLE(SERVICE_WORKER)
#include "NetworkProcessConnection.h"
#include "WebProcess.h"
#include "WebSWClientConnection.h"
#include "WebSWServerConnection.h"
#include <WebCore/CachedResource.h>
#include <WebCore/Exception.h>
#include <WebCore/ExceptionCode.h>
#include <WebCore/LegacySchemeRegistry.h>
#include <WebCore/RuntimeEnabledFeatures.h>
#include <WebCore/ServiceWorkerJob.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
using namespace PAL;
using namespace WebCore;
WebServiceWorkerProvider& WebServiceWorkerProvider::singleton()
{
static NeverDestroyed<WebServiceWorkerProvider> provider;
return provider;
}
WebServiceWorkerProvider::WebServiceWorkerProvider()
{
}
WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnection()
{
ASSERT(RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled());
return WebProcess::singleton().ensureNetworkProcessConnection().serviceWorkerConnection();
}
void WebServiceWorkerProvider::updateThrottleState(bool isThrottleable)
{
auto* networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection();
if (!networkProcessConnection)
return;
auto& connection = networkProcessConnection->serviceWorkerConnection();
if (isThrottleable != connection.isThrottleable())
connection.updateThrottleState();
}
void WebServiceWorkerProvider::terminateWorkerForTesting(WebCore::ServiceWorkerIdentifier identifier, CompletionHandler<void()>&& callback)
{
WebProcess::singleton().ensureNetworkProcessConnection().serviceWorkerConnection().terminateWorkerForTesting(identifier, WTFMove(callback));
}
}
#endif // ENABLE(SERVICE_WORKER)