Files
palemoon27/embedding/components/commandhandler/nsCommandParams.cpp
T
roytam1 86eaa55e65 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1251999 - [css-grid] Update <fixed-size> parsing to the latest spec. r=dholbert (07f68007b7)
- Bug 1151243 part 5 - [css-grid] Reftests for abs. pos. static-position. (f9a3b24508)
- Bug 1242053 part 1 - [css-grid] Fix parsing / serialization of grid-template subgrid values. r=dholbert (39576c2f6d)
- Bug 1242053 part 2 - [css-grid] Enable subgrid support for tests. r=dholbert (6da4aeb35a)
- Bug 1240956 part 2 - [css-grid] Update tests due to the changed column/row value order for 'grid', 'grid-template' and 'grid-gap' properties. (16d2258d3a)
- Bug 1253529 part 1 - [css-grid] Replace uses of the 'grid-template' shorthand with 'grid'. (f847bfa554)
- Bug 1253529 part 2 - [css-grid] Remove the 'grid-template' shorthand. r=dholbert (d553c2f623)
- Bug 594933 - Part 1: Let calc() supports number. r=dbaron (e4bc39b5f0)
- Bug 594933 - Part 2: Add support for calc() to line-height. r=dbaron (901227bacb)
- Bug 1253189 part 5 - Import reftests of css-values. r=dbaron (4599431827)
- Bug 1253189 part 4 - Add skip.list for skipping imported tests. r=dbaron (014f7ca7de)
- Bug 1253189 part 1 - Make import-tests.py compatible with Windows. r=dbaron (a22c3e4f7f)
- Bug 1253189 part 2 - Update import-tests.py script to work on the current repo. r=dbaron (7535b38b71)
- Bug 1253189 part 3 - Update existing received w3c reftests. r=dbaron (0fa2d6e2de)
- Bug 1253189 followup - Update skip.list to match the directory name on CLOSED TREE (019b55c3c9)
- Bug 968761 - Treat nested calc() as plain parenthesis. r=dbaron (537506f4e5)
- Bug 1248371 - [css-grid] Require that each track has a definite min- or max-sizing function when the track list contains a repeat(auto-fill/fit) track. r=dholbert (330dd37427)
- Bug 1244638 - Part 1:implement AnimationEffectTiming iterationStart. r=birtles, r=smaug (d0217068ac)
- Bug 1244638 - Part 2: Throw TypeError if iterationStart is NaN, negative value or Infinity. r=birtles, r=smaug (f631e261a0)
- Bug 1238845 - Implement UUID helper - dom/bluetooth & dom/webidl & layout/build change. r=jocelyn, r=bz (3ddfa8cccf)
- Bug 1252790 - Remove RuleHashTableOps. r=dbaron. (b52d9e2613)
- Bug 1252375 - Fix up jemalloc stats reporting. r=erahm. (dbecb54598)
- Bug 1249503 - Make WindowsAddressSpaceReporter bloat memory reports less. r=erahm. (3bfb6932cb)
- Bug 1253085 - Remove the |PLDHashTable*| argument from PLDHash{HashKey,MatchEntry}. r=froydnj. (1331fd9ea0)
- Bug 1251127 - Gracefully handle multiple calls to nsMemoryReporterManager::Init(). r=erahm. (c51f57907e)
- Bug 1234540 - verify the validity of hashEntry, if it's null return with NS_ERROR_FAILURE. r=michal (f44bd269db)
- Bug 1112499 - Set up shutdown pipe before new thread starts. r=keeler (73b9a56196)
- Bug 1245059 - Disable NotifyIpInterfaceChange use for now. r=mcmanus (ab11fd8507)
- Bug 1251873 - Store the trimmed referrer URL on HTTP channel if a trimming referrer policy is in effect; r=mcmanus (3f43d5b351)
- more bits of bug 366559 - patch 7, content-encoding brotli for https (f127a97450)
- Bug 1250115 - initialized pollInterval with 0 in order to prevent garbage value if Poll(..) doesn't get called. r=dragana (af55e06789)
- Bug 1251493 - Remove remaining references to MOZILLA_XPCOMRT_API from netwerk. r=mcmanus (43d711d2d6)
- Bug 1242452 - only if PR_GetIdentitiesLayer return valid pointer continue and pass it's result to PR_GetIdentitiesLayer. r=mcmanus (61a2785337)
- Bug 1251595 - Check if mNetAddr is set before sending ipv4/6 telemetry. r=mcmanus (9d081bc0b9)
- Bug 1252755: increase maximum UDP packet size to 9216 bytes for jumbo frames. r=jesup (3d629473ea)
- Bug 1194259: warnings-as-errors bustage fix rs=bustagn a CLOSED TREE (5b8288ff6d)
- Bug 1227781 - Fix crash with bogus STUN parameters. r=bwc (7d132a37ff)
- Bug 1231196: Fix init of PeerConnectionImpl::mThread for unit-tests and similar. r+drno (60f11ed191)
- Bug 1230184 - plumb setParameters down to JsepTrack. r=bwc, r=mrbkap (fdeaafb737)
- Bug 1231507 - Part 1: selectSsrc chrome-only API for SSRC-based filtering of receive tracks. r=drno, r=smaug (c24ce1a76e)
- Bug 1221837 - Accept hard coded codec numbers without rtpmaps. r=bwc (89b81c861c)
- Bug 1231507 - Part 2: added mochitest SimulCast offer test case r=jib (05d838960f)
- Bug 1230184 - setParameters webidl. r=smaug (6319cdfca7)
- Bug 1230184 - add input parameter validation to setParameters. r=bwc (c0740c142a)
- Bug 1230184 - add media.peerconnection.simulcast pref. r=bwc (99b1a4978d)
- Bug 1247619 - add console warning about OAuth for STUN not yet supported. r=jesup,smaug (801eaa66e1)
- Bug 1241153: Stop blocking addTrack on GMP init, and update codecs on existing tracks when GMP init finishes. r=jesup (3473dfe0ce)
- Bug 1251737 - Remove remaining references to MOZILLA_XPCOMRT_API from media. r=jesup (7b32d9d191)
- Bug 1218326: Prevent datachannel operations on closed PeerConnections. r=jesup a=lizzard (5d20d7dd7f)
- Bug 1211091 - use upper boundary for streams per data channel. r=bwc (7f9462c434)
- Bug 1188391 - separate immediate ICE failures from failures after checking. r=bwc, r=vladan (9095c58656)
- Bug 1227708 - Differentiate ICE_SUCCESS_RATE telemetry for loop vs webrtc r=jesup (399406c872)
- Bug 1232082 - fix removal of remote tracks to update receivers. r=jesup (81998ed355)
- Bug 1244913 - Add test_peerConnection_scaleResolution.html r=bwc,jesup (8ac2d8a363)
- Bug 1249860 - Add simulcast test for resolution scaling. r=bwc (c7753bf02b)
- Bug 1247622 - Make RTCRtpSender.setParameters return a promise. r=jesup,smaug (4c2504adc8)
2024-02-29 23:07:00 +08:00

265 lines
6.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "xpcom-config.h"
#include <new>
#include "nscore.h"
#include "nsCRT.h"
#include "nsCommandParams.h"
#include "mozilla/HashFunctions.h"
using namespace mozilla;
const PLDHashTableOps nsCommandParams::sHashOps =
{
HashKey,
HashMatchEntry,
HashMoveEntry,
HashClearEntry
};
NS_IMPL_ISUPPORTS(nsCommandParams, nsICommandParams)
nsCommandParams::nsCommandParams()
: mValuesHash(&sHashOps, sizeof(HashEntry), 2)
{
}
nsCommandParams::~nsCommandParams()
{
}
NS_IMETHODIMP
nsCommandParams::GetValueType(const char* aName, int16_t* aRetVal)
{
NS_ENSURE_ARG_POINTER(aRetVal);
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry) {
*aRetVal = foundEntry->mEntryType;
return NS_OK;
}
*aRetVal = eNoType;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::GetBooleanValue(const char* aName, bool* aRetVal)
{
NS_ENSURE_ARG_POINTER(aRetVal);
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry && foundEntry->mEntryType == eBooleanType) {
*aRetVal = foundEntry->mData.mBoolean;
return NS_OK;
}
*aRetVal = false;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::GetLongValue(const char* aName, int32_t* aRetVal)
{
NS_ENSURE_ARG_POINTER(aRetVal);
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry && foundEntry->mEntryType == eLongType) {
*aRetVal = foundEntry->mData.mLong;
return NS_OK;
}
*aRetVal = false;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::GetDoubleValue(const char* aName, double* aRetVal)
{
NS_ENSURE_ARG_POINTER(aRetVal);
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry && foundEntry->mEntryType == eDoubleType) {
*aRetVal = foundEntry->mData.mDouble;
return NS_OK;
}
*aRetVal = 0.0;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::GetStringValue(const char* aName, nsAString& aRetVal)
{
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry && foundEntry->mEntryType == eWStringType) {
NS_ASSERTION(foundEntry->mData.mString, "Null string");
aRetVal.Assign(*foundEntry->mData.mString);
return NS_OK;
}
aRetVal.Truncate();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::GetCStringValue(const char* aName, char** aRetVal)
{
NS_ENSURE_ARG_POINTER(aRetVal);
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry && foundEntry->mEntryType == eStringType) {
NS_ASSERTION(foundEntry->mData.mCString, "Null string");
*aRetVal = ToNewCString(*foundEntry->mData.mCString);
return NS_OK;
}
*aRetVal = nullptr;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::GetISupportsValue(const char* aName, nsISupports** aRetVal)
{
NS_ENSURE_ARG_POINTER(aRetVal);
HashEntry* foundEntry = GetNamedEntry(aName);
if (foundEntry && foundEntry->mEntryType == eISupportsType) {
NS_IF_ADDREF(*aRetVal = foundEntry->mISupports.get());
return NS_OK;
}
*aRetVal = nullptr;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCommandParams::SetBooleanValue(const char* aName, bool aValue)
{
HashEntry* foundEntry = GetOrMakeEntry(aName, eBooleanType);
if (!foundEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
foundEntry->mData.mBoolean = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsCommandParams::SetLongValue(const char* aName, int32_t aValue)
{
HashEntry* foundEntry = GetOrMakeEntry(aName, eLongType);
if (!foundEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
foundEntry->mData.mLong = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsCommandParams::SetDoubleValue(const char* aName, double aValue)
{
HashEntry* foundEntry = GetOrMakeEntry(aName, eDoubleType);
if (!foundEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
foundEntry->mData.mDouble = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsCommandParams::SetStringValue(const char* aName, const nsAString& aValue)
{
HashEntry* foundEntry = GetOrMakeEntry(aName, eWStringType);
if (!foundEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
foundEntry->mData.mString = new nsString(aValue);
return NS_OK;
}
NS_IMETHODIMP
nsCommandParams::SetCStringValue(const char* aName, const char* aValue)
{
HashEntry* foundEntry = GetOrMakeEntry(aName, eStringType);
if (!foundEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
foundEntry->mData.mCString = new nsCString(aValue);
return NS_OK;
}
NS_IMETHODIMP
nsCommandParams::SetISupportsValue(const char* aName, nsISupports* aValue)
{
HashEntry* foundEntry = GetOrMakeEntry(aName, eISupportsType);
if (!foundEntry) {
return NS_ERROR_OUT_OF_MEMORY;
}
foundEntry->mISupports = aValue; // addrefs
return NS_OK;
}
NS_IMETHODIMP
nsCommandParams::RemoveValue(const char* aName)
{
mValuesHash.Remove((void*)aName);
return NS_OK;
}
nsCommandParams::HashEntry*
nsCommandParams::GetNamedEntry(const char* aName)
{
return static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
}
nsCommandParams::HashEntry*
nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType)
{
auto foundEntry = static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
if (foundEntry) { // reuse existing entry
foundEntry->Reset(aEntryType);
return foundEntry;
}
foundEntry = static_cast<HashEntry*>(mValuesHash.Add((void*)aName, fallible));
if (!foundEntry) {
return nullptr;
}
// Use placement new. Our ctor does not clobber keyHash, which is important.
new (foundEntry) HashEntry(aEntryType, aName);
return foundEntry;
}
PLDHashNumber
nsCommandParams::HashKey(const void* aKey)
{
return HashString((const char*)aKey);
}
bool
nsCommandParams::HashMatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey)
{
const char* keyString = (const char*)aKey;
const HashEntry* thisEntry = static_cast<const HashEntry*>(aEntry);
return thisEntry->mEntryName.Equals(keyString);
}
void
nsCommandParams::HashMoveEntry(PLDHashTable* aTable,
const PLDHashEntryHdr* aFrom,
PLDHashEntryHdr* aTo)
{
const HashEntry* fromEntry = static_cast<const HashEntry*>(aFrom);
HashEntry* toEntry = static_cast<HashEntry*>(aTo);
new (toEntry) HashEntry(*fromEntry);
fromEntry->~HashEntry();
}
void
nsCommandParams::HashClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
{
HashEntry* thisEntry = static_cast<HashEntry*>(aEntry);
thisEntry->~HashEntry();
}