Bug 1858509 add thread-safety annotations around MediaSourceDemuxer::mMonitor r=alwu
[gecko.git] / ipc / glue / TransportSecurityInfoUtils.cpp
blob9898e2b579c94ad74bc401977a1487626b444db5
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"
9 #include "nsNSSCertificate.h"
11 namespace IPC {
13 void ParamTraits<nsITransportSecurityInfo*>::Write(
14 MessageWriter* aWriter, nsITransportSecurityInfo* aParam) {
15 bool nonNull = !!aParam;
16 WriteParam(aWriter, nonNull);
17 if (!nonNull) {
18 return;
21 aParam->SerializeToIPC(aWriter);
24 bool ParamTraits<nsITransportSecurityInfo*>::Read(
25 MessageReader* aReader, RefPtr<nsITransportSecurityInfo>* aResult) {
26 *aResult = nullptr;
28 bool nonNull = false;
29 if (!ReadParam(aReader, &nonNull)) {
30 return false;
33 if (!nonNull) {
34 return true;
37 if (!mozilla::psm::TransportSecurityInfo::DeserializeFromIPC(aReader,
38 aResult)) {
39 return false;
42 return true;
45 void ParamTraits<nsIX509Cert*>::Write(MessageWriter* aWriter,
46 nsIX509Cert* aParam) {
47 bool nonNull = !!aParam;
48 WriteParam(aWriter, nonNull);
49 if (!nonNull) {
50 return;
53 aParam->SerializeToIPC(aWriter);
56 bool ParamTraits<nsIX509Cert*>::Read(MessageReader* aReader,
57 RefPtr<nsIX509Cert>* aResult) {
58 *aResult = nullptr;
60 bool nonNull = false;
61 if (!ReadParam(aReader, &nonNull)) {
62 return false;
65 if (!nonNull) {
66 return true;
69 RefPtr<nsIX509Cert> cert = new nsNSSCertificate();
70 if (!cert->DeserializeFromIPC(aReader)) {
71 return false;
74 *aResult = std::move(cert);
75 return true;
78 } // namespace IPC