Bug 1434206 - Make TableUpdate objects const as much as possible. r=gcp

I tried to make TableUpdateArray point to const TableUpdate objects
everywhere but there were two problems:

- HashStore::ApplyUpdate() triggers a few Merge() calls which include
  sorting the underlying TableUpdate object first.

- LookupCacheV4::ApplyUpdate() calls TableUpdateV4::NewChecksum() when the
  checksum is missing and that sets mChecksum.

MozReview-Commit-ID: LIhJcoxo7e7
This commit is contained in:
Francois Marier
2018-05-11 16:02:37 -07:00
parent ef8ea55aca
commit b910cbbb34
10 changed files with 33 additions and 27 deletions

View File

@@ -282,7 +282,7 @@ LookupCacheV4::ApplyUpdate(RefPtr<TableUpdateV4> aTableUpdate,
// remove from the old prefix set(according to lexigraphic order).
// |removalIndex| is the current index of RemovalIndiceArray.
// |numOldPrefixPicked| is used to record how many prefixes we picked from the old map.
TableUpdateV4::RemovalIndiceArray& removalArray = aTableUpdate->RemovalIndices();
const TableUpdateV4::RemovalIndiceArray& removalArray = aTableUpdate->RemovalIndices();
uint32_t removalIndex = 0;
int32_t numOldPrefixPicked = -1;
@@ -525,7 +525,7 @@ ReadValue(nsIInputStream* aInputStream, T& aValue)
////////////////////////////////////////////////////////////////////////
nsresult
LookupCacheV4::WriteMetadata(TableUpdateV4* aTableUpdate)
LookupCacheV4::WriteMetadata(RefPtr<const TableUpdateV4> aTableUpdate)
{
NS_ENSURE_ARG_POINTER(aTableUpdate);
if (nsUrlClassifierDBService::ShutdownHasStarted()) {