Bug 1682536 - Use references/NotNull in Manager. r=dom-workers-and-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D99776
This commit is contained in:
Simon Giesecke 2020-12-17 16:14:43 +00:00
parent 4756746f18
commit 641ad4b8f6
3 changed files with 9 additions and 11 deletions

10
dom/cache/Manager.cpp vendored
View File

@ -1804,16 +1804,14 @@ void Manager::ReleaseBodyId(const nsID& aBodyId) {
const ManagerId& Manager::GetManagerId() const { return *mManagerId; }
void Manager::AddStreamList(StreamList* aStreamList) {
void Manager::AddStreamList(StreamList& aStreamList) {
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_DIAGNOSTIC_ASSERT(aStreamList);
mStreamLists.AppendElement(aStreamList);
mStreamLists.AppendElement(WrapNotNullUnchecked(&aStreamList));
}
void Manager::RemoveStreamList(StreamList* aStreamList) {
void Manager::RemoveStreamList(StreamList& aStreamList) {
NS_ASSERT_OWNINGTHREAD(Manager);
MOZ_DIAGNOSTIC_ASSERT(aStreamList);
mStreamLists.RemoveElement(aStreamList);
mStreamLists.RemoveElement(&aStreamList);
}
void Manager::ExecuteCacheOp(Listener* aListener, CacheId aCacheId,

6
dom/cache/Manager.h vendored
View File

@ -177,8 +177,8 @@ class Manager final : public SafeRefCounted<Manager> {
// Methods to allow a StreamList to register themselves with the Manager.
// StreamList objects must call RemoveStreamList() before they are destroyed.
void AddStreamList(StreamList* aStreamList);
void RemoveStreamList(StreamList* aStreamList);
void AddStreamList(StreamList& aStreamList);
void RemoveStreamList(StreamList& aStreamList);
void ExecuteCacheOp(Listener* aListener, CacheId aCacheId,
const CacheOpArgs& aOpArgs);
@ -268,7 +268,7 @@ class Manager final : public SafeRefCounted<Manager> {
static ListenerId sNextListenerId;
// Weak references cleared by RemoveStreamList() in StreamList destructors.
nsTArray<StreamList*> mStreamLists;
nsTArray<NotNull<StreamList*>> mStreamLists;
bool mShuttingDown;
State mState;

View File

@ -74,7 +74,7 @@ void StreamList::Activate(CacheId aCacheId) {
mActivated = true;
mCacheId = aCacheId;
mManager->AddRefCacheId(mCacheId);
mManager->AddStreamList(this);
mManager->AddStreamList(*this);
for (uint32_t i = 0; i < mList.Length(); ++i) {
mManager->AddRefBodyId(mList[i].mId);
@ -149,7 +149,7 @@ StreamList::~StreamList() {
NS_ASSERT_OWNINGTHREAD(StreamList);
MOZ_DIAGNOSTIC_ASSERT(!mStreamControl);
if (mActivated) {
mManager->RemoveStreamList(this);
mManager->RemoveStreamList(*this);
for (uint32_t i = 0; i < mList.Length(); ++i) {
mManager->ReleaseBodyId(mList[i].mId);
}