Backed out changeset d385df62c0e7 (bug 1267186) for hazard failures

This commit is contained in:
Carsten "Tomcat" Book
2016-05-09 13:40:01 +02:00
parent ea4915ffd1
commit 08a1dea94e
12 changed files with 221 additions and 465 deletions

View File

@@ -25,8 +25,7 @@
#include "nsCRT.h"
#include "nsIObserverService.h"
#include "nsISimpleEnumerator.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/WebIDLGlobalNameHash.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
@@ -35,7 +34,6 @@
#define NS_DOM_INTERFACE_PREFIX "nsIDOM"
using namespace mozilla;
using namespace mozilla::dom;
static PLDHashNumber
GlobalNameHashHashKey(const void *key)
@@ -97,7 +95,7 @@ static const PLDHashTableOps hash_table_ops =
GlobalNameHashInitEntry
};
#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 32
#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 512
nsScriptNameSpaceManager::nsScriptNameSpaceManager()
: mGlobalNames(&hash_table_ops, sizeof(GlobalNameMapEntry),
@@ -113,17 +111,14 @@ nsScriptNameSpaceManager::~nsScriptNameSpaceManager()
}
nsGlobalNameStruct *
nsScriptNameSpaceManager::AddToHash(const char *aKey,
nsScriptNameSpaceManager::AddToHash(const nsAString *aKey,
const char16_t **aClassName)
{
NS_ConvertASCIItoUTF16 key(aKey);
auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Add(&key, fallible));
auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Add(aKey, fallible));
if (!entry) {
return nullptr;
}
WebIDLGlobalNameHash::Remove(aKey, key.Length());
if (aClassName) {
*aClassName = entry->mKey.get();
}
@@ -235,7 +230,8 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
return NS_OK;
}
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized,
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding,
"Whaaa, JS environment name clash!");
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
@@ -258,7 +254,8 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
nsGlobalNameStruct *s = AddToHash(aClassName);
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) {
*aFoundOld = true;
return NS_OK;
@@ -352,7 +349,8 @@ nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategory
nsGlobalNameStruct *s = AddToHash(categoryEntry.get());
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding) {
s->mType = type;
s->mCID = cid;
s->mChromeOnly =
@@ -416,6 +414,21 @@ nsScriptNameSpaceManager::Observe(nsISupports* aSubject, const char* aTopic,
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