зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1682536 - Use references/NotNull for QuotaObject. r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D99780
This commit is contained in:
Родитель
3012a7db34
Коммит
b87d2b0662
|
@ -841,7 +841,7 @@ class OriginInfo final {
|
|||
|
||||
void LockedPersist();
|
||||
|
||||
nsDataHashtable<nsStringHashKey, QuotaObject*> mQuotaObjects;
|
||||
nsDataHashtable<nsStringHashKey, NotNull<QuotaObject*>> mQuotaObjects;
|
||||
ClientUsageArray mClientUsages;
|
||||
GroupInfo* mGroupInfo;
|
||||
const nsCString mOrigin;
|
||||
|
@ -4341,15 +4341,16 @@ already_AddRefed<QuotaObject> QuotaManager::GetQuotaObject(
|
|||
// We need this extra raw pointer because we can't assign to the smart
|
||||
// pointer directly since QuotaObject::AddRef would try to acquire the same
|
||||
// mutex.
|
||||
QuotaObject* quotaObject;
|
||||
if (!originInfo->mQuotaObjects.Get(path, "aObject)) {
|
||||
// Create a new QuotaObject.
|
||||
quotaObject = new QuotaObject(originInfo, aClientType, path, fileSize);
|
||||
|
||||
// Put it to the hashtable. The hashtable is not responsible to delete
|
||||
// the QuotaObject.
|
||||
originInfo->mQuotaObjects.Put(path, quotaObject);
|
||||
}
|
||||
const NotNull<QuotaObject*> quotaObject =
|
||||
originInfo->mQuotaObjects.WithEntryHandle(
|
||||
path, [&](auto&& entryHandle) {
|
||||
return entryHandle.OrInsertWith([&] {
|
||||
// Create a new QuotaObject. The hashtable is not responsible to
|
||||
// delete the QuotaObject.
|
||||
return WrapNotNullUnchecked(
|
||||
new QuotaObject(originInfo, aClientType, path, fileSize));
|
||||
});
|
||||
});
|
||||
|
||||
// Addref the QuotaObject and move the ownership to the result. This must
|
||||
// happen before we unlock!
|
||||
|
|
Загрузка…
Ссылка в новой задаче