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 "mozilla/ipc/IPDLParamTraits.h"
12 struct SerializedURI
{
15 bool operator==(const SerializedURI
& rhs
) const {
16 return spec
.Equals(rhs
.spec
);
20 struct ChromePackage
{
22 SerializedURI contentBaseURI
;
23 SerializedURI localeBaseURI
;
24 SerializedURI skinBaseURI
;
27 bool operator==(const ChromePackage
& rhs
) const {
28 return package
.Equals(rhs
.package
) &&
29 contentBaseURI
== rhs
.contentBaseURI
&&
30 localeBaseURI
== rhs
.localeBaseURI
&&
31 skinBaseURI
== rhs
.skinBaseURI
&& flags
== rhs
.flags
;
35 struct SubstitutionMapping
{
38 SerializedURI resolvedURI
;
41 bool operator==(const SubstitutionMapping
& rhs
) const {
42 return scheme
.Equals(rhs
.scheme
) && path
.Equals(rhs
.path
) &&
43 resolvedURI
== rhs
.resolvedURI
&& flags
== rhs
.flags
;
47 struct OverrideMapping
{
48 SerializedURI originalURI
;
49 SerializedURI overrideURI
;
51 bool operator==(const OverrideMapping
& rhs
) const {
52 return originalURI
== rhs
.originalURI
&& overrideURI
== rhs
.overrideURI
;
59 struct ParamTraits
<SerializedURI
> {
60 typedef SerializedURI paramType
;
62 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
63 WriteParam(aWriter
, aParam
.spec
);
66 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
68 if (ReadParam(aReader
, &spec
)) {
77 struct ParamTraits
<ChromePackage
> {
78 typedef ChromePackage paramType
;
80 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
81 WriteParam(aWriter
, aParam
.package
);
82 WriteParam(aWriter
, aParam
.contentBaseURI
);
83 WriteParam(aWriter
, aParam
.localeBaseURI
);
84 WriteParam(aWriter
, aParam
.skinBaseURI
);
85 WriteParam(aWriter
, aParam
.flags
);
88 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
90 SerializedURI contentBaseURI
, localeBaseURI
, skinBaseURI
;
93 if (ReadParam(aReader
, &package
) && ReadParam(aReader
, &contentBaseURI
) &&
94 ReadParam(aReader
, &localeBaseURI
) &&
95 ReadParam(aReader
, &skinBaseURI
) && ReadParam(aReader
, &flags
)) {
96 aResult
->package
= package
;
97 aResult
->contentBaseURI
= contentBaseURI
;
98 aResult
->localeBaseURI
= localeBaseURI
;
99 aResult
->skinBaseURI
= skinBaseURI
;
100 aResult
->flags
= flags
;
108 struct ParamTraits
<SubstitutionMapping
> {
109 typedef SubstitutionMapping paramType
;
111 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
112 WriteParam(aWriter
, aParam
.scheme
);
113 WriteParam(aWriter
, aParam
.path
);
114 WriteParam(aWriter
, aParam
.resolvedURI
);
115 WriteParam(aWriter
, aParam
.flags
);
118 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
119 nsCString scheme
, path
;
120 SerializedURI resolvedURI
;
123 if (ReadParam(aReader
, &scheme
) && ReadParam(aReader
, &path
) &&
124 ReadParam(aReader
, &resolvedURI
) && ReadParam(aReader
, &flags
)) {
125 aResult
->scheme
= scheme
;
126 aResult
->path
= path
;
127 aResult
->resolvedURI
= resolvedURI
;
128 aResult
->flags
= flags
;
136 struct ParamTraits
<OverrideMapping
> {
137 typedef OverrideMapping paramType
;
139 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
140 WriteParam(aWriter
, aParam
.originalURI
);
141 WriteParam(aWriter
, aParam
.overrideURI
);
144 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
145 SerializedURI originalURI
;
146 SerializedURI overrideURI
;
148 if (ReadParam(aReader
, &originalURI
) && ReadParam(aReader
, &overrideURI
)) {
149 aResult
->originalURI
= originalURI
;
150 aResult
->overrideURI
= overrideURI
;
159 #endif // RegistryMessageUtils_h