2019-09-30 16:25:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/MaybeNewPSHEntry.h"
|
|
|
|
#include "mozilla/dom/PContentParent.h"
|
|
|
|
#include "mozilla/dom/SHEntryChild.h"
|
|
|
|
#include "mozilla/dom/SHEntryParent.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct IPDLParamTraits<dom::NewPSHEntry> {
|
|
|
|
static void Write(IPC::Message* aMsg, IProtocol* aActor,
|
|
|
|
dom::NewPSHEntry&& aEntry) {
|
|
|
|
MOZ_RELEASE_ASSERT(aActor->GetSide() == ParentSide, "wrong side!");
|
|
|
|
|
|
|
|
WriteIPDLParam(aMsg, aActor, std::move(aEntry.mEndpoint));
|
2019-10-24 10:17:19 +03:00
|
|
|
WriteIPDLParam(aMsg, aActor, aEntry.mSHistoryParent);
|
2019-09-30 16:25:53 +03:00
|
|
|
WriteIPDLParam(aMsg, aActor, aEntry.mSharedID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
|
|
|
|
IProtocol* aActor, dom::NewPSHEntry* aEntry) {
|
|
|
|
MOZ_RELEASE_ASSERT(aActor->GetSide() == ChildSide, "wrong side!");
|
|
|
|
|
|
|
|
return ReadIPDLParam(aMsg, aIter, aActor, &aEntry->mEndpoint) &&
|
2019-10-24 10:17:19 +03:00
|
|
|
ReadIPDLParam(aMsg, aIter, aActor, &aEntry->mSHistoryChild) &&
|
2019-09-30 16:25:53 +03:00
|
|
|
ReadIPDLParam(aMsg, aIter, aActor, &aEntry->mSharedID);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
void IPDLParamTraits<dom::CrossProcessSHEntry*>::Write(
|
|
|
|
IPC::Message* aMsg, IProtocol* aActor, dom::CrossProcessSHEntry* aEntry) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(aActor->ToplevelProtocol()->GetProtocolId() ==
|
|
|
|
PContentMsgStart);
|
2019-12-02 19:29:22 +03:00
|
|
|
if (aActor->GetSide() == ChildSide) {
|
|
|
|
WriteIPDLParam(aMsg, aActor,
|
|
|
|
static_cast<dom::PSHEntryChild*>(
|
|
|
|
static_cast<dom::SHEntryChild*>(aEntry)));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2019-09-30 16:25:53 +03:00
|
|
|
|
|
|
|
dom::MaybeNewPSHEntryParent entry(static_cast<dom::PSHEntryParent*>(nullptr));
|
|
|
|
if (aEntry) {
|
|
|
|
entry = static_cast<dom::LegacySHEntry*>(aEntry)->GetOrCreateActor(
|
|
|
|
static_cast<dom::PContentParent*>(aActor->ToplevelProtocol()));
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteIPDLParam(aMsg, aActor, std::move(entry));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
bool IPDLParamTraits<dom::CrossProcessSHEntry*>::Read(
|
|
|
|
const IPC::Message* aMsg, PickleIterator* aIter,
|
|
|
|
mozilla::ipc::IProtocol* aActor, RefPtr<dom::CrossProcessSHEntry>* aEntry) {
|
2019-12-02 19:29:22 +03:00
|
|
|
if (aActor->GetSide() == ParentSide) {
|
|
|
|
dom::PSHEntryParent* actor;
|
|
|
|
if (!ReadIPDLParam(aMsg, aIter, aActor, &actor)) {
|
|
|
|
aActor->FatalError("Error deserializing MaybeNewPSHEntry");
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-30 16:25:53 +03:00
|
|
|
|
2019-12-02 19:29:22 +03:00
|
|
|
*aEntry =
|
|
|
|
actor ? static_cast<dom::SHEntryParent*>(actor)->GetSHEntry() : nullptr;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2019-09-30 16:25:53 +03:00
|
|
|
dom::MaybeNewPSHEntryChild actor(static_cast<dom::PSHEntryChild*>(nullptr));
|
|
|
|
if (!ReadIPDLParam(aMsg, aIter, aActor, &actor)) {
|
|
|
|
aActor->FatalError("Error deserializing MaybeNewPSHEntry");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return actor.match(
|
|
|
|
[&](dom::PSHEntryChild*& entry) {
|
|
|
|
*aEntry = static_cast<dom::SHEntryChild*>(entry);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
[&](dom::NewPSHEntry& newEntry) {
|
2019-10-24 10:17:19 +03:00
|
|
|
RefPtr<dom::SHEntryChild> entry = new dom::SHEntryChild(
|
|
|
|
static_cast<dom::SHistoryChild*>(newEntry.mSHistoryChild),
|
|
|
|
newEntry.mSharedID);
|
2019-09-30 16:25:53 +03:00
|
|
|
dom::ContentChild::GetSingleton()->BindPSHEntryEndpoint(
|
|
|
|
std::move(newEntry.mEndpoint), do_AddRef(entry).take());
|
|
|
|
*aEntry = entry.forget();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ipc
|
|
|
|
} // namespace mozilla
|