Commit 99c554d8 authored by Simon Giesecke's avatar Simon Giesecke
Browse files

Bug 1596129 - Introduce DatabaseNameMatchPredicate function to reduce code...

Bug 1596129 - Introduce DatabaseNameMatchPredicate function to reduce code duplication. r=dom-workers-and-storage-reviewers,ytausky

Depends on D52874

Differential Revision: https://phabricator.services.mozilla.com/D52875

--HG--
extra : moz-landing-system : lando
parent 445f39a1
......@@ -209,6 +209,13 @@ void MaxPreloadExtraRecordsPrefChangeCallback(const char* aPrefName,
// require adaptations in ActorsParent.cpp
}
auto DatabaseNameMatchPredicate(const nsAString* const aName) {
MOZ_ASSERT(aName);
return [aName](const auto& fileManager) {
return fileManager->DatabaseName() == *aName;
};
}
} // namespace
IndexedDatabaseManager::IndexedDatabaseManager()
......@@ -864,9 +871,7 @@ already_AddRefed<FileManager> FileManagerInfo::GetFileManager(
const auto end = managers.cend();
const auto foundIt =
std::find_if(managers.cbegin(), end, [&aName](const auto& fileManager) {
return fileManager->DatabaseName() == aName;
});
std::find_if(managers.cbegin(), end, DatabaseNameMatchPredicate(&aName));
return foundIt != end ? RefPtr<FileManager>{*foundIt}.forget() : nullptr;
}
......@@ -919,9 +924,7 @@ void FileManagerInfo::InvalidateAndRemoveFileManager(
auto& managers = GetArray(aPersistenceType);
const auto end = managers.cend();
const auto foundIt =
std::find_if(managers.cbegin(), end, [&aName](const auto& fileManager) {
return fileManager->DatabaseName() == aName;
});
std::find_if(managers.cbegin(), end, DatabaseNameMatchPredicate(&aName));
if (foundIt != end) {
(*foundIt)->Invalidate();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment