1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_RegistryMessageUtils_h
7 #define mozilla_RegistryMessageUtils_h
9 #include "ipc/IPCMessageUtils.h"
16 bool operator ==(const SerializedURI
& rhs
) const
18 return spec
.Equals(rhs
.spec
);
25 SerializedURI contentBaseURI
;
26 SerializedURI localeBaseURI
;
27 SerializedURI skinBaseURI
;
30 bool operator ==(const ChromePackage
& rhs
) const
32 return package
.Equals(rhs
.package
) &&
33 contentBaseURI
== rhs
.contentBaseURI
&&
34 localeBaseURI
== rhs
.localeBaseURI
&&
35 skinBaseURI
== rhs
.skinBaseURI
&&
40 struct SubstitutionMapping
44 SerializedURI resolvedURI
;
47 bool operator ==(const SubstitutionMapping
& rhs
) const
49 return scheme
.Equals(rhs
.scheme
) &&
50 path
.Equals(rhs
.path
) &&
51 resolvedURI
== rhs
.resolvedURI
&&
56 struct OverrideMapping
58 SerializedURI originalURI
;
59 SerializedURI overrideURI
;
61 bool operator==(const OverrideMapping
& rhs
) const
63 return originalURI
== rhs
.originalURI
&&
64 overrideURI
== rhs
.overrideURI
;
71 struct ParamTraits
<SerializedURI
>
73 typedef SerializedURI paramType
;
75 static void Write(Message
* aMsg
, const paramType
& aParam
)
77 WriteParam(aMsg
, aParam
.spec
);
80 static bool Read(const Message
* aMsg
, PickleIterator
* aIter
, paramType
* aResult
)
83 if (ReadParam(aMsg
, aIter
, &spec
)) {
92 struct ParamTraits
<ChromePackage
>
94 typedef ChromePackage paramType
;
96 static void Write(Message
* aMsg
, const paramType
& aParam
)
98 WriteParam(aMsg
, aParam
.package
);
99 WriteParam(aMsg
, aParam
.contentBaseURI
);
100 WriteParam(aMsg
, aParam
.localeBaseURI
);
101 WriteParam(aMsg
, aParam
.skinBaseURI
);
102 WriteParam(aMsg
, aParam
.flags
);
105 static bool Read(const Message
* aMsg
, PickleIterator
* aIter
, paramType
* aResult
)
108 SerializedURI contentBaseURI
, localeBaseURI
, skinBaseURI
;
111 if (ReadParam(aMsg
, aIter
, &package
) &&
112 ReadParam(aMsg
, aIter
, &contentBaseURI
) &&
113 ReadParam(aMsg
, aIter
, &localeBaseURI
) &&
114 ReadParam(aMsg
, aIter
, &skinBaseURI
) &&
115 ReadParam(aMsg
, aIter
, &flags
)) {
116 aResult
->package
= package
;
117 aResult
->contentBaseURI
= contentBaseURI
;
118 aResult
->localeBaseURI
= localeBaseURI
;
119 aResult
->skinBaseURI
= skinBaseURI
;
120 aResult
->flags
= flags
;
126 static void Log(const paramType
& aParam
, std::wstring
* aLog
)
128 aLog
->append(StringPrintf(L
"[%s, %s, %s, %s, %u]", aParam
.package
.get(),
129 aParam
.contentBaseURI
.spec
.get(),
130 aParam
.localeBaseURI
.spec
.get(),
131 aParam
.skinBaseURI
.spec
.get(), aParam
.flags
));
136 struct ParamTraits
<SubstitutionMapping
>
138 typedef SubstitutionMapping paramType
;
140 static void Write(Message
* aMsg
, const paramType
& aParam
)
142 WriteParam(aMsg
, aParam
.scheme
);
143 WriteParam(aMsg
, aParam
.path
);
144 WriteParam(aMsg
, aParam
.resolvedURI
);
145 WriteParam(aMsg
, aParam
.flags
);
148 static bool Read(const Message
* aMsg
, PickleIterator
* aIter
, paramType
* aResult
)
150 nsCString scheme
, path
;
151 SerializedURI resolvedURI
;
154 if (ReadParam(aMsg
, aIter
, &scheme
) &&
155 ReadParam(aMsg
, aIter
, &path
) &&
156 ReadParam(aMsg
, aIter
, &resolvedURI
) &&
157 ReadParam(aMsg
, aIter
, &flags
)) {
158 aResult
->scheme
= scheme
;
159 aResult
->path
= path
;
160 aResult
->resolvedURI
= resolvedURI
;
161 aResult
->flags
= flags
;
167 static void Log(const paramType
& aParam
, std::wstring
* aLog
)
169 aLog
->append(StringPrintf(L
"[%s://%s, %s, %u]",
172 aParam
.resolvedURI
.spec
.get()));
177 struct ParamTraits
<OverrideMapping
>
179 typedef OverrideMapping paramType
;
181 static void Write(Message
* aMsg
, const paramType
& aParam
)
183 WriteParam(aMsg
, aParam
.originalURI
);
184 WriteParam(aMsg
, aParam
.overrideURI
);
187 static bool Read(const Message
* aMsg
, PickleIterator
* aIter
, paramType
* aResult
)
189 SerializedURI originalURI
;
190 SerializedURI overrideURI
;
192 if (ReadParam(aMsg
, aIter
, &originalURI
) &&
193 ReadParam(aMsg
, aIter
, &overrideURI
)) {
194 aResult
->originalURI
= originalURI
;
195 aResult
->overrideURI
= overrideURI
;
201 static void Log(const paramType
& aParam
, std::wstring
* aLog
)
203 aLog
->append(StringPrintf(L
"[%s, %s, %u]", aParam
.originalURI
.spec
.get(),
204 aParam
.overrideURI
.spec
.get()));
210 #endif // RegistryMessageUtils_h