Bug 993194, part 5 - Change nsNodeInfoManager::mPrincipal into an nsCOMPtr. r=smaug

This commit is contained in:
Andrew McCreight 2014-04-10 07:05:20 -07:00
Родитель e8c627b9d1
Коммит 368782d1e6
2 изменённых файлов: 6 добавлений и 9 удалений

Просмотреть файл

@ -113,7 +113,6 @@ static PLHashAllocOps allocOps =
nsNodeInfoManager::nsNodeInfoManager()
: mDocument(nullptr),
mNonDocumentNodeInfos(0),
mPrincipal(nullptr),
mTextNodeInfo(nullptr),
mCommentNodeInfo(nullptr),
mDocumentNodeInfo(nullptr)
@ -141,7 +140,7 @@ nsNodeInfoManager::~nsNodeInfoManager()
PL_HashTableDestroy(mNodeInfoHash);
// Note: mPrincipal may be null here if we never got inited correctly
NS_IF_RELEASE(mPrincipal);
mPrincipal = nullptr;
mBindingManager = nullptr;
@ -179,8 +178,8 @@ nsNodeInfoManager::Init(nsIDocument *aDocument)
NS_PRECONDITION(!mPrincipal,
"Being inited when we already have a principal?");
nsresult rv = CallCreateInstance("@mozilla.org/nullprincipal;1",
&mPrincipal);
nsresult rv;
mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_TRUE(mPrincipal, rv);
if (aDocument) {
@ -386,14 +385,14 @@ nsNodeInfoManager::GetDocumentNodeInfo()
void
nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal *aPrincipal)
{
NS_RELEASE(mPrincipal);
mPrincipal = nullptr;
if (!aPrincipal) {
aPrincipal = mDefaultPrincipal;
}
NS_ASSERTION(aPrincipal, "Must have principal by this point!");
NS_ADDREF(mPrincipal = aPrincipal);
mPrincipal = aPrincipal;
}
void

Просмотреть файл

@ -126,9 +126,7 @@ private:
PLHashTable *mNodeInfoHash;
nsIDocument *mDocument; // WEAK
uint32_t mNonDocumentNodeInfos;
nsIPrincipal *mPrincipal; // STRONG, but not nsCOMPtr to avoid include hell
// while inlining DocumentPrincipal(). Never null
// after Init() succeeds.
nsCOMPtr<nsIPrincipal> mPrincipal; // Never null after Init() succeeds.
nsCOMPtr<nsIPrincipal> mDefaultPrincipal; // Never null after Init() succeeds
nsINodeInfo *mTextNodeInfo; // WEAK to avoid circular ownership
nsINodeInfo *mCommentNodeInfo; // WEAK to avoid circular ownership