From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- ipc/glue/TransportSecurityInfoUtils.cpp | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 ipc/glue/TransportSecurityInfoUtils.cpp (limited to 'ipc/glue/TransportSecurityInfoUtils.cpp') diff --git a/ipc/glue/TransportSecurityInfoUtils.cpp b/ipc/glue/TransportSecurityInfoUtils.cpp new file mode 100644 index 0000000000..9898e2b579 --- /dev/null +++ b/ipc/glue/TransportSecurityInfoUtils.cpp @@ -0,0 +1,78 @@ +/* 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 "TransportSecurityInfoUtils.h" + +#include "ipc/IPCMessageUtils.h" +#include "mozilla/psm/TransportSecurityInfo.h" +#include "nsNSSCertificate.h" + +namespace IPC { + +void ParamTraits::Write( + MessageWriter* aWriter, nsITransportSecurityInfo* aParam) { + bool nonNull = !!aParam; + WriteParam(aWriter, nonNull); + if (!nonNull) { + return; + } + + aParam->SerializeToIPC(aWriter); +} + +bool ParamTraits::Read( + MessageReader* aReader, RefPtr* aResult) { + *aResult = nullptr; + + bool nonNull = false; + if (!ReadParam(aReader, &nonNull)) { + return false; + } + + if (!nonNull) { + return true; + } + + if (!mozilla::psm::TransportSecurityInfo::DeserializeFromIPC(aReader, + aResult)) { + return false; + } + + return true; +} + +void ParamTraits::Write(MessageWriter* aWriter, + nsIX509Cert* aParam) { + bool nonNull = !!aParam; + WriteParam(aWriter, nonNull); + if (!nonNull) { + return; + } + + aParam->SerializeToIPC(aWriter); +} + +bool ParamTraits::Read(MessageReader* aReader, + RefPtr* aResult) { + *aResult = nullptr; + + bool nonNull = false; + if (!ReadParam(aReader, &nonNull)) { + return false; + } + + if (!nonNull) { + return true; + } + + RefPtr cert = new nsNSSCertificate(); + if (!cert->DeserializeFromIPC(aReader)) { + return false; + } + + *aResult = std::move(cert); + return true; +} + +} // namespace IPC -- cgit v1.2.3