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;
|
|
|
|
nsCString charset;
|
2014-07-26 00:17:36 +04:00
|
|
|
|
|
|
|
bool operator ==(const SerializedURI& rhs) const
|
|
|
|
{
|
|
|
|
return spec.Equals(rhs.spec) &&
|
|
|
|
charset.Equals(rhs.charset);
|
|
|
|
}
|
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
|
2010-03-11 08:33:00 +03:00
|
|
|
{
|
2015-07-17 01:50:07 +03:00
|
|
|
nsCString scheme;
|
|
|
|
nsCString path;
|
2010-03-11 08:33:00 +03:00
|
|
|
SerializedURI resolvedURI;
|
2014-10-07 21:29:40 +04:00
|
|
|
|
2015-07-17 01:50:07 +03:00
|
|
|
bool operator ==(const SubstitutionMapping& rhs) const
|
2014-10-07 21:29:40 +04:00
|
|
|
{
|
2015-07-17 01:50:07 +03:00
|
|
|
return scheme.Equals(rhs.scheme) &&
|
|
|
|
path.Equals(rhs.path) &&
|
2014-10-07 21:29:40 +04:00
|
|
|
resolvedURI == rhs.resolvedURI;
|
|
|
|
}
|
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);
|
|
|
|
WriteParam(aMsg, aParam.charset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
|
|
|
{
|
|
|
|
nsCString spec, charset;
|
|
|
|
if (ReadParam(aMsg, aIter, &spec) &&
|
|
|
|
ReadParam(aMsg, aIter, &charset)) {
|
|
|
|
aResult->spec = spec;
|
|
|
|
aResult->charset = charset;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<ChromePackage>
|
|
|
|
{
|
|
|
|
typedef ChromePackage paramType;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
|
|
|
{
|
|
|
|
nsCString package;
|
|
|
|
SerializedURI contentBaseURI, localeBaseURI, skinBaseURI;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t flags;
|
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>
|
2010-03-11 08:33:00 +03:00
|
|
|
{
|
2015-07-17 01:50:07 +03:00
|
|
|
typedef SubstitutionMapping paramType;
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
|
|
|
{
|
2015-07-17 01:50:07 +03:00
|
|
|
nsCString scheme, path;
|
2010-03-11 08:33:00 +03:00
|
|
|
SerializedURI resolvedURI;
|
|
|
|
|
2015-07-17 01:50:07 +03:00
|
|
|
if (ReadParam(aMsg, aIter, &scheme) &&
|
|
|
|
ReadParam(aMsg, aIter, &path) &&
|
2010-03-11 08:33:00 +03:00
|
|
|
ReadParam(aMsg, aIter, &resolvedURI)) {
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam)
|
|
|
|
{
|
|
|
|
WriteParam(aMsg, aParam.originalURI);
|
|
|
|
WriteParam(aMsg, aParam.overrideURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
|
|
|
{
|
|
|
|
SerializedURI originalURI;
|
|
|
|
SerializedURI overrideURI;
|
|
|
|
|
|
|
|
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
|