Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/dom/PRemoteWorkerParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/ClientIPCUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/RemoteWorkerParent.h"
#include "mozilla/dom/ServiceWorkerIPCUtils.h"
#include "mozilla/dom/WorkerIPCUtils.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/dom/PFetchEventOpProxyParent.h"
#include "mozilla/dom/PRemoteWorkerServiceParent.h"
#include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "nsIFile.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
#include "mozilla/ipc/TaintingIPCUtils.h"
namespace mozilla {
namespace dom {
MOZ_IMPLICIT PRemoteWorkerParent::PRemoteWorkerParent() :
mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
MOZ_COUNT_CTOR(PRemoteWorkerParent);
}
PRemoteWorkerParent::~PRemoteWorkerParent()
{
MOZ_COUNT_DTOR(PRemoteWorkerParent);
}
auto PRemoteWorkerParent::ActorAlloc() -> void
{
AddRef();
}
auto PRemoteWorkerParent::ActorDealloc() -> void
{
Release();
}
auto PRemoteWorkerParent::OtherPid() const -> ::base::ProcessId
{
::base::ProcessId pid =
::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid();
MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId);
return pid;
}
auto PRemoteWorkerParent::OtherChildID() const -> ::GeckoChildID
{
::GeckoChildID childID =
::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherChildIDMaybeInvalid();
MOZ_RELEASE_ASSERT(childID != -1);
return childID;
}
auto PRemoteWorkerParent::OtherEndpointProcInfo() const -> ::mozilla::ipc::EndpointProcInfo
{
return ::mozilla::ipc::EndpointProcInfo{OtherPid(), OtherChildID()};
}
auto PRemoteWorkerParent::Manager() const -> PRemoteWorkerServiceParent*
{
return static_cast<PRemoteWorkerServiceParent*>(IProtocol::Manager());
}
auto PRemoteWorkerParent::ManagedPFetchEventOpProxyParent(nsTArray<PFetchEventOpProxyParent*>& aArr) const -> void
{
mManagedPFetchEventOpProxyParent.ToArray(aArr);
}
auto PRemoteWorkerParent::ManagedPFetchEventOpProxyParent() const -> const ManagedContainer<PFetchEventOpProxyParent>&
{
return mManagedPFetchEventOpProxyParent;
}
auto PRemoteWorkerParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
static constexpr ::mozilla::ipc::ProtocolId sIds[] = {
PFetchEventOpProxyMsgStart
};
return sIds;
}
auto PRemoteWorkerParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
switch (aProtocol) {
case PFetchEventOpProxyMsgStart:
return (&(mManagedPFetchEventOpProxyParent));
default:
return nullptr;
}
}
auto PRemoteWorkerParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
mAsyncCallbacks.RejectPendingResponses(aReason);
}
auto PRemoteWorkerParent::OpenPFetchEventOpProxyEndpoint(PFetchEventOpProxyParent* aActor) -> ManagedEndpoint<PFetchEventOpProxyChild>
{
if (!aActor) {
NS_WARNING("Cannot bind null PFetchEventOpProxyParent actor");
return ManagedEndpoint<PFetchEventOpProxyChild>();
}
if (!aActor->SetManagerAndRegister(this)) {
NS_WARNING("Failed to bind PFetchEventOpProxyParent actor");
return ManagedEndpoint<PFetchEventOpProxyChild>();
}
// Mark our actor as awaiting the other side to be bound. This will
// be cleared when a `MANAGED_ENDPOINT_{DROPPED,BOUND}` message is
// received.
aActor->mAwaitingManagedEndpointBind = true;
return ManagedEndpoint<PFetchEventOpProxyChild>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}
auto PRemoteWorkerParent::BindPFetchEventOpProxyEndpoint(
ManagedEndpoint<PFetchEventOpProxyParent> aEndpoint,
PFetchEventOpProxyParent* aActor) -> bool
{
return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this);
}
auto PRemoteWorkerParent::SendPFetchEventOpProxyConstructor(
PFetchEventOpProxyParent* actor,
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs) -> PFetchEventOpProxyParent*
{
if (!actor) {
NS_WARNING("Cannot bind null PFetchEventOpProxyParent actor");
return nullptr;
}
if (!actor->SetManagerAndRegister(this)) {
NS_WARNING("Failed to bind PFetchEventOpProxyParent actor");
return nullptr;
}
// Build our constructor message.
UniquePtr<IPC::Message> msg__ = PRemoteWorker::Msg_PFetchEventOpProxyConstructor(Id());
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), actor);
// Sentinel = 'actor'
((&(writer__)))->WriteSentinel(102892058);
IPC::WriteParam((&(writer__)), aArgs);
// Sentinel = 'aArgs'
((&(writer__)))->WriteSentinel(92602863);
// Notify the other side about the newly created actor. This can
// fail if our manager has already been destroyed.
//
// NOTE: If the send call fails due to toplevel channel teardown,
// the `IProtocol::ChannelSend` wrapper absorbs the error for us,
// so we don't tear down actors unexpectedly.
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_PFetchEventOpProxyConstructor", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
// Warn, destroy the actor, and return null if the message failed to
// send. Otherwise, return the successfully created actor reference.
if (!sendok__) {
NS_WARNING("Error sending PFetchEventOpProxyParent constructor");
actor->ActorDisconnected(FailedConstructor);
return nullptr;
}
return actor;
}
auto PRemoteWorkerParent::Send__delete__(PRemoteWorkerParent* actor) -> bool
{
if (!actor || !actor->CanSend()) {
NS_WARNING("Attempt to __delete__ missing or closed actor");
return false;
}
UniquePtr<IPC::Message> msg__ = PRemoteWorker::Msg___delete__((actor)->Id());
IPC::MessageWriter writer__{
(*(msg__)),
actor};
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
actor->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg___delete__", OTHER);
bool sendok__ = (actor)->ChannelSend(std::move(msg__));
actor->ActorDisconnected(Deletion);
return sendok__;
}
auto PRemoteWorkerParent::SendExecOp(const SharedWorkerOpArgs& aArgs) -> bool
{
UniquePtr<IPC::Message> msg__ = PRemoteWorker::Msg_ExecOp(Id());
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), aArgs);
// Sentinel = 'aArgs'
((&(writer__)))->WriteSentinel(92602863);
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_ExecOp", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
return sendok__;
}
auto PRemoteWorkerParent::SendExecServiceWorkerOp(
const ServiceWorkerOpArgs& aArgs,
mozilla::ipc::ResolveCallback<ServiceWorkerOpResult>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PRemoteWorker::Msg_ExecServiceWorkerOp(Id());
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), aArgs);
// Sentinel = 'aArgs'
((&(writer__)))->WriteSentinel(92602863);
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_ExecServiceWorkerOp", OTHER);
int32_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PRemoteWorker::Reply_ExecServiceWorkerOp__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__aResult = IPC::ReadParam<ServiceWorkerOpResult>(aReader);
if (!maybe__aResult) {
(aReader)->FatalError("Error deserializing 'ServiceWorkerOpResult'");
return MsgValueError;
}
auto& aResult = *maybe__aResult;
// Sentinel = 'aResult'
if ((!((aReader)->ReadSentinel(185205473)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'ServiceWorkerOpResult'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(aResult));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PRemoteWorkerParent::SendExecServiceWorkerOp(const ServiceWorkerOpArgs& aArgs) -> RefPtr<ExecServiceWorkerOpPromise>
{
RefPtr<MozPromise<ServiceWorkerOpResult, ResponseRejectReason, true>::Private> promise__ = new MozPromise<ServiceWorkerOpResult, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendExecServiceWorkerOp(std::move(aArgs), [promise__](ServiceWorkerOpResult&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PRemoteWorkerParent::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
default:
FatalError("unreached");
return;
}
}
auto PRemoteWorkerParent::OnMessageReceived(const Message& msg__) -> PRemoteWorkerParent::Result
{
switch (msg__.type()) {
case MANAGED_ENDPOINT_BOUND_MESSAGE_TYPE:
{
if (!mAwaitingManagedEndpointBind) {
NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
return MsgNotAllowed;
}
mAwaitingManagedEndpointBind = false;
return MsgProcessed;
}
case MANAGED_ENDPOINT_DROPPED_MESSAGE_TYPE:
{
if (!mAwaitingManagedEndpointBind) {
NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
return MsgNotAllowed;
}
mAwaitingManagedEndpointBind = false;
this->ActorDisconnected(ManagedEndpointDropped);
return MsgProcessed;
}
case PRemoteWorker::Msg_Created__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_Created", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__aStatus = IPC::ReadParam<bool>((&(reader__)));
if (!maybe__aStatus) {
FatalError("Error deserializing 'bool'");
return MsgValueError;
}
auto& aStatus = *maybe__aStatus;
// Sentinel = 'aStatus'
if ((!(((&(reader__)))->ReadSentinel(186712806)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
return MsgValueError;
}
reader__.EndRead();
mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerParent*>(this))->RecvCreated(std::move(aStatus));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PRemoteWorker::Msg_Error__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_Error", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__aValue = IPC::ReadParam<ErrorValue>((&(reader__)));
if (!maybe__aValue) {
FatalError("Error deserializing 'ErrorValue'");
return MsgValueError;
}
auto& aValue = *maybe__aValue;
// Sentinel = 'aValue'
if ((!(((&(reader__)))->ReadSentinel(135332447)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'ErrorValue'");
return MsgValueError;
}
reader__.EndRead();
mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerParent*>(this))->RecvError(std::move(aValue));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PRemoteWorker::Msg_NotifyLock__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_NotifyLock", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__aCreated = IPC::ReadParam<bool>((&(reader__)));
if (!maybe__aCreated) {
FatalError("Error deserializing 'bool'");
return MsgValueError;
}
auto& aCreated = *maybe__aCreated;
// Sentinel = 'aCreated'
if ((!(((&(reader__)))->ReadSentinel(228066074)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
return MsgValueError;
}
reader__.EndRead();
mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerParent*>(this))->RecvNotifyLock(std::move(aCreated));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PRemoteWorker::Msg_NotifyWebTransport__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_NotifyWebTransport", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__aCreated = IPC::ReadParam<bool>((&(reader__)));
if (!maybe__aCreated) {
FatalError("Error deserializing 'bool'");
return MsgValueError;
}
auto& aCreated = *maybe__aCreated;
// Sentinel = 'aCreated'
if ((!(((&(reader__)))->ReadSentinel(228066074)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
return MsgValueError;
}
reader__.EndRead();
mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerParent*>(this))->RecvNotifyWebTransport(std::move(aCreated));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PRemoteWorker::Msg_Close__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_Close", OTHER);
mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerParent*>(this))->RecvClose();
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PRemoteWorker::Msg_SetServiceWorkerSkipWaitingFlag__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_SetServiceWorkerSkipWaitingFlag", OTHER);
int32_t id__ = Id();
UniquePtr<IPC::Message> reply__(PRemoteWorker::Reply_SetServiceWorkerSkipWaitingFlag(id__));
reply__->set_seqno(msg__.seqno());
RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);
SetServiceWorkerSkipWaitingFlagResolver resolver = [resolver__ = std::move(resolver__)](const bool& aParam) {
resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
IPC::MessageWriter writer__(*reply__, self__);
IPC::WriteParam((&(writer__)), aParam);
// Sentinel = 'aOk'
((&(writer__)))->WriteSentinel(36634908);
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending reply ",
reply__->type(),
mozilla::ipc::MessageDirection::eSending);
}
});
};
mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerParent*>(this))->RecvSetServiceWorkerSkipWaitingFlag(std::move(resolver));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PRemoteWorker::Reply_PFetchEventOpProxyConstructor__ID:
{
return MsgProcessed;
}
case PRemoteWorker::Reply___delete____ID:
{
return MsgProcessed;
}
case PRemoteWorker::Reply_ExecServiceWorkerOp__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PRemoteWorker", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PRemoteWorkerParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PRemoteWorker::Msg_ExecServiceWorkerOp", OTHER);
return mAsyncCallbacks.GotReply(this, msg__);
}
default:
return MsgNotKnown;
}
}
auto PRemoteWorkerParent::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PRemoteWorkerParent::Result
{
MOZ_ASSERT_UNREACHABLE("message protocol not supported");
return MsgNotKnown;
}
} // namespace dom
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::dom::PRemoteWorkerParent*>::Write(
IPC::MessageWriter* aWriter,
const paramType& aVar) -> void
{
MOZ_RELEASE_ASSERT(
aWriter->GetActor(),
"Cannot serialize managed actors without an actor");
int32_t id;
if (!aVar) {
id = 0; // kNullActorId
} else {
id = aVar->Id();
if (id == 1) { // kFreedActorId
aVar->FatalError("Actor has been |delete|d");
}
MOZ_RELEASE_ASSERT(
aWriter->GetActor()->GetIPCChannel() == aVar->GetIPCChannel(),
"Actor must be from the same channel as the"
" actor it's being sent over");
MOZ_RELEASE_ASSERT(
aVar->CanSend(),
"Actor must still be open when sending");
}
IPC::WriteParam(aWriter, id);
}
auto ParamTraits<::mozilla::dom::PRemoteWorkerParent*>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
MOZ_RELEASE_ASSERT(
aReader->GetActor(),
"Cannot deserialize managed actors without an actor");
mozilla::Maybe<mozilla::ipc::IProtocol*> actor = aReader->GetActor()
->ReadActor(aReader, true, "PRemoteWorker", PRemoteWorkerMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::dom::PRemoteWorkerParent*>(actor.ref());
}
return {};
}
} // namespace IPC