Backed out changeset f156971f0f4d (bug 1074832) for Android crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 14 Oct 2014 12:41:43 -0400
changeset 210363 786d392dbb42659f0368e6b54706e6bb04fdf0a1
parent 210362 307181c1de8e61875ec22084b53b8f4c9328a25f
child 210364 da9a33e9383256f2ab8d8162769b6c8a7818acda
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs1074832
milestone36.0a1
backs outf156971f0f4df96b2c3c0debaebd956cd5c6d116
Backed out changeset f156971f0f4d (bug 1074832) for Android crashes. CLOSED TREE
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -48,30 +48,30 @@ public:
     , mOldFrecency(0)
     , mOldExpirationTime(nsICacheEntry::NO_EXPIRATION_TIME)
     , mDoNotSearchInIndex(false)
     , mDoNotSearchInUpdates(false)
   {
     mIndex->AssertOwnsLock();
 
     mHash = aHash;
-    const CacheIndexEntry *entry = FindEntry();
+    CacheIndexEntry *entry = FindEntry();
     mIndex->mIndexStats.BeforeChange(entry);
     if (entry && entry->IsInitialized() && !entry->IsRemoved()) {
       mOldRecord = entry->mRec;
       mOldFrecency = entry->mRec->mFrecency;
       mOldExpirationTime = entry->mRec->mExpirationTime;
     }
   }
 
   ~CacheIndexEntryAutoManage()
   {
     mIndex->AssertOwnsLock();
 
-    const CacheIndexEntry *entry = FindEntry();
+    CacheIndexEntry *entry = FindEntry();
     mIndex->mIndexStats.AfterChange(entry);
     if (!entry || !entry->IsInitialized() || entry->IsRemoved()) {
       entry = nullptr;
     }
 
     if (entry && !mOldRecord) {
       mIndex->InsertRecordToFrecencyArray(entry->mRec);
       mIndex->InsertRecordToExpirationArray(entry->mRec);
@@ -120,19 +120,19 @@ public:
   // We cannot rely on nsTHashtable::GetEntry() in case we are enumerating the
   // entries and returning PL_DHASH_REMOVE. Destructor is called before the
   // entry is removed. Caller must call one of following methods to skip
   // lookup in the hashtable.
   void DoNotSearchInIndex()   { mDoNotSearchInIndex = true; }
   void DoNotSearchInUpdates() { mDoNotSearchInUpdates = true; }
 
 private:
-  const CacheIndexEntry * FindEntry()
+  CacheIndexEntry * FindEntry()
   {
-    const CacheIndexEntry *entry = nullptr;
+    CacheIndexEntry *entry = nullptr;
 
     switch (mIndex->mState) {
       case CacheIndex::READING:
       case CacheIndex::WRITING:
         if (!mDoNotSearchInUpdates) {
           entry = mIndex->mPendingUpdates.GetEntry(*mHash);
         }
         // no break
@@ -515,17 +515,16 @@ CacheIndex::AddEntry(const SHA1Sum::Hash
   // non-fresh entries exists outside the scope of CacheIndexEntryAutoManage.
   bool updateIfNonFreshEntriesExist = false;
 
   {
     CacheIndexEntryAutoManage entryMng(aHash, index);
 
     CacheIndexEntry *entry = index->mIndex.GetEntry(*aHash);
     bool entryRemoved = entry && entry->IsRemoved();
-    CacheIndexEntryUpdate *updated = nullptr;
 
     if (index->mState == READY || index->mState == UPDATING ||
         index->mState == BUILDING) {
       MOZ_ASSERT(index->mPendingUpdates.Count() == 0);
 
       if (entry && !entryRemoved) {
         // Found entry in index that shouldn't exist.
 
@@ -554,17 +553,17 @@ CacheIndex::AddEntry(const SHA1Sum::Hash
           MOZ_ASSERT(index->mState == UPDATING);
         }
       }
 
       if (!entry) {
         entry = index->mIndex.PutEntry(*aHash);
       }
     } else { // WRITING, READING
-      updated = index->mPendingUpdates.GetEntry(*aHash);
+      CacheIndexEntry *updated = index->mPendingUpdates.GetEntry(*aHash);
       bool updatedRemoved = updated && updated->IsRemoved();
 
       if ((updated && !updatedRemoved) ||
           (!updated && entry && !entryRemoved && entry->IsFresh())) {
         // Fresh entry found, so the file was removed outside FF
         LOG(("CacheIndex::AddEntry() - Cache file was removed outside FF "
              "process!"));
 
@@ -574,27 +573,22 @@ CacheIndex::AddEntry(const SHA1Sum::Hash
           LOG(("CacheIndex::AddEntry() - Found entry that shouldn't exist, "
                "update is needed"));
           index->mIndexNeedsUpdate = true;
         }
         // Ignore if state is READING since the index information is partial
       }
 
       updated = index->mPendingUpdates.PutEntry(*aHash);
+      entry = updated;
     }
 
-    if (updated) {
-      updated->InitNew();
-      updated->MarkDirty();
-      updated->MarkFresh();
-    } else {
-      entry->InitNew();
-      entry->MarkDirty();
-      entry->MarkFresh();
-    }
+    entry->InitNew();
+    entry->MarkDirty();
+    entry->MarkFresh();
   }
 
   if (updateIfNonFreshEntriesExist &&
       index->mIndexStats.Count() != index->mIndexStats.Fresh()) {
     index->mIndexNeedsUpdate = true;
   }
 
   index->StartUpdatingIndexIfNeeded();
@@ -653,17 +647,17 @@ CacheIndex::EnsureEntryExists(const SHA1
         if (!entry) {
           entry = index->mIndex.PutEntry(*aHash);
         }
         entry->InitNew();
         entry->MarkDirty();
       }
       entry->MarkFresh();
     } else { // WRITING, READING
-      CacheIndexEntryUpdate *updated = index->mPendingUpdates.GetEntry(*aHash);
+      CacheIndexEntry *updated = index->mPendingUpdates.GetEntry(*aHash);
       bool updatedRemoved = updated && updated->IsRemoved();
 
       if (updatedRemoved ||
           (!updated && entryRemoved && entry->IsFresh())) {
         // Fresh information about missing entry found. This could happen only
         // if somebody copies files to the entries directory while FF is running.
         LOG(("CacheIndex::EnsureEntryExists() - Cache file was added outside "
              "FF process! Update is needed."));
@@ -733,17 +727,16 @@ CacheIndex::InitEntry(const SHA1Sum::Has
   if (!index->IsIndexUsable()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   {
     CacheIndexEntryAutoManage entryMng(aHash, index);
 
     CacheIndexEntry *entry = index->mIndex.GetEntry(*aHash);
-    CacheIndexEntryUpdate *updated = nullptr;
     bool reinitEntry = false;
 
     if (entry && entry->IsRemoved()) {
       entry = nullptr;
     }
 
     if (index->mState == READY || index->mState == UPDATING ||
         index->mState == BUILDING) {
@@ -755,70 +748,61 @@ CacheIndex::InitEntry(const SHA1Sum::Has
         index->mIndexNeedsUpdate = true; // TODO Does this really help in case of collision?
         reinitEntry = true;
       } else {
         if (entry->IsInitialized()) {
           return NS_OK;
         }
       }
     } else {
-      updated = index->mPendingUpdates.GetEntry(*aHash);
+      CacheIndexEntry *updated = index->mPendingUpdates.GetEntry(*aHash);
       DebugOnly<bool> removed = updated && updated->IsRemoved();
 
       MOZ_ASSERT(updated || !removed);
       MOZ_ASSERT(updated || entry);
 
       if (updated) {
         MOZ_ASSERT(updated->IsFresh());
 
         if (IsCollision(updated, aAppId, aAnonymous, aInBrowser)) {
           index->mIndexNeedsUpdate = true;
           reinitEntry = true;
         } else {
           if (updated->IsInitialized()) {
             return NS_OK;
           }
         }
+        entry = updated;
       } else {
         MOZ_ASSERT(entry->IsFresh());
 
         if (IsCollision(entry, aAppId, aAnonymous, aInBrowser)) {
           index->mIndexNeedsUpdate = true;
           reinitEntry = true;
         } else {
           if (entry->IsInitialized()) {
             return NS_OK;
           }
         }
 
         // make a copy of a read-only entry
         updated = index->mPendingUpdates.PutEntry(*aHash);
         *updated = *entry;
+        entry = updated;
       }
     }
 
     if (reinitEntry) {
       // There is a collision and we are going to rewrite this entry. Initialize
       // it as a new entry.
-      if (updated) {
-        updated->InitNew();
-        updated->MarkFresh();
-      } else {
-        entry->InitNew();
-        entry->MarkFresh();
-      }
+      entry->InitNew();
+      entry->MarkFresh();
     }
-
-    if (updated) {
-      updated->Init(aAppId, aAnonymous, aInBrowser);
-      updated->MarkDirty();
-    } else {
-      entry->Init(aAppId, aAnonymous, aInBrowser);
-      entry->MarkDirty();
-    }
+    entry->Init(aAppId, aAnonymous, aInBrowser);
+    entry->MarkDirty();
   }
 
   index->StartUpdatingIndexIfNeeded();
   index->WriteIndexToDiskIfNeeded();
 
   return NS_OK;
 }
 
@@ -876,17 +860,17 @@ CacheIndex::RemoveEntry(const SHA1Sum::H
           } else {
             entry->MarkRemoved();
             entry->MarkDirty();
             entry->MarkFresh();
           }
         }
       }
     } else { // WRITING, READING
-      CacheIndexEntryUpdate *updated = index->mPendingUpdates.GetEntry(*aHash);
+      CacheIndexEntry *updated = index->mPendingUpdates.GetEntry(*aHash);
       bool updatedRemoved = updated && updated->IsRemoved();
 
       if (updatedRemoved ||
           (!updated && entryRemoved && entry->IsFresh())) {
         // Fresh information about missing entry found. This could happen only
         // if somebody copies files to the entries directory while FF is running.
         LOG(("CacheIndex::RemoveEntry() - Cache file was added outside FF "
              "process! Update is needed."));
@@ -956,68 +940,52 @@ CacheIndex::UpdateEntry(const SHA1Sum::H
     if (index->mState == READY || index->mState == UPDATING ||
         index->mState == BUILDING) {
       MOZ_ASSERT(index->mPendingUpdates.Count() == 0);
       MOZ_ASSERT(entry);
 
       if (!HasEntryChanged(entry, aFrecency, aExpirationTime, aSize)) {
         return NS_OK;
       }
-
-      MOZ_ASSERT(entry->IsFresh());
-      MOZ_ASSERT(entry->IsInitialized());
-      entry->MarkDirty();
-
-      if (aFrecency) {
-        entry->SetFrecency(*aFrecency);
-      }
-
-      if (aExpirationTime) {
-        entry->SetExpirationTime(*aExpirationTime);
-      }
-
-      if (aSize) {
-        entry->SetFileSize(*aSize);
-      }
     } else {
-      CacheIndexEntryUpdate *updated = index->mPendingUpdates.GetEntry(*aHash);
+      CacheIndexEntry *updated = index->mPendingUpdates.GetEntry(*aHash);
       DebugOnly<bool> removed = updated && updated->IsRemoved();
 
       MOZ_ASSERT(updated || !removed);
       MOZ_ASSERT(updated || entry);
 
       if (!updated) {
-        if (!entry) {
-          LOG(("CacheIndex::UpdateEntry() - Entry was found neither in mIndex "
-               "nor in mPendingUpdates!"));
-          NS_WARNING(("CacheIndex::UpdateEntry() - Entry was found neither in "
-                      "mIndex nor in mPendingUpdates!"));
+        if (entry &&
+            HasEntryChanged(entry, aFrecency, aExpirationTime, aSize)) {
+          // make a copy of a read-only entry
+          updated = index->mPendingUpdates.PutEntry(*aHash);
+          *updated = *entry;
+          entry = updated;
+        } else {
           return NS_ERROR_NOT_AVAILABLE;
         }
-
-        // make a copy of a read-only entry
-        updated = index->mPendingUpdates.PutEntry(*aHash);
-        *updated = *entry;
+      } else {
+        entry = updated;
       }
-
-      MOZ_ASSERT(updated->IsFresh());
-      MOZ_ASSERT(updated->IsInitialized());
-      updated->MarkDirty();
-
-      if (aFrecency) {
-        updated->SetFrecency(*aFrecency);
-      }
-
-      if (aExpirationTime) {
-        updated->SetExpirationTime(*aExpirationTime);
-      }
-
-      if (aSize) {
-        updated->SetFileSize(*aSize);
-      }
+    }
+
+    MOZ_ASSERT(entry->IsFresh());
+    MOZ_ASSERT(entry->IsInitialized());
+    entry->MarkDirty();
+
+    if (aFrecency) {
+      entry->SetFrecency(*aFrecency);
+    }
+
+    if (aExpirationTime) {
+      entry->SetExpirationTime(*aExpirationTime);
+    }
+
+    if (aSize) {
+      entry->SetFileSize(*aSize);
     }
   }
 
   index->WriteIndexToDiskIfNeeded();
 
   return NS_OK;
 }
 
@@ -1123,17 +1091,17 @@ CacheIndex::HasEntry(const nsACString &a
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   SHA1Sum sum;
   SHA1Sum::Hash hash;
   sum.update(aKey.BeginReading(), aKey.Length());
   sum.finish(hash);
 
-  const CacheIndexEntry *entry = nullptr;
+  CacheIndexEntry *entry = nullptr;
 
   switch (index->mState) {
     case READING:
     case WRITING:
       entry = index->mPendingUpdates.GetEntry(hash);
       // no break
     case BUILDING:
     case UPDATING:
@@ -1508,17 +1476,17 @@ CacheIndex::ProcessPendingOperations()
 
   MOZ_ASSERT(mPendingUpdates.Count() == 0);
 
   EnsureCorrectStats();
 }
 
 // static
 PLDHashOperator
-CacheIndex::UpdateEntryInIndex(CacheIndexEntryUpdate *aEntry, void* aClosure)
+CacheIndex::UpdateEntryInIndex(CacheIndexEntry *aEntry, void* aClosure)
 {
   CacheIndex *index = static_cast<CacheIndex *>(aClosure);
 
   LOG(("CacheFile::UpdateEntryInIndex() [hash=%08x%08x%08x%08x%08x]",
        LOGSHA1(aEntry->Hash())));
 
   MOZ_ASSERT(aEntry->IsFresh());
 
@@ -1543,26 +1511,18 @@ CacheIndex::UpdateEntryInIndex(CacheInde
         entry->MarkDirty();
         entry->MarkFresh();
       }
     }
 
     return PL_DHASH_REMOVE;
   }
 
-  if (entry) {
-    // Some information in mIndex can be newer than in mPendingUpdates (see bug
-    // 1074832). This will copy just those values that were really updated.
-    aEntry->ApplyUpdate(entry);
-  } else {
-    // There is no entry in mIndex, copy all information from mPendingUpdates
-    // to mIndex.
-    entry = index->mIndex.PutEntry(*aEntry->Hash());
-    *entry = *aEntry;
-  }
+  entry = index->mIndex.PutEntry(*aEntry->Hash());
+  *entry = *aEntry;
 
   return PL_DHASH_REMOVE;
 }
 
 bool
 CacheIndex::WriteIndexToDiskIfNeeded()
 {
   if (mState != READY || mShuttingDown) {
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -161,61 +161,61 @@ public:
     if (aAnonymous) {
       mRec->mFlags |= kAnonymousMask;
     }
     if (aInBrowser) {
       mRec->mFlags |= kInBrowserMask;
     }
   }
 
-  const SHA1Sum::Hash * Hash() const { return &mRec->mHash; }
+  const SHA1Sum::Hash * Hash() { return &mRec->mHash; }
 
-  bool IsInitialized() const { return !!(mRec->mFlags & kInitializedMask); }
+  bool IsInitialized() { return !!(mRec->mFlags & kInitializedMask); }
 
-  uint32_t AppId() const { return mRec->mAppId; }
-  bool     Anonymous() const { return !!(mRec->mFlags & kAnonymousMask); }
-  bool     InBrowser() const { return !!(mRec->mFlags & kInBrowserMask); }
+  uint32_t AppId() { return mRec->mAppId; }
+  bool     Anonymous() { return !!(mRec->mFlags & kAnonymousMask); }
+  bool     InBrowser() { return !!(mRec->mFlags & kInBrowserMask); }
 
-  bool IsRemoved() const { return !!(mRec->mFlags & kRemovedMask); }
+  bool IsRemoved() { return !!(mRec->mFlags & kRemovedMask); }
   void MarkRemoved() { mRec->mFlags |= kRemovedMask; }
 
-  bool IsDirty() const { return !!(mRec->mFlags & kDirtyMask); }
+  bool IsDirty() { return !!(mRec->mFlags & kDirtyMask); }
   void MarkDirty() { mRec->mFlags |= kDirtyMask; }
   void ClearDirty() { mRec->mFlags &= ~kDirtyMask; }
 
-  bool IsFresh() const { return !!(mRec->mFlags & kFreshMask); }
+  bool IsFresh() { return !!(mRec->mFlags & kFreshMask); }
   void MarkFresh() { mRec->mFlags |= kFreshMask; }
 
   void     SetFrecency(uint32_t aFrecency) { mRec->mFrecency = aFrecency; }
-  uint32_t GetFrecency() const { return mRec->mFrecency; }
+  uint32_t GetFrecency() { return mRec->mFrecency; }
 
   void     SetExpirationTime(uint32_t aExpirationTime)
   {
     mRec->mExpirationTime = aExpirationTime;
   }
-  uint32_t GetExpirationTime() const { return mRec->mExpirationTime; }
+  uint32_t GetExpirationTime() { return mRec->mExpirationTime; }
 
   // Sets filesize in kilobytes.
   void     SetFileSize(uint32_t aFileSize)
   {
     if (aFileSize > kFileSizeMask) {
       LOG(("CacheIndexEntry::SetFileSize() - FileSize is too large, "
            "truncating to %u", kFileSizeMask));
       aFileSize = kFileSizeMask;
     }
     mRec->mFlags &= ~kFileSizeMask;
     mRec->mFlags |= aFileSize;
   }
   // Returns filesize in kilobytes.
-  uint32_t GetFileSize() const { return GetFileSize(mRec); }
+  uint32_t GetFileSize() { return GetFileSize(mRec); }
   static uint32_t GetFileSize(CacheIndexRecord *aRec)
   {
     return aRec->mFlags & kFileSizeMask;
   }
-  bool     IsFileEmpty() const { return GetFileSize() == 0; }
+  bool     IsFileEmpty() { return GetFileSize() == 0; }
 
   void WriteToBuf(void *aBuf)
   {
     CacheIndexRecord *dst = reinterpret_cast<CacheIndexRecord *>(aBuf);
 
     // Copy the whole record to the buffer.
     memcpy(aBuf, mRec, sizeof(CacheIndexRecord));
 
@@ -241,17 +241,17 @@ public:
                sizeof(SHA1Sum::Hash)) == 0);
 
     mRec->mFrecency = NetworkEndian::readUint32(&src->mFrecency);
     mRec->mExpirationTime = NetworkEndian::readUint32(&src->mExpirationTime);
     mRec->mAppId = NetworkEndian::readUint32(&src->mAppId);
     mRec->mFlags = NetworkEndian::readUint32(&src->mFlags);
   }
 
-  void Log() const {
+  void Log() {
     LOG(("CacheIndexEntry::Log() [this=%p, hash=%08x%08x%08x%08x%08x, fresh=%u,"
          " initialized=%u, removed=%u, dirty=%u, anonymous=%u, inBrowser=%u, "
          "appId=%u, frecency=%u, expirationTime=%u, size=%u]",
          this, LOGSHA1(mRec->mHash), IsFresh(), IsInitialized(), IsRemoved(),
          IsDirty(), Anonymous(), InBrowser(), AppId(), GetFrecency(),
          GetExpirationTime(), GetFileSize()));
   }
 
@@ -275,17 +275,16 @@ public:
   }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const
   {
     return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf);
   }
 
 private:
-  friend class CacheIndexEntryUpdate;
   friend class CacheIndex;
   friend class CacheIndexEntryAutoManage;
 
   static const uint32_t kInitializedMask = 0x80000000;
   static const uint32_t kAnonymousMask   = 0x40000000;
   static const uint32_t kInBrowserMask   = 0x20000000;
 
   // This flag is set when the entry was removed. We need to keep this
@@ -304,92 +303,16 @@ private:
   static const uint32_t kReservedMask    = 0x03000000;
 
   // FileSize in kilobytes
   static const uint32_t kFileSizeMask    = 0x00FFFFFF;
 
   nsAutoPtr<CacheIndexRecord> mRec;
 };
 
-class CacheIndexEntryUpdate : public CacheIndexEntry
-{
-public:
-  explicit CacheIndexEntryUpdate(CacheIndexEntry::KeyTypePointer aKey)
-    : CacheIndexEntry(aKey)
-    , mUpdateFlags(0)
-  {
-    MOZ_COUNT_CTOR(CacheIndexEntryUpdate);
-    LOG(("CacheIndexEntryUpdate::CacheIndexEntryUpdate()"));
-  }
-  ~CacheIndexEntryUpdate()
-  {
-    MOZ_COUNT_DTOR(CacheIndexEntryUpdate);
-    LOG(("CacheIndexEntryUpdate::~CacheIndexEntryUpdate()"));
-  }
-
-  CacheIndexEntryUpdate& operator=(const CacheIndexEntry& aOther)
-  {
-    MOZ_ASSERT(memcmp(&mRec->mHash, &aOther.mRec->mHash,
-               sizeof(SHA1Sum::Hash)) == 0);
-    mUpdateFlags = 0;
-    *(static_cast<CacheIndexEntry *>(this)) = aOther;
-    return *this;
-  }
-
-  void InitNew()
-  {
-    mUpdateFlags = 0;
-    CacheIndexEntry::InitNew();
-  }
-
-  void SetFrecency(uint32_t aFrecency)
-  {
-    mUpdateFlags |= kFrecencyUpdatedMask;
-    CacheIndexEntry::SetFrecency(aFrecency);
-  }
-
-  void SetExpirationTime(uint32_t aExpirationTime)
-  {
-    mUpdateFlags |= kExpirationUpdatedMask;
-    CacheIndexEntry::SetExpirationTime(aExpirationTime);
-  }
-
-  void SetFileSize(uint32_t aFileSize)
-  {
-    mUpdateFlags |= kFileSizeUpdatedMask;
-    CacheIndexEntry::SetFileSize(aFileSize);
-  }
-
-  void ApplyUpdate(CacheIndexEntry *aDst) {
-    MOZ_ASSERT(memcmp(&mRec->mHash, &aDst->mRec->mHash,
-               sizeof(SHA1Sum::Hash)) == 0);
-    if (mUpdateFlags & kFrecencyUpdatedMask) {
-      aDst->mRec->mFrecency = mRec->mFrecency;
-    }
-    if (mUpdateFlags & kExpirationUpdatedMask) {
-      aDst->mRec->mExpirationTime = mRec->mExpirationTime;
-    }
-    aDst->mRec->mAppId = mRec->mAppId;
-    if (mUpdateFlags & kFileSizeUpdatedMask) {
-      aDst->mRec->mFlags = mRec->mFlags;
-    } else {
-      // Copy all flags except file size.
-      aDst->mRec->mFlags &= kFileSizeMask;
-      aDst->mRec->mFlags |= (mRec->mFlags & ~kFileSizeMask);
-    }
-  }
-
-private:
-  static const uint32_t kFrecencyUpdatedMask = 0x00000001;
-  static const uint32_t kExpirationUpdatedMask = 0x00000002;
-  static const uint32_t kFileSizeUpdatedMask = 0x00000004;
-
-  uint32_t mUpdateFlags;
-};
-
 class CacheIndexStats
 {
 public:
   CacheIndexStats()
     : mCount(0)
     , mNotInitialized(0)
     , mRemoved(0)
     , mDirty(0)
@@ -469,17 +392,17 @@ public:
     return mCount - mRemoved - mNotInitialized - mEmpty;
   }
 
   uint32_t Size() {
     MOZ_ASSERT(!mStateLogged, "CacheIndexStats::Size() - state logged!");
     return mSize;
   }
 
-  void BeforeChange(const CacheIndexEntry *aEntry) {
+  void BeforeChange(CacheIndexEntry *aEntry) {
 #ifdef DEBUG_STATS
     if (!mDisableLogging) {
       LOG(("CacheIndexStats::BeforeChange()"));
       Log();
     }
 #endif
 
     MOZ_ASSERT(!mStateLogged, "CacheIndexStats::BeforeChange() - state "
@@ -513,17 +436,17 @@ public:
             MOZ_ASSERT(mSize >= aEntry->GetFileSize());
             mSize -= aEntry->GetFileSize();
           }
         }
       }
     }
   }
 
-  void AfterChange(const CacheIndexEntry *aEntry) {
+  void AfterChange(CacheIndexEntry *aEntry) {
     MOZ_ASSERT(mStateLogged, "CacheIndexStats::AfterChange() - state not "
                "logged!");
 #ifdef DEBUG
     mStateLogged = false;
 #endif
     if (aEntry) {
       ++mCount;
       if (aEntry->IsDirty()) {
@@ -714,17 +637,17 @@ private:
   // Checks whether any of the information about the entry has changed.
   static bool HasEntryChanged(CacheIndexEntry *aEntry,
                               const uint32_t  *aFrecency,
                               const uint32_t  *aExpirationTime,
                               const uint32_t  *aSize);
 
   // Merge all pending operations from mPendingUpdates into mIndex.
   void ProcessPendingOperations();
-  static PLDHashOperator UpdateEntryInIndex(CacheIndexEntryUpdate *aEntry,
+  static PLDHashOperator UpdateEntryInIndex(CacheIndexEntry *aEntry,
                                             void* aClosure);
 
   // Following methods perform writing of the index file.
   //
   // The index is written periodically, but not earlier than once in
   // kMinDumpInterval and there must be at least kMinUnwrittenChanges
   // differences between index on disk and in memory. Index is always first
   // written to a temporary file and the old index file is replaced when the
@@ -1001,17 +924,17 @@ private:
   // Directory enumerator used when building and updating index.
   nsCOMPtr<nsIDirectoryEnumerator> mDirEnumerator;
 
   // Main index hashtable.
   nsTHashtable<CacheIndexEntry> mIndex;
 
   // We cannot add, remove or change any entry in mIndex in states READING and
   // WRITING. We track all changes in mPendingUpdates during these states.
-  nsTHashtable<CacheIndexEntryUpdate> mPendingUpdates;
+  nsTHashtable<CacheIndexEntry> mPendingUpdates;
 
   // Contains information statistics for mIndex + mPendingUpdates.
   CacheIndexStats               mIndexStats;
 
   // When reading journal, we must first parse the whole file and apply the
   // changes iff the journal was read successfully. mTmpJournal is used to store
   // entries from the journal file. We throw away all these entries if parsing
   // of the journal fails or the hash does not match.