2010-03-11 05:33:00 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-11 05:33:00 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_RegistryMessageUtils_h
|
|
|
|
#define mozilla_RegistryMessageUtils_h
|
|
|
|
|
2023-03-02 07:44:28 +00:00
|
|
|
#include "mozilla/ipc/IPDLParamTraits.h"
|
2013-09-23 17:25:00 +00:00
|
|
|
#include "nsString.h"
|
2010-03-11 05:33:00 +00:00
|
|
|
|
|
|
|
struct SerializedURI {
|
|
|
|
nsCString spec;
|
2014-07-25 20:17:36 +00:00
|
|
|
|
|
|
|
bool operator==(const SerializedURI& rhs) const {
|
2017-08-02 11:43:30 +00:00
|
|
|
return spec.Equals(rhs.spec);
|
2014-07-25 20:17:36 +00:00
|
|
|
}
|
2010-03-11 05:33:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ChromePackage {
|
|
|
|
nsCString package;
|
|
|
|
SerializedURI contentBaseURI;
|
|
|
|
SerializedURI localeBaseURI;
|
|
|
|
SerializedURI skinBaseURI;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags;
|
2014-07-25 20:17:36 +00:00
|
|
|
|
|
|
|
bool operator==(const ChromePackage& rhs) const {
|
|
|
|
return package.Equals(rhs.package) &&
|
|
|
|
contentBaseURI == rhs.contentBaseURI &&
|
|
|
|
localeBaseURI == rhs.localeBaseURI &&
|
|
|
|
skinBaseURI == rhs.skinBaseURI && flags == rhs.flags;
|
|
|
|
}
|
2010-03-11 05:33:00 +00:00
|
|
|
};
|
|
|
|
|
2015-07-16 22:50:07 +00:00
|
|
|
struct SubstitutionMapping {
|
|
|
|
nsCString scheme;
|
|
|
|
nsCString path;
|
2010-03-11 05:33:00 +00:00
|
|
|
SerializedURI resolvedURI;
|
2017-06-08 09:44:09 +00:00
|
|
|
uint32_t flags;
|
2014-10-07 17:29:40 +00:00
|
|
|
|
2015-07-16 22:50:07 +00:00
|
|
|
bool operator==(const SubstitutionMapping& rhs) const {
|
|
|
|
return scheme.Equals(rhs.scheme) && path.Equals(rhs.path) &&
|
2017-06-08 09:44:09 +00:00
|
|
|
resolvedURI == rhs.resolvedURI && flags == rhs.flags;
|
2014-10-07 17:29:40 +00:00
|
|
|
}
|
2010-03-11 05:33:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OverrideMapping {
|
|
|
|
SerializedURI originalURI;
|
|
|
|
SerializedURI overrideURI;
|
2014-07-25 20:17:36 +00:00
|
|
|
|
|
|
|
bool operator==(const OverrideMapping& rhs) const {
|
|
|
|
return originalURI == rhs.originalURI && overrideURI == rhs.overrideURI;
|
|
|
|
}
|
2010-03-11 05:33:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<SerializedURI> {
|
|
|
|
typedef SerializedURI paramType;
|
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.spec);
|
2010-03-11 05:33:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2017-08-02 11:43:30 +00:00
|
|
|
nsCString spec;
|
2022-03-04 15:39:41 +00:00
|
|
|
if (ReadParam(aReader, &spec)) {
|
2010-03-11 05:33:00 +00:00
|
|
|
aResult->spec = spec;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<ChromePackage> {
|
|
|
|
typedef ChromePackage paramType;
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.package);
|
|
|
|
WriteParam(aWriter, aParam.contentBaseURI);
|
|
|
|
WriteParam(aWriter, aParam.localeBaseURI);
|
|
|
|
WriteParam(aWriter, aParam.skinBaseURI);
|
|
|
|
WriteParam(aWriter, aParam.flags);
|
2010-03-11 05:33:00 +00:00
|
|
|
}
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2010-03-11 05:33:00 +00:00
|
|
|
nsCString package;
|
|
|
|
SerializedURI contentBaseURI, localeBaseURI, skinBaseURI;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags;
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
if (ReadParam(aReader, &package) && ReadParam(aReader, &contentBaseURI) &&
|
|
|
|
ReadParam(aReader, &localeBaseURI) &&
|
|
|
|
ReadParam(aReader, &skinBaseURI) && ReadParam(aReader, &flags)) {
|
2010-03-11 05:33:00 +00:00
|
|
|
aResult->package = package;
|
|
|
|
aResult->contentBaseURI = contentBaseURI;
|
|
|
|
aResult->localeBaseURI = localeBaseURI;
|
|
|
|
aResult->skinBaseURI = skinBaseURI;
|
|
|
|
aResult->flags = flags;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2015-07-16 22:50:07 +00:00
|
|
|
struct ParamTraits<SubstitutionMapping> {
|
|
|
|
typedef SubstitutionMapping paramType;
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.scheme);
|
|
|
|
WriteParam(aWriter, aParam.path);
|
|
|
|
WriteParam(aWriter, aParam.resolvedURI);
|
|
|
|
WriteParam(aWriter, aParam.flags);
|
2010-03-11 05:33:00 +00:00
|
|
|
}
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2015-07-16 22:50:07 +00:00
|
|
|
nsCString scheme, path;
|
2010-03-11 05:33:00 +00:00
|
|
|
SerializedURI resolvedURI;
|
2017-06-08 09:44:09 +00:00
|
|
|
uint32_t flags;
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
if (ReadParam(aReader, &scheme) && ReadParam(aReader, &path) &&
|
|
|
|
ReadParam(aReader, &resolvedURI) && ReadParam(aReader, &flags)) {
|
2015-07-16 22:50:07 +00:00
|
|
|
aResult->scheme = scheme;
|
|
|
|
aResult->path = path;
|
2010-03-11 05:33:00 +00:00
|
|
|
aResult->resolvedURI = resolvedURI;
|
2017-06-08 09:44:09 +00:00
|
|
|
aResult->flags = flags;
|
2010-03-11 05:33:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<OverrideMapping> {
|
|
|
|
typedef OverrideMapping paramType;
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.originalURI);
|
|
|
|
WriteParam(aWriter, aParam.overrideURI);
|
2010-03-11 05:33:00 +00:00
|
|
|
}
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2010-03-11 05:33:00 +00:00
|
|
|
SerializedURI originalURI;
|
|
|
|
SerializedURI overrideURI;
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2022-03-04 15:39:41 +00:00
|
|
|
if (ReadParam(aReader, &originalURI) && ReadParam(aReader, &overrideURI)) {
|
2010-03-11 05:33:00 +00:00
|
|
|
aResult->originalURI = originalURI;
|
|
|
|
aResult->overrideURI = overrideURI;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace IPC
|
2010-03-11 05:33:00 +00:00
|
|
|
|
|
|
|
#endif // RegistryMessageUtils_h
|