Bug 1743256 [wpt PR 31764] - Implement contain-intrinsic-size: auto, a=testonly
[gecko.git] / ipc / glue / TransportSecurityInfoUtils.cpp
blob0fa88dc5c86e71d168fd3504258b9455dbc0e61b
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 Message* aMsg, nsITransportSecurityInfo* aParam) {
14 bool nonNull = !!aParam;
15 WriteParam(aMsg, nonNull);
16 if (!nonNull) {
17 return;
20 aParam->SerializeToIPC(aMsg);
23 bool ParamTraits<nsITransportSecurityInfo*>::Read(
24 const Message* aMsg, PickleIterator* aIter,
25 RefPtr<nsITransportSecurityInfo>* aResult) {
26 *aResult = nullptr;
28 bool nonNull = false;
29 if (!ReadParam(aMsg, aIter, &nonNull)) {
30 return false;
33 if (!nonNull) {
34 return true;
37 RefPtr<nsITransportSecurityInfo> info =
38 new mozilla::psm::TransportSecurityInfo();
39 if (!info->DeserializeFromIPC(aMsg, aIter)) {
40 return false;
43 *aResult = std::move(info);
44 return true;
47 void ParamTraits<nsIX509Cert*>::Write(Message* aMsg, nsIX509Cert* aParam) {
48 bool nonNull = !!aParam;
49 WriteParam(aMsg, nonNull);
50 if (!nonNull) {
51 return;
54 aParam->SerializeToIPC(aMsg);
57 bool ParamTraits<nsIX509Cert*>::Read(const Message* aMsg, PickleIterator* aIter,
58 RefPtr<nsIX509Cert>* aResult) {
59 *aResult = nullptr;
61 bool nonNull = false;
62 if (!ReadParam(aMsg, aIter, &nonNull)) {
63 return false;
66 if (!nonNull) {
67 return true;
70 RefPtr<nsIX509Cert> cert = new nsNSSCertificate();
71 if (!cert->DeserializeFromIPC(aMsg, aIter)) {
72 return false;
75 *aResult = std::move(cert);
76 return true;
79 } // namespace IPC