ServiceWorkerClientData.h [plain text]
#pragma once
#if ENABLE(SERVICE_WORKER)
#include "ServiceWorkerClientIdentifier.h"
#include "ServiceWorkerClientType.h"
#include "ServiceWorkerTypes.h"
#include <wtf/URL.h>
namespace WebCore {
class SWClientConnection;
class ScriptExecutionContext;
struct ServiceWorkerClientData {
ServiceWorkerClientIdentifier identifier;
ServiceWorkerClientType type;
ServiceWorkerClientFrameType frameType;
URL url;
ServiceWorkerClientData isolatedCopy() const;
static ServiceWorkerClientData from(ScriptExecutionContext&, SWClientConnection&);
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<ServiceWorkerClientData> decode(Decoder&);
};
template<class Encoder>
void ServiceWorkerClientData::encode(Encoder& encoder) const
{
encoder << identifier << type << frameType << url;
}
template<class Decoder>
Optional<ServiceWorkerClientData> ServiceWorkerClientData::decode(Decoder& decoder)
{
Optional<ServiceWorkerClientIdentifier> identifier;
decoder >> identifier;
if (!identifier)
return WTF::nullopt;
Optional<ServiceWorkerClientType> type;
decoder >> type;
if (!type)
return WTF::nullopt;
Optional<ServiceWorkerClientFrameType> frameType;
decoder >> frameType;
if (!frameType)
return WTF::nullopt;
Optional<URL> url;
decoder >> url;
if (!url)
return WTF::nullopt;
return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url) } };
}
using ServiceWorkerClientsMatchAllCallback = WTF::CompletionHandler<void(Vector<ServiceWorkerClientData>&&)>;
}
#endif // ENABLE(SERVICE_WORKER)