2010-03-11 08:33:00 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 08:33:00 +03:00
|
|
|
|
|
|
|
#ifndef mozilla_RegistryMessageUtils_h
|
|
|
|
#define mozilla_RegistryMessageUtils_h
|
|
|
|
|
2012-08-28 16:41:04 +04:00
|
|
|
#include "ipc/IPCMessageUtils.h"
|
2013-09-23 21:25:00 +04:00
|
|
|
#include "nsString.h"
|
2010-03-11 08:33:00 +03:00
|
|
|
|
|
|
|
struct SerializedURI {
|
|
|
|
nsCString spec;
|
2014-07-26 00:17:36 +04:00
|
|
|
|
|
|
|
bool operator==(const SerializedURI& rhs) const {
|
2017-08-02 14:43:30 +03:00
|
|
|
return spec.Equals(rhs.spec);
|
2014-07-26 00:17:36 +04:00
|
|
|
}
|
2010-03-11 08:33:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ChromePackage {
|
|
|
|
nsCString package;
|
|
|
|
SerializedURI contentBaseURI;
|
|
|
|
SerializedURI localeBaseURI;
|
|
|
|
SerializedURI skinBaseURI;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t flags;
|
2014-07-26 00:17:36 +04: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 08:33:00 +03:00
|
|
|
};
|
|
|
|
|
2015-07-17 01:50:07 +03:00
|
|
|
struct SubstitutionMapping {
|
|
|
|
nsCString scheme;
|
|
|
|
nsCString path;
|
2010-03-11 08:33:00 +03:00
|
|
|
SerializedURI resolvedURI;
|
2017-06-08 12:44:09 +03:00
|
|
|
uint32_t flags;
|
2014-10-07 21:29:40 +04:00
|
|
|
|
2015-07-17 01:50:07 +03:00
|
|
|
bool operator==(const SubstitutionMapping& rhs) const {
|
|
|
|
return scheme.Equals(rhs.scheme) && path.Equals(rhs.path) &&
|
2017-06-08 12:44:09 +03:00
|
|
|
resolvedURI == rhs.resolvedURI && flags == rhs.flags;
|
2014-10-07 21:29:40 +04:00
|
|
|
}
|
2010-03-11 08:33:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OverrideMapping {
|
|
|
|
SerializedURI originalURI;
|
|
|
|
SerializedURI overrideURI;
|
2014-07-26 00:17:36 +04:00
|
|
|
|
|
|
|
bool operator==(const OverrideMapping& rhs) const {
|
|
|
|
return originalURI == rhs.originalURI && overrideURI == rhs.overrideURI;
|
|
|
|
}
|
2010-03-11 08:33:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<SerializedURI> {
|
|
|
|
typedef SerializedURI paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.spec);
|
|
|
|
}
|
|
|
|
|
2016-04-21 07:09:15 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
2017-08-02 14:43:30 +03:00
|
|
|
nsCString spec;
|
|
|
|
if (ReadParam(aMsg, aIter, &spec)) {
|
2010-03-11 08:33:00 +03:00
|
|
|
aResult->spec = spec;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<ChromePackage> {
|
|
|
|
typedef ChromePackage paramType;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.package);
|
|
|
|
WriteParam(aMsg, aParam.contentBaseURI);
|
|
|
|
WriteParam(aMsg, aParam.localeBaseURI);
|
|
|
|
WriteParam(aMsg, aParam.skinBaseURI);
|
|
|
|
WriteParam(aMsg, aParam.flags);
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2016-04-21 07:09:15 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
2010-03-11 08:33:00 +03:00
|
|
|
nsCString package;
|
|
|
|
SerializedURI contentBaseURI, localeBaseURI, skinBaseURI;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t flags;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
if (ReadParam(aMsg, aIter, &package) &&
|
|
|
|
ReadParam(aMsg, aIter, &contentBaseURI) &&
|
|
|
|
ReadParam(aMsg, aIter, &localeBaseURI) &&
|
|
|
|
ReadParam(aMsg, aIter, &skinBaseURI) &&
|
|
|
|
ReadParam(aMsg, aIter, &flags)) {
|
|
|
|
aResult->package = package;
|
|
|
|
aResult->contentBaseURI = contentBaseURI;
|
|
|
|
aResult->localeBaseURI = localeBaseURI;
|
|
|
|
aResult->skinBaseURI = skinBaseURI;
|
|
|
|
aResult->flags = flags;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Log(const paramType& aParam, std::wstring* aLog) {
|
|
|
|
aLog->append(StringPrintf(L"[%s, %s, %s, %s, %u]", aParam.package.get(),
|
|
|
|
aParam.contentBaseURI.spec.get(),
|
|
|
|
aParam.localeBaseURI.spec.get(),
|
|
|
|
aParam.skinBaseURI.spec.get(), aParam.flags));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2015-07-17 01:50:07 +03:00
|
|
|
struct ParamTraits<SubstitutionMapping> {
|
|
|
|
typedef SubstitutionMapping paramType;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
2015-07-17 01:50:07 +03:00
|
|
|
WriteParam(aMsg, aParam.scheme);
|
|
|
|
WriteParam(aMsg, aParam.path);
|
2010-03-11 08:33:00 +03:00
|
|
|
WriteParam(aMsg, aParam.resolvedURI);
|
2017-06-08 12:44:09 +03:00
|
|
|
WriteParam(aMsg, aParam.flags);
|
2010-03-11 08:33:00 +03:00
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2016-04-21 07:09:15 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
2015-07-17 01:50:07 +03:00
|
|
|
nsCString scheme, path;
|
2010-03-11 08:33:00 +03:00
|
|
|
SerializedURI resolvedURI;
|
2017-06-08 12:44:09 +03:00
|
|
|
uint32_t flags;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2015-07-17 01:50:07 +03:00
|
|
|
if (ReadParam(aMsg, aIter, &scheme) && ReadParam(aMsg, aIter, &path) &&
|
2017-06-08 12:44:09 +03:00
|
|
|
ReadParam(aMsg, aIter, &resolvedURI) &&
|
|
|
|
ReadParam(aMsg, aIter, &flags)) {
|
2015-07-17 01:50:07 +03:00
|
|
|
aResult->scheme = scheme;
|
|
|
|
aResult->path = path;
|
2010-03-11 08:33:00 +03:00
|
|
|
aResult->resolvedURI = resolvedURI;
|
2017-06-08 12:44:09 +03:00
|
|
|
aResult->flags = flags;
|
2010-03-11 08:33:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Log(const paramType& aParam, std::wstring* aLog) {
|
2015-07-17 01:50:07 +03:00
|
|
|
aLog->append(StringPrintf(L"[%s://%s, %s, %u]", aParam.scheme.get(),
|
|
|
|
aParam.path.get(),
|
2010-03-11 08:33:00 +03:00
|
|
|
aParam.resolvedURI.spec.get()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<OverrideMapping> {
|
|
|
|
typedef OverrideMapping paramType;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.originalURI);
|
|
|
|
WriteParam(aMsg, aParam.overrideURI);
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2016-04-21 07:09:15 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
2010-03-11 08:33:00 +03:00
|
|
|
SerializedURI originalURI;
|
|
|
|
SerializedURI overrideURI;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
if (ReadParam(aMsg, aIter, &originalURI) &&
|
|
|
|
ReadParam(aMsg, aIter, &overrideURI)) {
|
|
|
|
aResult->originalURI = originalURI;
|
|
|
|
aResult->overrideURI = overrideURI;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Log(const paramType& aParam, std::wstring* aLog) {
|
|
|
|
aLog->append(StringPrintf(L"[%s, %s, %u]", aParam.originalURI.spec.get(),
|
|
|
|
aParam.overrideURI.spec.get()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace IPC
|
2010-03-11 08:33:00 +03:00
|
|
|
|
|
|
|
#endif // RegistryMessageUtils_h
|