WebSWServerToContextConnection.h [plain text]
#pragma once
#if ENABLE(SERVICE_WORKER)
#include "MessageReceiver.h"
#include "MessageSender.h"
#include "ServiceWorkerFetchTask.h"
#include <WebCore/SWServerToContextConnection.h>
#include <wtf/WeakPtr.h>
namespace WebCore {
struct FetchOptions;
struct MessageWithMessagePorts;
class ResourceRequest;
}
namespace IPC {
class FormDataReference;
}
namespace PAL {
class SessionID;
}
namespace WebKit {
class NetworkConnectionToWebProcess;
class WebSWServerConnection;
class WebSWServerToContextConnection: public CanMakeWeakPtr<WebSWServerToContextConnection>, public WebCore::SWServerToContextConnection, public IPC::MessageSender, public IPC::MessageReceiver {
public:
WebSWServerToContextConnection(NetworkConnectionToWebProcess&, WebCore::RegistrableDomain&&, WebCore::SWServer&);
~WebSWServerToContextConnection();
IPC::Connection& ipcConnection() const;
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
void startFetch(ServiceWorkerFetchTask&);
void cancelFetch(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier);
void didReceiveFetchTaskMessage(IPC::Connection&, IPC::Decoder&);
void setThrottleState(bool isThrottleable);
bool isThrottleable() const { return m_isThrottleable; }
void registerFetch(ServiceWorkerFetchTask&);
void unregisterFetch(ServiceWorkerFetchTask&);
WebCore::ProcessIdentifier webProcessIdentifier() const;
private:
IPC::Connection* messageSenderConnection() const final;
uint64_t messageSenderDestinationID() const final;
void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const WebCore::MessageWithMessagePorts&, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
void installServiceWorkerContext(const WebCore::ServiceWorkerContextData&, const String& userAgent) final;
void fireInstallEvent(WebCore::ServiceWorkerIdentifier) final;
void fireActivateEvent(WebCore::ServiceWorkerIdentifier) final;
void terminateWorker(WebCore::ServiceWorkerIdentifier) final;
void findClientByIdentifierCompleted(uint64_t requestIdentifier, const Optional<WebCore::ServiceWorkerClientData>&, bool hasSecurityError) final;
void matchAllCompleted(uint64_t requestIdentifier, const Vector<WebCore::ServiceWorkerClientData>&) final;
void connectionIsNoLongerNeeded() final;
void terminateDueToUnresponsiveness() final;
void connectionClosed();
NetworkConnectionToWebProcess& m_connection;
WeakPtr<WebCore::SWServer> m_server;
HashMap<WebCore::FetchIdentifier, WeakPtr<ServiceWorkerFetchTask>> m_ongoingFetches;
bool m_isThrottleable { true };
};
}
#endif // ENABLE(SERVICE_WORKER)