//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/hwinference/PTextGenerationParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/hwinference/TextGenerationParent.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 hwinference {
auto PTextGenerationParent::ProcessingError(
Result aCode,
const char* aReason) -> void
{
}
auto PTextGenerationParent::ShouldContinueFromReplyTimeout() -> bool
{
return true;
}
MOZ_IMPLICIT PTextGenerationParent::PTextGenerationParent() :
mozilla::ipc::IToplevelProtocol("PTextGenerationParent", kProtocolId, mozilla::ipc::ParentSide)
{
MOZ_COUNT_CTOR(PTextGenerationParent);
}
PTextGenerationParent::~PTextGenerationParent()
{
MOZ_COUNT_DTOR(PTextGenerationParent);
}
auto PTextGenerationParent::ActorAlloc() -> void
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PTextGenerationParent'");
AddRef();
}
auto PTextGenerationParent::ActorDealloc() -> void
{
Release();
}
auto PTextGenerationParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
return {};
}
auto PTextGenerationParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
switch (aProtocol) {
default:
return nullptr;
}
}
auto PTextGenerationParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
mAsyncCallbacks.RejectPendingResponses(aReason);
}
auto PTextGenerationParent::SendGenerate(
const GenerateRequest& request,
mozilla::ipc::ResolveCallback<GenerateResponse>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PTextGeneration::Msg_Generate(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), request);
// Sentinel = 'request'
((&(writer__)))->WriteSentinel(202703626);
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTextGeneration::Msg_Generate", OTHER);
IPC::Message::seqno_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PTextGeneration::Reply_Generate__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__response = IPC::ReadParam<GenerateResponse>(aReader);
if (!maybe__response) {
(aReader)->FatalError("Error deserializing 'GenerateResponse'");
return MsgValueError;
}
auto& response = *maybe__response;
// Sentinel = 'response'
if ((!((aReader)->ReadSentinel(260965232)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'GenerateResponse'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(response));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PTextGenerationParent::SendGenerate(const GenerateRequest& request) -> RefPtr<GeneratePromise>
{
RefPtr<MozPromise<GenerateResponse, ResponseRejectReason, true>::Private> promise__ = new MozPromise<GenerateResponse, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendGenerate(std::forward<const GenerateRequest&>(request), [promise__](GenerateResponse&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PTextGenerationParent::SendClear() -> bool
{
UniquePtr<IPC::Message> msg__ = PTextGeneration::Msg_Clear(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTextGeneration::Msg_Clear", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
return sendok__;
}
auto PTextGenerationParent::SendCancel() -> bool
{
UniquePtr<IPC::Message> msg__ = PTextGeneration::Msg_Cancel(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTextGeneration::Msg_Cancel", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
return sendok__;
}
auto PTextGenerationParent::DeallocManagee(
mozilla::ipc::ProtocolId aProtocolId,
IProtocol* aListener) -> void
{
FatalError("unreached");
return;
}
auto PTextGenerationParent::OnMessageReceived(const Message& msg__) -> PTextGenerationParent::Result
{
if (!CanSend()) {
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Ignored message for dead actor",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eSending);
}
return MsgProcessed;
}
switch (msg__.type()) {
case PTextGeneration::Msg_Ready__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTextGeneration::Msg_Ready", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__result = IPC::ReadParam<LoadResult>((&(reader__)));
if (!maybe__result) {
FatalError("Error deserializing 'LoadResult'");
return MsgValueError;
}
auto& result = *maybe__result;
// Sentinel = 'result'
if ((!(((&(reader__)))->ReadSentinel(153223840)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'LoadResult'");
return MsgValueError;
}
reader__.EndRead();
mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::hwinference::TextGenerationParent*>(this))->RecvReady(std::move(result));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PTextGeneration::Msg_Delta__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTextGeneration::Msg_Delta", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__text = IPC::ReadParam<nsCString>((&(reader__)));
if (!maybe__text) {
FatalError("Error deserializing 'nsCString'");
return MsgValueError;
}
auto& text = *maybe__text;
// Sentinel = 'text'
if ((!(((&(reader__)))->ReadSentinel(73859526)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
return MsgValueError;
}
reader__.EndRead();
mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::hwinference::TextGenerationParent*>(this))->RecvDelta(std::move(text));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PTextGeneration::Reply_Generate__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTextGeneration", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTextGenerationParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTextGeneration::Msg_Generate", OTHER);
return mAsyncCallbacks.GotReply(this, msg__);
}
default:
return MsgNotKnown;
case SHMEM_CREATED_MESSAGE_TYPE:
{
if (!ShmemCreated(msg__)) {
return MsgPayloadError;
}
return MsgProcessed;
}
case SHMEM_DESTROYED_MESSAGE_TYPE:
{
if (!ShmemDestroyed(msg__)) {
return MsgPayloadError;
}
return MsgProcessed;
}
}
}
auto PTextGenerationParent::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PTextGenerationParent::Result
{
if (!CanSend()) {
return MsgDropped;
}
MOZ_ASSERT_UNREACHABLE("message protocol not supported");
return MsgNotKnown;
}
} // namespace hwinference
} // namespace mozilla