2013-01-15 04:26:47 +04:00
|
|
|
/* -*- 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
|
2012-05-21 15:12:37 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2017-08-17 00:10:56 +03:00
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-12-21 19:51:10 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
#ifndef nsScriptNameSpaceManager_h__
|
|
|
|
#define nsScriptNameSpaceManager_h__
|
1998-12-21 19:51:10 +03:00
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2015-08-21 00:20:06 +03:00
|
|
|
#include "nsBaseHashtable.h"
|
2013-11-07 09:35:30 +04:00
|
|
|
#include "nsIMemoryReporter.h"
|
1998-12-21 19:51:10 +03:00
|
|
|
#include "nsIScriptNameSpaceManager.h"
|
2002-01-17 07:08:14 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsID.h"
|
2015-09-16 06:49:53 +03:00
|
|
|
#include "PLDHashTable.h"
|
2002-03-04 05:25:08 +03:00
|
|
|
#include "nsDOMClassInfo.h"
|
2010-11-17 01:09:50 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
2013-08-15 22:17:48 +04:00
|
|
|
#include "xpcpublic.h"
|
2010-11-17 01:09:50 +03:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
struct nsGlobalNameStruct
|
|
|
|
{
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
enum nametype {
|
2002-01-17 07:08:14 +03:00
|
|
|
eTypeNotInitialized,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
eTypeProperty,
|
2001-07-11 13:09:30 +04:00
|
|
|
eTypeExternalConstructor,
|
|
|
|
eTypeClassConstructor,
|
2002-03-04 05:25:08 +03:00
|
|
|
eTypeClassProto,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
} mType;
|
|
|
|
|
2013-08-09 18:35:53 +04:00
|
|
|
bool mChromeOnly : 1;
|
|
|
|
bool mAllowXBL : 1;
|
2007-06-26 18:44:20 +04:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
union {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mDOMClassInfoID; // eTypeClassConstructor
|
2016-02-14 17:59:48 +03:00
|
|
|
nsIID mIID; // eTypeClassProto
|
2016-05-09 18:08:31 +03:00
|
|
|
nsCID mCID; // All other types
|
2001-07-11 13:09:30 +04:00
|
|
|
};
|
|
|
|
};
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2015-06-18 06:30:15 +03:00
|
|
|
class GlobalNameMapEntry : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Our hash table ops don't care about the order of these members.
|
|
|
|
nsString mKey;
|
|
|
|
nsGlobalNameStruct mGlobalName;
|
|
|
|
|
|
|
|
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
|
|
|
// Measurement of the following members may be added later if DMD finds it
|
|
|
|
// is worthwhile:
|
|
|
|
// - mGlobalName
|
2015-11-18 01:46:46 +03:00
|
|
|
return mKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
2015-06-18 06:30:15 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
class nsICategoryManager;
|
|
|
|
|
2013-12-08 10:09:10 +04:00
|
|
|
class nsScriptNameSpaceManager : public nsIObserver,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsIMemoryReporter
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
{
|
|
|
|
public:
|
2010-11-17 01:09:50 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
2013-12-08 10:09:10 +04:00
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
2010-11-17 01:09:50 +03:00
|
|
|
|
1998-12-21 19:51:10 +03:00
|
|
|
nsScriptNameSpaceManager();
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
nsresult Init();
|
|
|
|
|
2002-01-17 07:08:14 +03:00
|
|
|
// Returns a nsGlobalNameStruct for aName, or null if one is not
|
|
|
|
// found. The returned nsGlobalNameStruct is only guaranteed to be
|
|
|
|
// valid until the next call to any of the methods in this class.
|
2003-01-31 15:10:13 +03:00
|
|
|
// It also returns a pointer to the string buffer of the classname
|
|
|
|
// in the nsGlobalNameStruct.
|
2012-03-29 22:43:13 +04:00
|
|
|
const nsGlobalNameStruct* LookupName(const nsAString& aName,
|
2016-02-05 22:20:08 +03:00
|
|
|
const char16_t **aClassName = nullptr);
|
1998-12-21 19:51:10 +03:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
nsresult RegisterClassName(const char *aClassName,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aDOMClassInfoID,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aPrivileged,
|
2013-08-09 18:35:53 +04:00
|
|
|
bool aXBLAllowed,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t **aResult);
|
2001-07-11 13:09:30 +04:00
|
|
|
|
|
|
|
nsresult RegisterClassProto(const char *aClassName,
|
|
|
|
const nsIID *aConstructorProtoIID,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *aFoundOld);
|
2001-07-11 13:09:30 +04:00
|
|
|
|
2015-06-18 06:30:15 +03:00
|
|
|
class NameIterator : public PLDHashTable::Iterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef PLDHashTable::Iterator Base;
|
|
|
|
explicit NameIterator(PLDHashTable* aTable) : Base(aTable) {}
|
|
|
|
NameIterator(NameIterator&& aOther) : Base(mozilla::Move(aOther.mTable)) {}
|
|
|
|
|
|
|
|
const GlobalNameMapEntry* Get() const
|
|
|
|
{
|
|
|
|
return static_cast<const GlobalNameMapEntry*>(Base::Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
NameIterator() = delete;
|
|
|
|
NameIterator(const NameIterator&) = delete;
|
|
|
|
NameIterator& operator=(const NameIterator&) = delete;
|
|
|
|
NameIterator& operator=(const NameIterator&&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
NameIterator GlobalNameIter() { return NameIterator(&mGlobalNames); }
|
2012-11-01 21:51:57 +04:00
|
|
|
|
2015-07-30 08:28:20 +03:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-11-05 02:18:44 +04:00
|
|
|
|
2012-03-31 08:42:20 +04:00
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~nsScriptNameSpaceManager();
|
|
|
|
|
2002-01-17 07:08:14 +03:00
|
|
|
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
|
|
|
// that aKey will be mapped to. If mType in the returned
|
|
|
|
// nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
|
|
|
|
// already existed.
|
2016-05-09 14:40:01 +03:00
|
|
|
nsGlobalNameStruct *AddToHash(const char *aKey,
|
2016-05-09 18:08:31 +03:00
|
|
|
const char16_t **aClassName = nullptr);
|
|
|
|
|
2013-08-22 17:44:19 +04:00
|
|
|
// Removes an existing entry from the hash.
|
2016-02-05 22:20:08 +03:00
|
|
|
void RemoveFromHash(const nsAString *aKey);
|
2002-01-17 07:08:14 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
nsresult FillHash(nsICategoryManager *aCategoryManager,
|
2010-11-17 01:09:50 +03:00
|
|
|
const char *aCategory);
|
1998-12-21 19:51:10 +03:00
|
|
|
|
2010-11-17 01:09:50 +03:00
|
|
|
/**
|
|
|
|
* Add a new category entry into the hash table.
|
2011-02-03 02:46:12 +03:00
|
|
|
* Only some categories can be added (see the beginning of the definition).
|
|
|
|
* The other ones will be ignored.
|
2010-11-17 01:09:50 +03:00
|
|
|
*
|
|
|
|
* @aCategoryManager Instance of the category manager service.
|
|
|
|
* @aCategory Category where the entry comes from.
|
|
|
|
* @aEntry The entry that should be added.
|
|
|
|
*/
|
|
|
|
nsresult AddCategoryEntryToHash(nsICategoryManager* aCategoryManager,
|
|
|
|
const char* aCategory,
|
|
|
|
nsISupports* aEntry);
|
|
|
|
|
2013-08-22 17:44:19 +04:00
|
|
|
/**
|
|
|
|
* Remove an existing category entry from the hash table.
|
|
|
|
* Only some categories can be removed (see the beginning of the definition).
|
|
|
|
* The other ones will be ignored.
|
|
|
|
*
|
|
|
|
* @aCategory Category where the entry will be removed from.
|
|
|
|
* @aEntry The entry that should be removed.
|
|
|
|
*/
|
|
|
|
nsresult RemoveCategoryEntryFromHash(nsICategoryManager* aCategoryManager,
|
|
|
|
const char* aCategory,
|
|
|
|
nsISupports* aEntry);
|
|
|
|
|
|
|
|
// common helper for AddCategoryEntryToHash and RemoveCategoryEntryFromHash
|
|
|
|
nsresult OperateCategoryEntryHash(nsICategoryManager* aCategoryManager,
|
|
|
|
const char* aCategory,
|
|
|
|
nsISupports* aEntry,
|
|
|
|
bool aRemove);
|
|
|
|
|
2015-05-20 02:46:17 +03:00
|
|
|
PLDHashTable mGlobalNames;
|
1998-12-21 19:51:10 +03:00
|
|
|
};
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
#endif /* nsScriptNameSpaceManager_h__ */
|