Files
palemoon27/netwerk/ipc/NeckoMessageUtils.h
T
roytam1 5c3e1ed7ef import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1255818. Switch from JS_ClearPendingException to AutoJSAPI::ClearException for cases when we have an AutoJSAPI around. r=bholley (e1e0413493)
- Bug 1253591. HTMLAllCollection should be rooted at the document, not the root element, so it can find the root element. r=peterv (c5f2f253a9)
- Bug 1257270 - Use std::nullptr_t instead of nullptr_t in WMFUtils.h. r=cpearce (539e705876)
- Bug 1251881 - use UniquePtr instead of ScopedDeletePtr in mozglue/linker/; r=glandium (2fe329e32c)
- Bug 1219068 - Compute size correctly when a character consists entirely of glue. r=karlt (80f2e23268)
- Bug 1246132 - Improve register allocation speed on large functions, r=sunfish. (6e023c252b)
- Bug 1150354: Make nsPluginDirServiceProvider build with MSVC 2015 CTP 6, r=jmathies (0113760730)
- Bug 1197311 - Remove PR_snprintf calls in dom/ r=froydnj (6268400ef0)
- Bug 1255099 - XHR CTOR doesn't need to use implicitJSContext, r=bz (72f08fbc36)
- Bug 1255597 - Part 1: Remove redundent trailing spaces. r=khuey (7f2240cb05)
- Bug 1255597 - Part 2: Follow spec to modify the content-type check conditions which determine parsing XHR body or not. r=khuey (ba6f7fc536)
- Bug 1255597 - Part 3: Synchronize content-type hint of HttpChannelChild to HttpChannelParent. r=jduell (bb97478b01)
- Bug 1255597 - Part 4: Remove 'expected fail' settings and expect test cases in responsexml-media-type.htm should be passed. r=khuey (772884b4fb)
- Bug 1201170 - During message diversion must be possible to suspend them. r=jduell (abb2361b7f)
- Bug 1201174 - For FTP - in case of divertToParent, it myst be possible to delay delivering of OnDataAv./OnStopR. r=jduell (9299ef81be)
- Bug 1247393 - use arrays of UniquePtr in ChannelEventQueue; r=mcmanus (7621205b53)
- Bug 1254730 - ChannelEventQueue must be thread-safe, r=michal (b8e01204e9)
- Bug 1254859 part 2. Switch the AutoEntryScript in nsXULTemplateBuilder::InitHTMLTemplateRoot to take ownership of error reporting. r=bholley (f183ec692c)
- Bug 1254859 part 1. Switch the AutoEntryScript in nsGlobalWindow::FireOnNewGlobalObject to take ownership of error reporting. r=bholley (b0cd891917)
- Bug 1254860. Switch the AutoEntryScript TestShellCommandParent::RunCallback to taking ownership of error reporting. r=bholley (0c9697e60f)
- Bug 1254857. Switch the AutoEntryScript in xpc::EvalInSandbox to take ownership of error reporting. r=bholley (93b6bfc87c)
- Bug 1254847 part 3. Make AutoEntryScript always take ownership of error reporting. r=bholley (3c2929462f)
- Bug 1256688 - Continue using getPropertyDescriptor for has in Sandbox창. r=peterv (be7e50b715)
- Bug 1254730 - patch 2 - Better comments and a better management of lifetime of ChannelEvents, r=michal (8348911e35)
- Bug 1163198 - Remove instances of #ifdef PR_LOGGING in dom/plugins. r=froydnj (ba13039dfa)
- Bug 1253216 - clean up the atomic ops ifdef nest. r=jorendorff (6ca747d3cf)
- Bug 1257055 - Use jit/arm64/Architecture-arm64.h on non-JIT aarch64. r=lth (4f3949cd19)
- Bug 1253379 - Cache timings not send to HttpChannelChild r=mayhemer (395172278f)
- align SetAllowStaleCacheContent to FF52, possible misspatch (9d29d27011)
2024-03-19 22:11:27 +08:00

204 lines
7.1 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef mozilla_net_NeckoMessageUtils_h
#define mozilla_net_NeckoMessageUtils_h
#include "mozilla/DebugOnly.h"
#include "ipc/IPCMessageUtils.h"
#include "nsStringGlue.h"
#include "prio.h"
#include "mozilla/net/DNS.h"
#include "TimingStruct.h"
namespace IPC {
// nsIPermissionManager utilities
struct Permission
{
nsCString host, type;
uint32_t capability, expireType;
int64_t expireTime;
uint32_t appId;
bool isInBrowserElement;
Permission() { }
Permission(const nsCString& aHost,
const uint32_t aAppId,
const bool aIsInBrowserElement,
const nsCString& aType,
const uint32_t aCapability,
const uint32_t aExpireType,
const int64_t aExpireTime) : host(aHost),
type(aType),
capability(aCapability),
expireType(aExpireType),
expireTime(aExpireTime),
appId(aAppId),
isInBrowserElement(aIsInBrowserElement)
{}
};
template<>
struct ParamTraits<Permission>
{
static void Write(Message* aMsg, const Permission& aParam)
{
WriteParam(aMsg, aParam.host);
WriteParam(aMsg, aParam.type);
WriteParam(aMsg, aParam.capability);
WriteParam(aMsg, aParam.expireType);
WriteParam(aMsg, aParam.expireTime);
WriteParam(aMsg, aParam.appId);
WriteParam(aMsg, aParam.isInBrowserElement);
}
static bool Read(const Message* aMsg, void** aIter, Permission* aResult)
{
return ReadParam(aMsg, aIter, &aResult->host) &&
ReadParam(aMsg, aIter, &aResult->type) &&
ReadParam(aMsg, aIter, &aResult->capability) &&
ReadParam(aMsg, aIter, &aResult->expireType) &&
ReadParam(aMsg, aIter, &aResult->expireTime) &&
ReadParam(aMsg, aIter, &aResult->appId) &&
ReadParam(aMsg, aIter, &aResult->isInBrowserElement);
}
static void Log(const Permission& p, std::wstring* l)
{
l->append(L"(");
LogParam(p.host, l);
l->append(L", ");
LogParam(p.appId, l);
l->append(L", ");
LogParam(p.isInBrowserElement, l);
l->append(L", ");
LogParam(p.capability, l);
l->append(L", ");
LogParam(p.expireTime, l);
l->append(L", ");
LogParam(p.expireType, l);
l->append(L")");
}
};
template<>
struct ParamTraits<mozilla::net::NetAddr>
{
static void Write(Message* aMsg, const mozilla::net::NetAddr &aParam)
{
WriteParam(aMsg, aParam.raw.family);
if (aParam.raw.family == AF_UNSPEC) {
aMsg->WriteBytes(aParam.raw.data, sizeof(aParam.raw.data));
} else if (aParam.raw.family == AF_INET) {
WriteParam(aMsg, aParam.inet.port);
WriteParam(aMsg, aParam.inet.ip);
} else if (aParam.raw.family == AF_INET6) {
WriteParam(aMsg, aParam.inet6.port);
WriteParam(aMsg, aParam.inet6.flowinfo);
WriteParam(aMsg, aParam.inet6.ip.u64[0]);
WriteParam(aMsg, aParam.inet6.ip.u64[1]);
WriteParam(aMsg, aParam.inet6.scope_id);
#if defined(XP_UNIX)
} else if (aParam.raw.family == AF_LOCAL) {
// Train's already off the rails: let's get a stack trace at least...
NS_RUNTIMEABORT("Error: please post stack trace to "
"https://bugzilla.mozilla.org/show_bug.cgi?id=661158");
aMsg->WriteBytes(aParam.local.path, sizeof(aParam.local.path));
#endif
}
/* If we get here without hitting any of the cases above, there's not much
* we can do but let the deserializer fail when it gets this message */
}
static bool Read(const Message* aMsg, void** aIter, mozilla::net::NetAddr* aResult)
{
if (!ReadParam(aMsg, aIter, &aResult->raw.family))
return false;
if (aResult->raw.family == AF_UNSPEC) {
const char *tmp;
if (aMsg->ReadBytes(aIter, &tmp, sizeof(aResult->raw.data))) {
memcpy(&(aResult->raw.data), tmp, sizeof(aResult->raw.data));
return true;
}
return false;
} else if (aResult->raw.family == AF_INET) {
return ReadParam(aMsg, aIter, &aResult->inet.port) &&
ReadParam(aMsg, aIter, &aResult->inet.ip);
} else if (aResult->raw.family == AF_INET6) {
return ReadParam(aMsg, aIter, &aResult->inet6.port) &&
ReadParam(aMsg, aIter, &aResult->inet6.flowinfo) &&
ReadParam(aMsg, aIter, &aResult->inet6.ip.u64[0]) &&
ReadParam(aMsg, aIter, &aResult->inet6.ip.u64[1]) &&
ReadParam(aMsg, aIter, &aResult->inet6.scope_id);
#if defined(XP_UNIX)
} else if (aResult->raw.family == AF_LOCAL) {
const char *tmp;
if (aMsg->ReadBytes(aIter, &tmp, sizeof(aResult->local.path))) {
memcpy(&(aResult->local.path), tmp, sizeof(aResult->local.path));
return true;
}
return false;
#endif
}
/* We've been tricked by some socket family we don't know about! */
return false;
}
};
template<>
struct ParamTraits<mozilla::net::ResourceTimingStruct>
{
static void Write(Message* aMsg, const mozilla::net::ResourceTimingStruct& aParam)
{
WriteParam(aMsg, aParam.domainLookupStart);
WriteParam(aMsg, aParam.domainLookupEnd);
WriteParam(aMsg, aParam.connectStart);
WriteParam(aMsg, aParam.connectEnd);
WriteParam(aMsg, aParam.requestStart);
WriteParam(aMsg, aParam.responseStart);
WriteParam(aMsg, aParam.responseEnd);
WriteParam(aMsg, aParam.fetchStart);
WriteParam(aMsg, aParam.redirectStart);
WriteParam(aMsg, aParam.redirectEnd);
WriteParam(aMsg, aParam.transferSize);
WriteParam(aMsg, aParam.encodedBodySize);
WriteParam(aMsg, aParam.protocolVersion);
WriteParam(aMsg, aParam.cacheReadStart);
WriteParam(aMsg, aParam.cacheReadEnd);
}
static bool Read(const Message* aMsg, void** aIter, mozilla::net::ResourceTimingStruct* aResult)
{
return ReadParam(aMsg, aIter, &aResult->domainLookupStart) &&
ReadParam(aMsg, aIter, &aResult->domainLookupEnd) &&
ReadParam(aMsg, aIter, &aResult->connectStart) &&
ReadParam(aMsg, aIter, &aResult->connectEnd) &&
ReadParam(aMsg, aIter, &aResult->requestStart) &&
ReadParam(aMsg, aIter, &aResult->responseStart) &&
ReadParam(aMsg, aIter, &aResult->responseEnd) &&
ReadParam(aMsg, aIter, &aResult->fetchStart) &&
ReadParam(aMsg, aIter, &aResult->redirectStart) &&
ReadParam(aMsg, aIter, &aResult->redirectEnd) &&
ReadParam(aMsg, aIter, &aResult->transferSize) &&
ReadParam(aMsg, aIter, &aResult->encodedBodySize) &&
ReadParam(aMsg, aIter, &aResult->protocolVersion) &&
ReadParam(aMsg, aIter, &aResult->cacheReadStart) &&
ReadParam(aMsg, aIter, &aResult->cacheReadEnd);
}
};
} // namespace IPC
#endif // mozilla_net_NeckoMessageUtils_h