зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
8730386ad9
Коммит
5ab2e2fc52
|
@ -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))) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче