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

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

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