Skip to content

Commit

Permalink
Bug 1866402 - Update the cached value in PersistOp::DoDirectoryWork o…
Browse files Browse the repository at this point in the history
…nly when the value changed in the metadata file; r=dom-storage-reviewers,jari

Currently, we call QuotaManager::PersistOrigin even when the origin was already
persisted. QuotaManager::PersistOrigin won't try to update the value again,
but it will have to do a hash lookup. We can easilly avoid this by calling
QuotaManager::PersistOrigin only when the value changed in the metadata file.

Differential Revision: https://phabricator.services.mozilla.com/D198668
  • Loading branch information
janvarga committed Oct 12, 2024
1 parent 8ffcbdd commit 33f6a95
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dom/quota/OriginOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3151,12 +3151,14 @@ nsresult PersistOp::DoDirectoryWork(QuotaManager& aQuotaManager) {

// Set the persisted flag to true.
QM_TRY(MOZ_TO_RESULT(stream->WriteBoolean(true)));
}

// Directory metadata has been successfully updated.
// Update OriginInfo too if temporary storage was already initialized.
if (aQuotaManager.IsTemporaryStorageInitializedInternal()) {
aQuotaManager.PersistOrigin(originMetadata);
QM_TRY(MOZ_TO_RESULT(stream->Close()));

// Directory metadata has been successfully updated.
// Update OriginInfo too if temporary storage was already initialized.
if (aQuotaManager.IsTemporaryStorageInitializedInternal()) {
aQuotaManager.PersistOrigin(originMetadata);
}
}
}

Expand Down

0 comments on commit 33f6a95

Please sign in to comment.