mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
b1814c6e48
- Bug 1011826 - Split Prefable into two pieces. r=bz. (115675544f) - Bug 1260653 - Shrink NativeProperties. r=bz. (a609483d76) - Bug 1255655 - Const-ify mozilla::dom::ErrorFormatString. r=baku. (8e4f4dac33) - Bug 1257389: Use fallible allocation for content-controlled string in bug 1257389. r=bz (b3670d2916) - Bug 1245650 - remove JavaScript-navigator-property category support. r=bz. (fd2be96344) - Bug 1260653 (follow-up) - Use |MOZ_CONSTEXPR| instead of |constexpr| to unbreak builds with VS 2013. r=birtles. (d76ab3c86d) - Bug 1259172 - Fix assertion in Codegen.py's InitUnforgeablePropertiesOnHolder function. r=bz (ef54b31645) - Bug 1250949. Add some better documentation to the dictionary init codegen. r=ehsan (f608f930e5) - build bits of Bug 1318955 - Upgrade to Hunspell 1.5.4 and remove stale README for non-existing patches (713d8d8329) - Bug 1250499 - prevent resource leak in mount_operation_ask_password. r=ehsan (ba9d741462) - Bug 1252902 - remove ScopedFreePtr; r=Waldo (c8978edf27) - Bug 1261452 - do_AddRef shouldn't require an rvalue-reference. r=froydnj (aec4028b9e) - Bug 1252901 - don't use ScopedFreePtrTraits in MediaEngineWrapper.h; r=jesup (d4cf3438e3) - Bug 1252198 - use UniquePtr instead of ScopedFreePtr in MediaEngineTabVideoSource; r=gerald (767055ddba) - Bug 1254102 - Add "blackout" mode. If the window is not legal, output a black square. r=jesup (4d19c584bb) - Bug 1250934: Only dig out cubeb deviceIDs immediately before use since they can be freed r=padenot (5c321f9458) - Bug 1255217: Don't require getUserMedia/cubeb device enumeration mapping if --disable-webrtc is set r=padenot (bd3efd7a23) - Bug 1257616: We can release Conduits immediately if we're on MainThread already r=drno (0b04888e2f) - Bug 1258144: Don't start a thread for SystemClockDriver if already started r=padenot (298893101c) - Bug 1258144: Flip warning sense typo in original patch for bug r=cpearce (53422b72a3) - Bug 1258144: warnings-as-errors bustage r=cpearce (9259a2e872) - Bug 1251502 - Use devid instead of device_id when getting the ID for a cubeb device. r=jesup (61bb95c418) - Bug 1258942: Lock around DeviceID access for audio inputs r=padenot (1bdd2da88d) - Bug 1250934: Don't allow switching to a clock driver when we already have a switch pending r=padenot (d35cf2791d) - Bug 1250934: Factor out AudioTracksPresent() in MediaStreamGraph, and add checks of 'pending' tracks r=padenot (1e53e16ec0) - Bug 1250934: Block GraphDriver switching if audio input is enabled (full-duplex) r=padenot (1b30daf654) - Bug 1256555: Wrap "shouldAEC" variable-usage in #ifdef for consistency & to fix --disable-webrtc build failure. r=jesup (fa701f164e) - Bug 1263251: Calculate AudioTrackPresent() correctly in MediaStreamGraph r=padenot (e4ca11bdcd) - Bug 1264195: Re-add SetMicrophoneActive() calls into the GraphDriver r=padenot (c995b0cd83) - Bug 1250934: Update some MediaStreamGraph logging r=padenot (e105642010) - Bug 1266438 - Reset the AEC and other processing when audio devices change. r=jesup (e09f6bc9e7) - Bug 1256510: When shutting down MediaStreamGraphs, if the graph hasn't started, let it start and shut down r=padenot (92ffec2c64) - Bug 1266438 - Remove workaround on OSX when switching device, not necessary with duplex mode. r=jesup (0203d61186) - Bug 1261627 - Unbreak --disable-webrtc builds. r=cpearce (38c2af874d) - Bug 1248861: P1. Add AlignedBuffer template class. r=cpearce (3b27482308) - Bug 1248861: P2. Use AlignedByteBuffer with MediaRawData. r=cpearce (0652979dbc) - Bug 1248861: P3. Use AlignedAudioBuffer object with AudioData. r=cpearce (6788c4c1cb) - Bug 1248861: P4. Add AudioConfig and introduce channel layout definition. r=cpearce (0b10c3dea0) - Bug 1248861: P5. Add AudioConverter class and relatives. r=cpearce (1492a238c5) - Bug 1248861: P6. Ensure AT decoder channel layout is always in SMPTE order. r=rillian (05db7e01d1) - Bug 1239223: [vorbis] P1. Properly calculate decoded audio sample timestamps. r=kinetik (b6088d692a) - Bug 1264500 - Include Telemetry.h to avoid build errors. r=cpearce (c019891221) - Bug 1248861: P7. Ensure vorbis decoder channel layout is always in SMPTE order. r=rillian (69bc69795c) - Bug 657791 - Update seekable range handling for cueless WebMs. r=kinetik MediaDecoder previously had 3 states within GetSeekable(), media is either seekable, seekable but not supported by transport, or not seekable. Due to changes to make cueless webms playable, a 4th option is needed: a file that is not fully seekable, but may support seeking from the transport, such as these webms, should only be seekable in the buffered range. (73132b539d) - Bug 1248861: P8. Added ChannelLayout::MappingTable method. r=gerald (e672ae0045) - Bug 1248861: P9. Use ChannelLayout::MappingTable. r=gerald (f4775517ba) - Bug 1241062: [opus] P1. Properly calculate decoded audio sample timestamps. r=kinetik (8ba6184301) - Bug 1248861: P10. Ensure opus decoder channel layout is always in SMPTE order. r=rillian (7c05d2ef52) - Bug 1248861: P11. Fix current downmixer. r=rillian Current downmixer was using vorbis channel order (which isn't surprising as it was extracted from the Ogg reader). Make it use SMPTE order as that's now what all MediaDataDecoder output. (e1f7ef6e41) - Bug 1248861: P12. Update AudioCompactor to account for alignment padding. r=rillian (7bc1630947) - Bug 1265093: Silence CID 1358535. r=gerald It was a false positive, has mData can only be null if mLength is also 0. (1dc80f251d) - Bug 1262753: P1. Add AudioConfig == and != operator. r=gerald (1470c50ee9) - Bug 1262753: P2. Add AudioDataBuffer::operator=. r=gerald (97dc392584) - Bug 1262753: P3. Add AudioConverter::InputConfig/OutputConfig. r=gerald Allow access to original constructor objects, to avoid having to store the original AudioConfig objects elsewhere. (743799c4d9) - Bug 1262746: P1. Add downmixing capabilities to AudioConverter. r=rillian (1bbb210b88) - Bug 1248513 - Fix static analysis errors in non-unified build for AudioStream.cpp. r=gerald. (ada96b559a) - Bug 1262746: P2. Use AudioConvert in AudioStream to downmix samples. r=jwwang (c1d42ba8c5) - Bug 1262746: P3. Remove DownmixAudioToStereo method. r=rillian Functionality is now provided through AudioConverter class. (df003d2602) - Bug 1248478 - Remove some obsolete code in XrayWrapper.cpp. r=bholley. (5e9fe8790d) - missing bit of (089ce6da47) - Bug 1256688 - Continue using getPropertyDescriptor for has in XrayWrapper. r=peterv (8119ce5cb0) - Bug 1260945 - Add missing isSystem check (r=bholley) (3365901bcb) - Bug 1264778 - Merge some XPConnect js::Class instances. r=mrbkap. XPC_WN_WithCall_ObjectOps and XPC_WN_NoCall_ObjectOps are both equal to JS_NULL_OBJECT_OPS. (b363936eb9) - Bug 1257892. Fix XPCConvert::JSValToXPCException to correctly detect Web IDL binding exceptions (i.e. all of them now!) when trying to check whether the value is already an XPCException. r=bholley (c48ff0620c) - Bug 1179278: GDB pretty-printers: handle encoding errors when trying to print JSObject class names. DONTBUILD r=jorendorff (e9981ce359) - Bug 1261426 - GDB Scripts: Add pretty printers for js::jit::ExecutableAllocator. r=jandem (eb5570d8c7) - Bug 1232712 - add a gdb unwinder for SpiderMonkey; r=nbp (b60ca7eac5) - Bug 1259867 - GDB Scripts: Disable SpiderMonkey's unwinder by default. r=tromey (2784da6603) - Bug 1261426 - GDB Scripts: Use the ExecutableAllocator as a fallback solution for finding JIT pages. r=tromey (b80bfc4112) - Bug 1261426 - GDB Scripts: Prevent gdb Memory.error when dereferencing null pointers. r=tromey (ce5a767db1) - Bug 1254295 - add function name to gdb frame filter; r=nbp (ba31fca7c9) - Bug 1262936 - Add missing OOM check to RegExpStack::reset. r=bhackett (3d7c4be6c6) - Bug 1257779 - Don't make scripted proxies' [[OwnPropertyKeys]] have non-linear behavior in certain cases. r=jonco, r=evilpie (3b6e95f8e5) - Bug 1266614 - Fix C4334 in OrderedHashTable.h. r=jandem (c764886bc4) - Bug 1264920: IonMonkey - DoTypeUpdateFallback is not allowed to gc, r=jandem (df8cb4d03d)
458 lines
13 KiB
C++
458 lines
13 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 "nsScriptNameSpaceManager.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsIComponentManager.h"
|
|
#include "nsIComponentRegistrar.h"
|
|
#include "nsICategoryManager.h"
|
|
#include "nsIServiceManager.h"
|
|
#include "nsXPCOM.h"
|
|
#include "nsISupportsPrimitives.h"
|
|
#include "nsIScriptNameSpaceManager.h"
|
|
#include "nsIScriptContext.h"
|
|
#include "nsIInterfaceInfoManager.h"
|
|
#include "nsIInterfaceInfo.h"
|
|
#include "xptinfo.h"
|
|
#include "nsXPIDLString.h"
|
|
#include "nsPrintfCString.h"
|
|
#include "nsReadableUtils.h"
|
|
#include "nsHashKeys.h"
|
|
#include "nsDOMClassInfo.h"
|
|
#include "nsCRT.h"
|
|
#include "nsIObserverService.h"
|
|
#include "nsISimpleEnumerator.h"
|
|
|
|
#include "mozilla/MemoryReporting.h"
|
|
#include "mozilla/Preferences.h"
|
|
#include "mozilla/Services.h"
|
|
|
|
#define NS_INTERFACE_PREFIX "nsI"
|
|
#define NS_DOM_INTERFACE_PREFIX "nsIDOM"
|
|
|
|
using namespace mozilla;
|
|
|
|
static PLDHashNumber
|
|
GlobalNameHashHashKey(const void *key)
|
|
{
|
|
const nsAString *str = static_cast<const nsAString *>(key);
|
|
return HashString(*str);
|
|
}
|
|
|
|
static bool
|
|
GlobalNameHashMatchEntry(const PLDHashEntryHdr *entry, const void *key)
|
|
{
|
|
const GlobalNameMapEntry *e =
|
|
static_cast<const GlobalNameMapEntry *>(entry);
|
|
const nsAString *str = static_cast<const nsAString *>(key);
|
|
|
|
return str->Equals(e->mKey);
|
|
}
|
|
|
|
static void
|
|
GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|
{
|
|
GlobalNameMapEntry *e = static_cast<GlobalNameMapEntry *>(entry);
|
|
|
|
// An entry is being cleared, let the key (nsString) do its own
|
|
// cleanup.
|
|
e->mKey.~nsString();
|
|
|
|
// This will set e->mGlobalName.mType to
|
|
// nsGlobalNameStruct::eTypeNotInitialized
|
|
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
|
}
|
|
|
|
static void
|
|
GlobalNameHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
|
{
|
|
GlobalNameMapEntry *e = static_cast<GlobalNameMapEntry *>(entry);
|
|
const nsAString *keyStr = static_cast<const nsAString *>(key);
|
|
|
|
// Initialize the key in the entry with placement new
|
|
new (&e->mKey) nsString(*keyStr);
|
|
|
|
// This will set e->mGlobalName.mType to
|
|
// nsGlobalNameStruct::eTypeNotInitialized
|
|
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
|
}
|
|
|
|
NS_IMPL_ISUPPORTS(
|
|
nsScriptNameSpaceManager,
|
|
nsIObserver,
|
|
nsISupportsWeakReference,
|
|
nsIMemoryReporter)
|
|
|
|
static const PLDHashTableOps hash_table_ops =
|
|
{
|
|
GlobalNameHashHashKey,
|
|
GlobalNameHashMatchEntry,
|
|
PLDHashTable::MoveEntryStub,
|
|
GlobalNameHashClearEntry,
|
|
GlobalNameHashInitEntry
|
|
};
|
|
|
|
#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 512
|
|
|
|
nsScriptNameSpaceManager::nsScriptNameSpaceManager()
|
|
: mGlobalNames(&hash_table_ops, sizeof(GlobalNameMapEntry),
|
|
GLOBALNAME_HASHTABLE_INITIAL_LENGTH)
|
|
{
|
|
MOZ_COUNT_CTOR(nsScriptNameSpaceManager);
|
|
}
|
|
|
|
nsScriptNameSpaceManager::~nsScriptNameSpaceManager()
|
|
{
|
|
UnregisterWeakMemoryReporter(this);
|
|
MOZ_COUNT_DTOR(nsScriptNameSpaceManager);
|
|
}
|
|
|
|
nsGlobalNameStruct *
|
|
nsScriptNameSpaceManager::AddToHash(const nsAString *aKey,
|
|
const char16_t **aClassName)
|
|
{
|
|
auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Add(aKey, fallible));
|
|
if (!entry) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (aClassName) {
|
|
*aClassName = entry->mKey.get();
|
|
}
|
|
|
|
return &entry->mGlobalName;
|
|
}
|
|
|
|
void
|
|
nsScriptNameSpaceManager::RemoveFromHash(const nsAString *aKey)
|
|
{
|
|
mGlobalNames.Remove(aKey);
|
|
}
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
|
|
const char *aCategory)
|
|
{
|
|
nsCOMPtr<nsISimpleEnumerator> e;
|
|
nsresult rv = aCategoryManager->EnumerateCategory(aCategory,
|
|
getter_AddRefs(e));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<nsISupports> entry;
|
|
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
|
|
rv = AddCategoryEntryToHash(aCategoryManager, aCategory, entry);
|
|
if (NS_FAILED(rv)) {
|
|
return rv;
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::Init()
|
|
{
|
|
RegisterWeakMemoryReporter(this);
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsICategoryManager> cm =
|
|
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = FillHash(cm, JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = FillHash(cm, JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = FillHash(cm, JAVASCRIPT_GLOBAL_PRIVILEGED_PROPERTY_CATEGORY);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// Initial filling of the has table has been done.
|
|
// Now, listen for changes.
|
|
nsCOMPtr<nsIObserverService> serv =
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (serv) {
|
|
serv->AddObserver(this, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID, true);
|
|
serv->AddObserver(this, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID, true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
const nsGlobalNameStruct*
|
|
nsScriptNameSpaceManager::LookupName(const nsAString& aName,
|
|
const char16_t **aClassName)
|
|
{
|
|
auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Search(&aName));
|
|
|
|
if (entry) {
|
|
if (aClassName) {
|
|
*aClassName = entry->mKey.get();
|
|
}
|
|
return &entry->mGlobalName;
|
|
}
|
|
|
|
if (aClassName) {
|
|
*aClassName = nullptr;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
|
int32_t aDOMClassInfoID,
|
|
bool aPrivileged,
|
|
bool aXBLAllowed,
|
|
const char16_t **aResult)
|
|
{
|
|
if (!nsCRT::IsAscii(aClassName)) {
|
|
NS_ERROR("Trying to register a non-ASCII class name");
|
|
return NS_OK;
|
|
}
|
|
nsGlobalNameStruct *s = AddToHash(aClassName, aResult);
|
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
return NS_OK;
|
|
}
|
|
|
|
// If a external constructor is already defined with aClassName we
|
|
// won't overwrite it.
|
|
|
|
if (s->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
|
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding,
|
|
"Whaaa, JS environment name clash!");
|
|
|
|
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
|
|
s->mDOMClassInfoID = aDOMClassInfoID;
|
|
s->mChromeOnly = aPrivileged;
|
|
s->mAllowXBL = aXBLAllowed;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
|
const nsIID *aConstructorProtoIID,
|
|
bool *aFoundOld)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aConstructorProtoIID);
|
|
|
|
*aFoundOld = false;
|
|
|
|
nsGlobalNameStruct *s = AddToHash(aClassName);
|
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
|
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) {
|
|
*aFoundOld = true;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
s->mType = nsGlobalNameStruct::eTypeClassProto;
|
|
s->mIID = *aConstructorProtoIID;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategoryManager,
|
|
const char* aCategory,
|
|
nsISupports* aEntry,
|
|
bool aRemove)
|
|
{
|
|
MOZ_ASSERT(aCategoryManager);
|
|
// Get the type from the category name.
|
|
// NOTE: we could have passed the type in FillHash() and guessed it in
|
|
// Observe() but this way, we have only one place to update and this is
|
|
// not performance sensitive.
|
|
nsGlobalNameStruct::nametype type;
|
|
if (strcmp(aCategory, JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY) == 0) {
|
|
type = nsGlobalNameStruct::eTypeExternalConstructor;
|
|
} else if (strcmp(aCategory, JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY) == 0 ||
|
|
strcmp(aCategory, JAVASCRIPT_GLOBAL_PRIVILEGED_PROPERTY_CATEGORY) == 0) {
|
|
type = nsGlobalNameStruct::eTypeProperty;
|
|
} else {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsISupportsCString> strWrapper = do_QueryInterface(aEntry);
|
|
|
|
if (!strWrapper) {
|
|
NS_WARNING("Category entry not an nsISupportsCString!");
|
|
return NS_OK;
|
|
}
|
|
|
|
nsAutoCString categoryEntry;
|
|
nsresult rv = strWrapper->GetData(categoryEntry);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// We need to handle removal before calling GetCategoryEntry
|
|
// because the category entry is already removed before we are
|
|
// notified.
|
|
if (aRemove) {
|
|
NS_ConvertASCIItoUTF16 entry(categoryEntry);
|
|
const nsGlobalNameStruct *s = LookupName(entry);
|
|
// Verify mType so that this API doesn't remove names
|
|
// registered by others.
|
|
if (!s || s->mType != type) {
|
|
return NS_OK;
|
|
}
|
|
|
|
RemoveFromHash(&entry);
|
|
return NS_OK;
|
|
}
|
|
|
|
nsXPIDLCString contractId;
|
|
rv = aCategoryManager->GetCategoryEntry(aCategory, categoryEntry.get(),
|
|
getter_Copies(contractId));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (type == nsGlobalNameStruct::eTypeExternalConstructor) {
|
|
nsPrintfCString prefName("dom.global-constructor.disable.%s",
|
|
categoryEntry.get());
|
|
if (Preferences::GetType(prefName.get()) == nsIPrefBranch::PREF_BOOL &&
|
|
Preferences::GetBool(prefName.get(), false)) {
|
|
return NS_OK;
|
|
}
|
|
}
|
|
|
|
nsCOMPtr<nsIComponentRegistrar> registrar;
|
|
rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCID *cidPtr;
|
|
rv = registrar->ContractIDToCID(contractId, &cidPtr);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
NS_WARNING("Bad contract id registed with the script namespace manager");
|
|
return NS_OK;
|
|
}
|
|
|
|
// Copy CID onto the stack, so we can free it right away and avoid having
|
|
// to add cleanup code at every exit point from this function.
|
|
nsCID cid = *cidPtr;
|
|
free(cidPtr);
|
|
|
|
nsGlobalNameStruct *s = AddToHash(categoryEntry.get());
|
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
|
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding) {
|
|
s->mType = type;
|
|
s->mCID = cid;
|
|
s->mChromeOnly =
|
|
strcmp(aCategory, JAVASCRIPT_GLOBAL_PRIVILEGED_PROPERTY_CATEGORY) == 0;
|
|
} else {
|
|
NS_WARNING("Global script name not overwritten!");
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::AddCategoryEntryToHash(nsICategoryManager* aCategoryManager,
|
|
const char* aCategory,
|
|
nsISupports* aEntry)
|
|
{
|
|
return OperateCategoryEntryHash(aCategoryManager, aCategory, aEntry,
|
|
/* aRemove = */ false);
|
|
}
|
|
|
|
nsresult
|
|
nsScriptNameSpaceManager::RemoveCategoryEntryFromHash(nsICategoryManager* aCategoryManager,
|
|
const char* aCategory,
|
|
nsISupports* aEntry)
|
|
{
|
|
return OperateCategoryEntryHash(aCategoryManager, aCategory, aEntry,
|
|
/* aRemove = */ true);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsScriptNameSpaceManager::Observe(nsISupports* aSubject, const char* aTopic,
|
|
const char16_t* aData)
|
|
{
|
|
if (!aData) {
|
|
return NS_OK;
|
|
}
|
|
|
|
if (!strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID)) {
|
|
nsCOMPtr<nsICategoryManager> cm =
|
|
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
|
if (!cm) {
|
|
return NS_OK;
|
|
}
|
|
|
|
return AddCategoryEntryToHash(cm, NS_ConvertUTF16toUTF8(aData).get(),
|
|
aSubject);
|
|
} else if (!strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID)) {
|
|
nsCOMPtr<nsICategoryManager> cm =
|
|
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
|
if (!cm) {
|
|
return NS_OK;
|
|
}
|
|
|
|
return RemoveCategoryEntryFromHash(cm, NS_ConvertUTF16toUTF8(aData).get(),
|
|
aSubject);
|
|
}
|
|
|
|
// TODO: we could observe NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID
|
|
// but we are safe without it. See bug 600460.
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsScriptNameSpaceManager::RegisterDefineDOMInterface(const nsAFlatString& aName,
|
|
mozilla::dom::DefineInterface aDefineDOMInterface,
|
|
mozilla::dom::ConstructorEnabled* aConstructorEnabled)
|
|
{
|
|
nsGlobalNameStruct *s = AddToHash(&aName);
|
|
if (s) {
|
|
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
|
s->mType = nsGlobalNameStruct::eTypeNewDOMBinding;
|
|
}
|
|
s->mDefineDOMInterface = aDefineDOMInterface;
|
|
s->mConstructorEnabled = aConstructorEnabled;
|
|
}
|
|
}
|
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF(ScriptNameSpaceManagerMallocSizeOf)
|
|
|
|
NS_IMETHODIMP
|
|
nsScriptNameSpaceManager::CollectReports(
|
|
nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize)
|
|
{
|
|
return MOZ_COLLECT_REPORT(
|
|
"explicit/script-namespace-manager", KIND_HEAP, UNITS_BYTES,
|
|
SizeOfIncludingThis(ScriptNameSpaceManagerMallocSizeOf),
|
|
"Memory used for the script namespace manager.");
|
|
}
|
|
|
|
size_t
|
|
nsScriptNameSpaceManager::SizeOfIncludingThis(
|
|
mozilla::MallocSizeOf aMallocSizeOf) const
|
|
{
|
|
size_t n = 0;
|
|
|
|
n += mGlobalNames.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
|
for (auto iter = mGlobalNames.ConstIter(); !iter.Done(); iter.Next()) {
|
|
auto entry = static_cast<GlobalNameMapEntry*>(iter.Get());
|
|
n += entry->SizeOfExcludingThis(aMallocSizeOf);
|
|
}
|
|
|
|
return n;
|
|
}
|