Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in netwerk. r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D104197
This commit is contained in:
Simon Giesecke 2021-02-09 18:19:37 +00:00
Родитель 8730386ad9
Коммит 5ab2e2fc52
2 изменённых файлов: 9 добавлений и 15 удалений

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

@ -136,16 +136,11 @@ nsresult ChildDNSService::AsyncResolveInternal(
nsCString key;
GetDNSRecordHashKey(hostname, DNSResolverInfo::URL(aResolver), type,
aOriginAttributes, flags, originalListenerAddr, key);
auto entry = mPendingRequests.LookupForAdd(key);
if (entry) {
entry.Data()->AppendElement(sender);
} else {
entry.OrInsert([&]() {
auto* hashEntry = new nsTArray<RefPtr<DNSRequestSender>>();
hashEntry->AppendElement(sender);
return hashEntry;
});
}
mPendingRequests.WithEntryHandle(key, [&](auto&& entry) {
entry
.OrInsertWith([] { return new nsTArray<RefPtr<DNSRequestSender>>(); })
->AppendElement(sender);
});
}
sender->StartRequest();

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

@ -1113,11 +1113,10 @@ void nsHttpTransaction::OnPush(Http2PushedStreamWrapper* aStream) {
return;
}
auto entry = mIDToStreamMap.LookupForAdd(stream->StreamID());
MOZ_ASSERT(!entry);
if (!entry) {
entry.OrInsert([&stream]() { return stream; });
}
mIDToStreamMap.WithEntryHandle(stream->StreamID(), [&](auto&& entry) {
MOZ_ASSERT(!entry);
entry.OrInsert(stream);
});
if (NS_FAILED(mOnPushCallback(stream->StreamID(), stream->GetResourceUrl(),
stream->GetRequestString(), this))) {