mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1350637 - Part 3: Move mozilla::dom::Optional serialization helper to ipc/glue/IPCMessageUtils.h to make it available to other consumers; r=billm
This commit is contained in:
parent
c186d54bb2
commit
9ea37e48ab
@ -16,42 +16,6 @@ typedef mozilla::dom::Sequence<nsString> WebrtcGlobalLog;
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<typename T>
|
||||
struct ParamTraits<mozilla::dom::Optional<T>>
|
||||
{
|
||||
typedef mozilla::dom::Optional<T> paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
if (aParam.WasPassed()) {
|
||||
WriteParam(aMsg, true);
|
||||
WriteParam(aMsg, aParam.Value());
|
||||
return;
|
||||
}
|
||||
|
||||
WriteParam(aMsg, false);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
bool was_passed = false;
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &was_passed)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aResult->Reset(); //XXX Optional_base seems to reach this point with isSome true.
|
||||
|
||||
if (was_passed) {
|
||||
if (!ReadParam(aMsg, aIter, &(aResult->Construct()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct ParamTraits<mozilla::dom::Sequence<T>>
|
||||
{
|
||||
|
@ -979,6 +979,42 @@ struct ParamTraits<mozilla::Variant<Ts...>>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct ParamTraits<mozilla::dom::Optional<T>>
|
||||
{
|
||||
typedef mozilla::dom::Optional<T> paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
if (aParam.WasPassed()) {
|
||||
WriteParam(aMsg, true);
|
||||
WriteParam(aMsg, aParam.Value());
|
||||
return;
|
||||
}
|
||||
|
||||
WriteParam(aMsg, false);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
bool wasPassed = false;
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &wasPassed)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aResult->Reset();
|
||||
|
||||
if (wasPassed) {
|
||||
if (!ReadParam(aMsg, aIter, &aResult->Construct())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace IPC */
|
||||
|
||||
#endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user