Bug 1758813 [wpt PR 33142] - Implement RP sign out, a=testonly
[gecko.git] / ipc / glue / TransportSecurityInfoUtils.cpp
blobfbca28594a9f79deb5ab30c334fd239fc91d15b0
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "TransportSecurityInfoUtils.h"
7 #include "ipc/IPCMessageUtils.h"
8 #include "mozilla/psm/TransportSecurityInfo.h"
10 namespace IPC {
12 void ParamTraits<nsITransportSecurityInfo*>::Write(
13 MessageWriter* aWriter, nsITransportSecurityInfo* aParam) {
14 bool nonNull = !!aParam;
15 WriteParam(aWriter, nonNull);
16 if (!nonNull) {
17 return;
20 aParam->SerializeToIPC(aWriter);
23 bool ParamTraits<nsITransportSecurityInfo*>::Read(
24 MessageReader* aReader, RefPtr<nsITransportSecurityInfo>* aResult) {
25 *aResult = nullptr;
27 bool nonNull = false;
28 if (!ReadParam(aReader, &nonNull)) {
29 return false;
32 if (!nonNull) {
33 return true;
36 RefPtr<nsITransportSecurityInfo> info =
37 new mozilla::psm::TransportSecurityInfo();
38 if (!info->DeserializeFromIPC(aReader)) {
39 return false;
42 *aResult = std::move(info);
43 return true;
46 void ParamTraits<nsIX509Cert*>::Write(MessageWriter* aWriter,
47 nsIX509Cert* aParam) {
48 bool nonNull = !!aParam;
49 WriteParam(aWriter, nonNull);
50 if (!nonNull) {
51 return;
54 aParam->SerializeToIPC(aWriter);
57 bool ParamTraits<nsIX509Cert*>::Read(MessageReader* aReader,
58 RefPtr<nsIX509Cert>* aResult) {
59 *aResult = nullptr;
61 bool nonNull = false;
62 if (!ReadParam(aReader, &nonNull)) {
63 return false;
66 if (!nonNull) {
67 return true;
70 RefPtr<nsIX509Cert> cert = new nsNSSCertificate();
71 if (!cert->DeserializeFromIPC(aReader)) {
72 return false;
75 *aResult = std::move(cert);
76 return true;
79 } // namespace IPC