Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/widget/filedialog/PWinFileDialogParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/widget/filedialog/WinFileDialogParent.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 widget {
namespace filedialog {
auto PWinFileDialogParent::ProcessingError(
Result aCode,
const char* aReason) -> void
{
}
auto PWinFileDialogParent::ShouldContinueFromReplyTimeout() -> bool
{
return true;
}
MOZ_IMPLICIT PWinFileDialogParent::PWinFileDialogParent() :
mozilla::ipc::IToplevelProtocol("PWinFileDialogParent", kProtocolId, mozilla::ipc::ParentSide)
{
MOZ_COUNT_CTOR(PWinFileDialogParent);
}
PWinFileDialogParent::~PWinFileDialogParent()
{
MOZ_COUNT_DTOR(PWinFileDialogParent);
}
auto PWinFileDialogParent::ActorAlloc() -> void
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PWinFileDialogParent'");
AddRef();
}
auto PWinFileDialogParent::ActorDealloc() -> void
{
Release();
}
auto PWinFileDialogParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
return {};
}
auto PWinFileDialogParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
switch (aProtocol) {
default:
return nullptr;
}
}
auto PWinFileDialogParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
mAsyncCallbacks.RejectPendingResponses(aReason);
}
auto PWinFileDialogParent::SendShowFileDialog(
const WindowsHandle& parentHwnd,
const FileDialogType& type,
mozilla::Span<Command const> commands,
mozilla::ipc::ResolveCallback<FileResult>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PWinFileDialog::Msg_ShowFileDialog(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), parentHwnd);
// Sentinel = 'parentHwnd'
((&(writer__)))->WriteSentinel(381879324);
IPC::WriteParam((&(writer__)), type);
// Sentinel = 'type'
((&(writer__)))->WriteSentinel(75760067);
IPC::WriteParam((&(writer__)), commands);
// Sentinel = 'commands'
((&(writer__)))->WriteSentinel(249627475);
if (mozilla::ipc::LoggingEnabledFor("PWinFileDialog", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PWinFileDialogParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PWinFileDialog::Msg_ShowFileDialog", OTHER);
int32_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PWinFileDialog::Reply_ShowFileDialog__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__result = IPC::ReadParam<FileResult>(aReader);
if (!maybe__result) {
(aReader)->FatalError("Error deserializing 'FileResult'");
return MsgValueError;
}
auto& result = *maybe__result;
// Sentinel = 'result'
if ((!((aReader)->ReadSentinel(153223840)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'FileResult'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(result));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PWinFileDialogParent::SendShowFileDialog(
const WindowsHandle& parentHwnd,
const FileDialogType& type,
mozilla::Span<Command const> commands) -> RefPtr<ShowFileDialogPromise>
{
RefPtr<MozPromise<FileResult, ResponseRejectReason, true>::Private> promise__ = new MozPromise<FileResult, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendShowFileDialog(std::move(parentHwnd), std::move(type), std::move(commands), [promise__](FileResult&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PWinFileDialogParent::SendShowFolderDialog(
const WindowsHandle& parentHwnd,
mozilla::Span<Command const> commands,
mozilla::ipc::ResolveCallback<FolderResult>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PWinFileDialog::Msg_ShowFolderDialog(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), parentHwnd);
// Sentinel = 'parentHwnd'
((&(writer__)))->WriteSentinel(381879324);
IPC::WriteParam((&(writer__)), commands);
// Sentinel = 'commands'
((&(writer__)))->WriteSentinel(249627475);
if (mozilla::ipc::LoggingEnabledFor("PWinFileDialog", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PWinFileDialogParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PWinFileDialog::Msg_ShowFolderDialog", OTHER);
int32_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PWinFileDialog::Reply_ShowFolderDialog__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__result = IPC::ReadParam<FolderResult>(aReader);
if (!maybe__result) {
(aReader)->FatalError("Error deserializing 'FolderResult'");
return MsgValueError;
}
auto& result = *maybe__result;
// Sentinel = 'result'
if ((!((aReader)->ReadSentinel(153223840)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'FolderResult'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(result));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PWinFileDialogParent::SendShowFolderDialog(
const WindowsHandle& parentHwnd,
mozilla::Span<Command const> commands) -> RefPtr<ShowFolderDialogPromise>
{
RefPtr<MozPromise<FolderResult, ResponseRejectReason, true>::Private> promise__ = new MozPromise<FolderResult, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendShowFolderDialog(std::move(parentHwnd), std::move(commands), [promise__](FolderResult&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PWinFileDialogParent::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
FatalError("unreached");
return;
}
auto PWinFileDialogParent::OnMessageReceived(const Message& msg__) -> PWinFileDialogParent::Result
{
switch (msg__.type()) {
case PWinFileDialog::Reply_ShowFileDialog__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PWinFileDialog", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PWinFileDialogParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PWinFileDialog::Msg_ShowFileDialog", OTHER);
return mAsyncCallbacks.GotReply(this, msg__);
}
case PWinFileDialog::Reply_ShowFolderDialog__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PWinFileDialog", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PWinFileDialogParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PWinFileDialog::Msg_ShowFolderDialog", 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 PWinFileDialogParent::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PWinFileDialogParent::Result
{
MOZ_ASSERT_UNREACHABLE("message protocol not supported");
return MsgNotKnown;
}
} // namespace filedialog
} // namespace widget
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::widget::filedialog::PWinFileDialogParent*>::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::widget::filedialog::PWinFileDialogParent*>::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, "PWinFileDialog", PWinFileDialogMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::widget::filedialog::PWinFileDialogParent*>(actor.ref());
}
return {};
}
} // namespace IPC