Backed out changeset bd16c2fde4bf (bug 1201042) for bc test failures
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 07 Nov 2016 12:58:23 +0100
changeset 366494 dbc272fdb23832d038eed46de9227c6e192a07a5
parent 366493 e8669d6d4b436de48a73bb913ce0d9e23e33b92d
child 366495 86f702229e32c6119d092e86431afee576f033a1
child 366526 d2ad6e38524035a9461e7473cc674875e1fd2a20
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1201042
milestone52.0a1
backs outbd16c2fde4bfec3766027861d8149ed13e418def
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset bd16c2fde4bf (bug 1201042) for bc test failures
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheFileIOManager.h
netwerk/cache2/CacheHashUtils.cpp
netwerk/cache2/CacheHashUtils.h
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -2295,19 +2295,22 @@ CacheFile::InitIndexEntry()
 {
   MOZ_ASSERT(mHandle);
 
   if (mHandle->IsDoomed())
     return NS_OK;
 
   nsresult rv;
 
-  rv = CacheFileIOManager::InitIndexEntry(
-         mHandle, GetOriginAttrsHash(mMetadata->OriginAttributes()),
-         mMetadata->IsAnonymous(), mPinned);
+  // Bug 1201042 - will pass OriginAttributes directly.
+  rv = CacheFileIOManager::InitIndexEntry(mHandle,
+                                          mMetadata->OriginAttributes().mAppId,
+                                          mMetadata->IsAnonymous(),
+                                          mMetadata->OriginAttributes().mInIsolatedMozBrowser,
+                                          mPinned);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t expTime;
   mMetadata->GetExpirationTime(&expTime);
 
   uint32_t frecency;
   mMetadata->GetFrecency(&frecency);
 
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -960,22 +960,22 @@ public:
 protected:
   RefPtr<CacheFileHandle>       mHandle;
   nsCString                     mNewName;
   nsCOMPtr<CacheFileIOListener> mCallback;
 };
 
 class InitIndexEntryEvent : public Runnable {
 public:
-  InitIndexEntryEvent(CacheFileHandle *aHandle,
-                      OriginAttrsHash aOriginAttrsHash, bool aAnonymous,
-                      bool aPinning)
+  InitIndexEntryEvent(CacheFileHandle *aHandle, uint32_t aAppId,
+                      bool aAnonymous, bool aInIsolatedMozBrowser, bool aPinning)
     : mHandle(aHandle)
-    , mOriginAttrsHash(aOriginAttrsHash)
+    , mAppId(aAppId)
     , mAnonymous(aAnonymous)
+    , mInIsolatedMozBrowser(aInIsolatedMozBrowser)
     , mPinning(aPinning)
   {
     MOZ_COUNT_CTOR(InitIndexEntryEvent);
   }
 
 protected:
   ~InitIndexEntryEvent()
   {
@@ -984,34 +984,34 @@ protected:
 
 public:
   NS_IMETHOD Run() override
   {
     if (mHandle->IsClosed() || mHandle->IsDoomed()) {
       return NS_OK;
     }
 
-    CacheIndex::InitEntry(mHandle->Hash(), mOriginAttrsHash, mAnonymous,
-                          mPinning);
+    CacheIndex::InitEntry(mHandle->Hash(), mAppId, mAnonymous, mInIsolatedMozBrowser, mPinning);
 
     // We cannot set the filesize before we init the entry. If we're opening
     // an existing entry file, frecency and expiration time will be set after
     // parsing the entry file, but we must set the filesize here since nobody is
     // going to set it if there is no write to the file.
     uint32_t sizeInK = mHandle->FileSizeInK();
     CacheIndex::UpdateEntry(mHandle->Hash(), nullptr, nullptr, &sizeInK);
 
     return NS_OK;
   }
 
 protected:
   RefPtr<CacheFileHandle> mHandle;
-  OriginAttrsHash         mOriginAttrsHash;
-  bool                    mAnonymous;
-  bool                    mPinning;
+  uint32_t                  mAppId;
+  bool                      mAnonymous;
+  bool                      mInIsolatedMozBrowser;
+  bool                      mPinning;
 };
 
 class UpdateIndexEntryEvent : public Runnable {
 public:
   UpdateIndexEntryEvent(CacheFileHandle *aHandle, const uint32_t *aFrecency,
                         const uint32_t *aExpirationTime)
     : mHandle(aHandle)
     , mHasFrecency(false)
@@ -3484,37 +3484,38 @@ CacheFileIOManager::FindTrashDirToRemove
   // trash directories next time.
   mFailedTrashDirs.Clear();
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 // static
 nsresult
 CacheFileIOManager::InitIndexEntry(CacheFileHandle *aHandle,
-                                   OriginAttrsHash  aOriginAttrsHash,
+                                   uint32_t         aAppId,
                                    bool             aAnonymous,
+                                   bool             aInIsolatedMozBrowser,
                                    bool             aPinning)
 {
-  LOG(("CacheFileIOManager::InitIndexEntry() [handle=%p, originAttrsHash=%llx, "
-       "anonymous=%d, pinning=%d]", aHandle, aOriginAttrsHash, aAnonymous,
-       aPinning));
+  LOG(("CacheFileIOManager::InitIndexEntry() [handle=%p, appId=%u, anonymous=%d"
+       ", inIsolatedMozBrowser=%d, pinned=%d]", aHandle, aAppId, aAnonymous,
+       aInIsolatedMozBrowser, aPinning));
 
   nsresult rv;
   RefPtr<CacheFileIOManager> ioMan = gInstance;
 
   if (aHandle->IsClosed() || !ioMan) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   if (aHandle->IsSpecialFile()) {
     return NS_ERROR_UNEXPECTED;
   }
 
   RefPtr<InitIndexEntryEvent> ev =
-    new InitIndexEntryEvent(aHandle, aOriginAttrsHash, aAnonymous, aPinning);
+    new InitIndexEntryEvent(aHandle, aAppId, aAnonymous, aInIsolatedMozBrowser, aPinning);
   rv = ioMan->mIOThread->Dispatch(ev, aHandle->mPriority
                                   ? CacheIOThread::WRITE_PRIORITY
                                   : CacheIOThread::WRITE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
--- a/netwerk/cache2/CacheFileIOManager.h
+++ b/netwerk/cache2/CacheFileIOManager.h
@@ -2,17 +2,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef CacheFileIOManager__h__
 #define CacheFileIOManager__h__
 
 #include "CacheIOThread.h"
 #include "CacheStorageService.h"
-#include "CacheHashUtils.h"
 #include "nsIEventTarget.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/SHA1.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "nsTArray.h"
@@ -326,18 +325,19 @@ public:
                              const nsACString &aNewName,
                              CacheFileIOListener *aCallback);
   static nsresult EvictIfOverLimit();
   static nsresult EvictAll();
   static nsresult EvictByContext(nsILoadContextInfo *aLoadContextInfo,
                                  bool aPinning);
 
   static nsresult InitIndexEntry(CacheFileHandle *aHandle,
-                                 OriginAttrsHash  aOriginAttrsHash,
+                                 uint32_t         aAppId,
                                  bool             aAnonymous,
+                                 bool             aInIsolatedMozBrowser,
                                  bool             aPinning);
   static nsresult UpdateIndexEntry(CacheFileHandle *aHandle,
                                    const uint32_t  *aFrecency,
                                    const uint32_t  *aExpirationTime);
 
   static nsresult UpdateIndexEntry();
 
   enum EEnumerateMode {
--- a/netwerk/cache2/CacheHashUtils.cpp
+++ b/netwerk/cache2/CacheHashUtils.cpp
@@ -1,15 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CacheHashUtils.h"
 
-#include "mozilla/BasePrincipal.h"
 #include "plstr.h"
 
 namespace mozilla {
 namespace net {
 
 /**
  *  CacheHash::Hash(const char * key, uint32_t initval)
  *
@@ -183,24 +182,10 @@ CacheHash::GetHash()
 
 CacheHash::Hash16_t
 CacheHash::GetHash16()
 {
   Hash32_t hash = GetHash();
   return (hash & 0xFFFF);
 }
 
-OriginAttrsHash
-GetOriginAttrsHash(const mozilla::OriginAttributes &aOA)
-{
-  nsAutoCString suffix;
-  aOA.CreateSuffix(suffix);
-
-  SHA1Sum sum;
-  SHA1Sum::Hash hash;
-  sum.update(suffix.BeginReading(), suffix.Length());
-  sum.finish(hash);
-
-  return BigEndian::readUint64(&hash);
-}
-
 } // namespace net
 } // namespace mozilla
--- a/netwerk/cache2/CacheHashUtils.h
+++ b/netwerk/cache2/CacheHashUtils.h
@@ -16,19 +16,16 @@
     PR_htonl((reinterpret_cast<const uint32_t *>(x))[2]), \
     PR_htonl((reinterpret_cast<const uint32_t *>(x))[3]), \
     PR_htonl((reinterpret_cast<const uint32_t *>(x))[4])
 
 #define SHA1STRING(x) \
     (nsPrintfCString("%08x%08x%08x%08x%08x", LOGSHA1(x)).get())
 
 namespace mozilla {
-
-class OriginAttributes;
-
 namespace net {
 
 class CacheHash : public nsISupports
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   typedef uint16_t Hash16_t;
@@ -52,16 +49,13 @@ private:
   uint32_t mA, mB, mC;
   uint8_t  mPos;
   uint32_t mBuf;
   uint8_t  mBufPos;
   uint32_t mLength;
   bool     mFinalized;
 };
 
-typedef uint64_t OriginAttrsHash;
-
-OriginAttrsHash GetOriginAttrsHash(const mozilla::OriginAttributes &aOA);
 
 } // namespace net
 } // namespace mozilla
 
 #endif
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -22,17 +22,17 @@
 #include <algorithm>
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 
 
 #define kMinUnwrittenChanges   300
 #define kMinDumpInterval       20000 // in milliseconds
 #define kMaxBufSize            16384
-#define kIndexVersion          0x00000002
+#define kIndexVersion          0x00000001
 #define kUpdateIndexStartDelay 50000 // in milliseconds
 
 #define INDEX_NAME      "index"
 #define TEMP_INDEX_NAME "index.tmp"
 #define JOURNAL_NAME    "index.log"
 
 namespace mozilla {
 namespace net {
@@ -704,23 +704,24 @@ CacheIndex::EnsureEntryExists(const SHA1
   index->WriteIndexToDiskIfNeeded();
 
   return NS_OK;
 }
 
 // static
 nsresult
 CacheIndex::InitEntry(const SHA1Sum::Hash *aHash,
-                      OriginAttrsHash      aOriginAttrsHash,
+                      uint32_t             aAppId,
                       bool                 aAnonymous,
+                      bool                 aInIsolatedMozBrowser,
                       bool                 aPinned)
 {
-  LOG(("CacheIndex::InitEntry() [hash=%08x%08x%08x%08x%08x, "
-       "originAttrsHash=%llx, anonymous=%d, pinned=%d]", LOGSHA1(aHash),
-       aOriginAttrsHash, aAnonymous, aPinned));
+  LOG(("CacheIndex::InitEntry() [hash=%08x%08x%08x%08x%08x, appId=%u, "
+       "anonymous=%d, inIsolatedMozBrowser=%d, pinned=%d]", LOGSHA1(aHash),
+       aAppId, aAnonymous, aInIsolatedMozBrowser, aPinned));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   StaticMutexAutoLock lock(sLock);
 
   RefPtr<CacheIndex> index = gInstance;
 
   if (!index) {
@@ -743,17 +744,17 @@ CacheIndex::InitEntry(const SHA1Sum::Has
     }
 
     if (index->mState == READY || index->mState == UPDATING ||
         index->mState == BUILDING) {
       MOZ_ASSERT(index->mPendingUpdates.Count() == 0);
       MOZ_ASSERT(entry);
       MOZ_ASSERT(entry->IsFresh());
 
-      if (IsCollision(entry, aOriginAttrsHash, aAnonymous)) {
+      if (IsCollision(entry, aAppId, aAnonymous, aInIsolatedMozBrowser)) {
         index->mIndexNeedsUpdate = true; // TODO Does this really help in case of collision?
         reinitEntry = true;
       } else {
         if (entry->IsInitialized()) {
           return NS_OK;
         }
       }
     } else {
@@ -761,28 +762,28 @@ CacheIndex::InitEntry(const SHA1Sum::Has
       DebugOnly<bool> removed = updated && updated->IsRemoved();
 
       MOZ_ASSERT(updated || !removed);
       MOZ_ASSERT(updated || entry);
 
       if (updated) {
         MOZ_ASSERT(updated->IsFresh());
 
-        if (IsCollision(updated, aOriginAttrsHash, aAnonymous)) {
+        if (IsCollision(updated, aAppId, aAnonymous, aInIsolatedMozBrowser)) {
           index->mIndexNeedsUpdate = true;
           reinitEntry = true;
         } else {
           if (updated->IsInitialized()) {
             return NS_OK;
           }
         }
       } else {
         MOZ_ASSERT(entry->IsFresh());
 
-        if (IsCollision(entry, aOriginAttrsHash, aAnonymous)) {
+        if (IsCollision(entry, aAppId, aAnonymous, aInIsolatedMozBrowser)) {
           index->mIndexNeedsUpdate = true;
           reinitEntry = true;
         } else {
           if (entry->IsInitialized()) {
             return NS_OK;
           }
         }
 
@@ -800,20 +801,20 @@ CacheIndex::InitEntry(const SHA1Sum::Has
         updated->MarkFresh();
       } else {
         entry->InitNew();
         entry->MarkFresh();
       }
     }
 
     if (updated) {
-      updated->Init(aOriginAttrsHash, aAnonymous, aPinned);
+      updated->Init(aAppId, aAnonymous, aInIsolatedMozBrowser, aPinned);
       updated->MarkDirty();
     } else {
-      entry->Init(aOriginAttrsHash, aAnonymous, aPinned);
+      entry->Init(aAppId, aAnonymous, aInIsolatedMozBrowser, aPinned);
       entry->MarkDirty();
     }
   }
 
   index->StartUpdatingIndexIfNeeded();
   index->WriteIndexToDiskIfNeeded();
 
   return NS_OK;
@@ -1487,30 +1488,32 @@ CacheIndex::IsIndexUsable()
   }
 
   return true;
 }
 
 // static
 bool
 CacheIndex::IsCollision(CacheIndexEntry *aEntry,
-                        OriginAttrsHash  aOriginAttrsHash,
-                        bool             aAnonymous)
+                        uint32_t         aAppId,
+                        bool             aAnonymous,
+                        bool             aInIsolatedMozBrowser)
 {
   if (!aEntry->IsInitialized()) {
     return false;
   }
 
-  if (aEntry->Anonymous() != aAnonymous ||
-      aEntry->OriginAttrsHash() != aOriginAttrsHash) {
+  if (aEntry->AppId() != aAppId || aEntry->Anonymous() != aAnonymous ||
+      aEntry->InIsolatedMozBrowser() != aInIsolatedMozBrowser) {
     LOG(("CacheIndex::IsCollision() - Collision detected for entry hash=%08x"
-         "%08x%08x%08x%08x, expected values: originAttrsHash=%llx, "
-         "anonymous=%d; actual values: originAttrsHash=%llx, anonymous=%d]",
-         LOGSHA1(aEntry->Hash()), aOriginAttrsHash, aAnonymous,
-         aEntry->OriginAttrsHash(), aEntry->Anonymous()));
+         "%08x%08x%08x%08x, expected values: appId=%u, anonymous=%d, "
+         "inIsolatedMozBrowser=%d; actual values: appId=%u, anonymous=%d, "
+         "inIsolatedMozBrowser=%d]",
+         LOGSHA1(aEntry->Hash()), aAppId, aAnonymous, aInIsolatedMozBrowser,
+         aEntry->AppId(), aEntry->Anonymous(), aEntry->InIsolatedMozBrowser()));
     return true;
   }
 
   return false;
 }
 
 // static
 bool
@@ -2649,18 +2652,20 @@ void
 CacheIndex::InitEntryFromDiskData(CacheIndexEntry *aEntry,
                                   CacheFileMetadata *aMetaData,
                                   int64_t aFileSize)
 {
   aEntry->InitNew();
   aEntry->MarkDirty();
   aEntry->MarkFresh();
 
-  aEntry->Init(GetOriginAttrsHash(aMetaData->OriginAttributes()),
+  // Bug 1201042 - will pass OriginAttributes directly.
+  aEntry->Init(aMetaData->OriginAttributes().mAppId,
                aMetaData->IsAnonymous(),
+               aMetaData->OriginAttributes().mInIsolatedMozBrowser,
                aMetaData->Pinned());
 
   uint32_t expirationTime;
   aMetaData->GetExpirationTime(&expirationTime);
   aEntry->SetExpirationTime(expirationTime);
 
   uint32_t frecency;
   aMetaData->GetFrecency(&frecency);
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -52,37 +52,37 @@ typedef struct {
   // We set this flag as soon as possible after parsing index during startup
   // and clean it after we write journal to disk during shutdown. We ignore the
   // journal and start update process whenever this flag is set during index
   // parsing.
   uint32_t mIsDirty;
 } CacheIndexHeader;
 
 struct CacheIndexRecord {
-  SHA1Sum::Hash   mHash;
-  uint32_t        mFrecency;
-  uint32_t        mExpirationTime;
-  OriginAttrsHash mOriginAttrsHash;
+  SHA1Sum::Hash mHash;
+  uint32_t      mFrecency;
+  uint32_t      mExpirationTime;
+  uint32_t      mAppId;
 
   /*
    *    1000 0000 0000 0000 0000 0000 0000 0000 : initialized
    *    0100 0000 0000 0000 0000 0000 0000 0000 : anonymous
-   *    0010 0000 0000 0000 0000 0000 0000 0000 : removed
-   *    0001 0000 0000 0000 0000 0000 0000 0000 : dirty
-   *    0000 1000 0000 0000 0000 0000 0000 0000 : fresh
-   *    0000 0100 0000 0000 0000 0000 0000 0000 : pinned
+   *    0010 0000 0000 0000 0000 0000 0000 0000 : inIsolatedMozBrowser
+   *    0001 0000 0000 0000 0000 0000 0000 0000 : removed
+   *    0000 1000 0000 0000 0000 0000 0000 0000 : dirty
+   *    0000 0100 0000 0000 0000 0000 0000 0000 : fresh
    *    0000 0011 0000 0000 0000 0000 0000 0000 : reserved
    *    0000 0000 1111 1111 1111 1111 1111 1111 : file size (in kB)
    */
   uint32_t      mFlags;
 
   CacheIndexRecord()
     : mFrecency(0)
     , mExpirationTime(nsICacheEntry::NO_EXPIRATION_TIME)
-    , mOriginAttrsHash(0)
+    , mAppId(nsILoadContextInfo::NO_APP_ID)
     , mFlags(0)
   {}
 };
 
 class CacheIndexEntry : public PLDHashEntryHdr
 {
 public:
   typedef const SHA1Sum::Hash& KeyType;
@@ -131,54 +131,60 @@ public:
   }
 
   CacheIndexEntry& operator=(const CacheIndexEntry& aOther)
   {
     MOZ_ASSERT(memcmp(&mRec->mHash, &aOther.mRec->mHash,
                sizeof(SHA1Sum::Hash)) == 0);
     mRec->mFrecency = aOther.mRec->mFrecency;
     mRec->mExpirationTime = aOther.mRec->mExpirationTime;
-    mRec->mOriginAttrsHash = aOther.mRec->mOriginAttrsHash;
+    mRec->mAppId = aOther.mRec->mAppId;
     mRec->mFlags = aOther.mRec->mFlags;
     return *this;
   }
 
   void InitNew()
   {
     mRec->mFrecency = 0;
     mRec->mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
-    mRec->mOriginAttrsHash = 0;
+    mRec->mAppId = nsILoadContextInfo::NO_APP_ID;
     mRec->mFlags = 0;
   }
 
-  void Init(OriginAttrsHash aOriginAttrsHash, bool aAnonymous, bool aPinned)
+  void Init(uint32_t aAppId, bool aAnonymous, bool aInIsolatedMozBrowser, bool aPinned)
   {
     MOZ_ASSERT(mRec->mFrecency == 0);
     MOZ_ASSERT(mRec->mExpirationTime == nsICacheEntry::NO_EXPIRATION_TIME);
-    MOZ_ASSERT(mRec->mOriginAttrsHash == 0);
+    MOZ_ASSERT(mRec->mAppId == nsILoadContextInfo::NO_APP_ID);
     // When we init the entry it must be fresh and may be dirty
     MOZ_ASSERT((mRec->mFlags & ~kDirtyMask) == kFreshMask);
 
-    mRec->mOriginAttrsHash = aOriginAttrsHash;
+    mRec->mAppId = aAppId;
     mRec->mFlags |= kInitializedMask;
     if (aAnonymous) {
       mRec->mFlags |= kAnonymousMask;
     }
+    if (aInIsolatedMozBrowser) {
+      mRec->mFlags |= kInIsolatedMozBrowserMask;
+    }
     if (aPinned) {
       mRec->mFlags |= kPinnedMask;
     }
   }
 
   const SHA1Sum::Hash * Hash() const { return &mRec->mHash; }
 
   bool IsInitialized() const { return !!(mRec->mFlags & kInitializedMask); }
 
-  mozilla::net::OriginAttrsHash OriginAttrsHash() const { return mRec->mOriginAttrsHash; }
-
-  bool Anonymous() const { return !!(mRec->mFlags & kAnonymousMask); }
+  uint32_t AppId() const { return mRec->mAppId; }
+  bool     Anonymous() const { return !!(mRec->mFlags & kAnonymousMask); }
+  bool     InIsolatedMozBrowser() const
+  {
+    return !!(mRec->mFlags & kInIsolatedMozBrowserMask);
+  }
 
   bool IsRemoved() const { return !!(mRec->mFlags & kRemovedMask); }
   void MarkRemoved() { mRec->mFlags |= kRemovedMask; }
 
   bool IsDirty() const { return !!(mRec->mFlags & kDirtyMask); }
   void MarkDirty() { mRec->mFlags |= kDirtyMask; }
   void ClearDirty() { mRec->mFlags &= ~kDirtyMask; }
 
@@ -231,48 +237,50 @@ public:
     dst->mFlags &= ~kDirtyMask;
     dst->mFlags &= ~kFreshMask;
 
 #if defined(IS_LITTLE_ENDIAN)
     // Data in the buffer are in machine byte order and we want them in network
     // byte order.
     NetworkEndian::writeUint32(&dst->mFrecency, dst->mFrecency);
     NetworkEndian::writeUint32(&dst->mExpirationTime, dst->mExpirationTime);
-    NetworkEndian::writeUint64(&dst->mOriginAttrsHash, dst->mOriginAttrsHash);
+    NetworkEndian::writeUint32(&dst->mAppId, dst->mAppId);
     NetworkEndian::writeUint32(&dst->mFlags, dst->mFlags);
 #endif
   }
 
   void ReadFromBuf(void *aBuf)
   {
     CacheIndexRecord *src= reinterpret_cast<CacheIndexRecord *>(aBuf);
     MOZ_ASSERT(memcmp(&mRec->mHash, &src->mHash,
                sizeof(SHA1Sum::Hash)) == 0);
 
     mRec->mFrecency = NetworkEndian::readUint32(&src->mFrecency);
     mRec->mExpirationTime = NetworkEndian::readUint32(&src->mExpirationTime);
-    mRec->mOriginAttrsHash = NetworkEndian::readUint64(&src->mOriginAttrsHash);
+    mRec->mAppId = NetworkEndian::readUint32(&src->mAppId);
     mRec->mFlags = NetworkEndian::readUint32(&src->mFlags);
   }
 
   void Log() const {
-    LOG(("CacheIndexEntry::Log() [this=%p, hash=%08x%08x%08x%08x%08x, fresh=%u,"
-         " initialized=%u, removed=%u, dirty=%u, anonymous=%u, "
-         "originAttrsHash=%llx, frecency=%u, expirationTime=%u, size=%u]",
+    LOG(("CacheIndexEntry::Log() [this=%p, hash=%08x%08x%08x%08x%08x, "
+         "fresh=%u, initialized=%u, removed=%u, dirty=%u, anonymous=%u, "
+         "inIsolatedMozBrowser=%u, appId=%u, frecency=%u, expirationTime=%u, "
+         "size=%u]",
          this, LOGSHA1(mRec->mHash), IsFresh(), IsInitialized(), IsRemoved(),
-         IsDirty(), Anonymous(), OriginAttrsHash(), GetFrecency(),
+         IsDirty(), Anonymous(), InIsolatedMozBrowser(), AppId(), GetFrecency(),
          GetExpirationTime(), GetFileSize()));
   }
 
   static bool RecordMatchesLoadContextInfo(CacheIndexRecord *aRec,
                                            nsILoadContextInfo *aInfo)
   {
     if (!aInfo->IsPrivate() &&
-        GetOriginAttrsHash(*aInfo->OriginAttributesPtr()) == aRec->mOriginAttrsHash &&
-        aInfo->IsAnonymous() == !!(aRec->mFlags & kAnonymousMask)) {
+        aInfo->OriginAttributesPtr()->mAppId == aRec->mAppId &&
+        aInfo->IsAnonymous() == !!(aRec->mFlags & kAnonymousMask) &&
+        aInfo->OriginAttributesPtr()->mInIsolatedMozBrowser == !!(aRec->mFlags & kInIsolatedMozBrowserMask)) {
       return true;
     }
 
     return false;
   }
 
   // Memory reporting
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const
@@ -287,34 +295,35 @@ public:
 
 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 kInIsolatedMozBrowserMask   = 0x20000000;
 
   // This flag is set when the entry was removed. We need to keep this
   // information in memory until we write the index file.
-  static const uint32_t kRemovedMask     = 0x20000000;
+  static const uint32_t kRemovedMask     = 0x10000000;
 
   // This flag is set when the information in memory is not in sync with the
   // information in index file on disk.
-  static const uint32_t kDirtyMask       = 0x10000000;
+  static const uint32_t kDirtyMask       = 0x08000000;
 
   // This flag is set when the information about the entry is fresh, i.e.
   // we've created or opened this entry during this session, or we've seen
   // this entry during update or build process.
-  static const uint32_t kFreshMask       = 0x08000000;
+  static const uint32_t kFreshMask       = 0x04000000;
 
   // Indicates a pinned entry.
-  static const uint32_t kPinnedMask      = 0x04000000;
+  static const uint32_t kPinnedMask      = 0x02000000;
 
-  static const uint32_t kReservedMask    = 0x03000000;
+  static const uint32_t kReservedMask    = 0x01000000;
 
   // FileSize in kilobytes
   static const uint32_t kFileSizeMask    = 0x00FFFFFF;
 
   nsAutoPtr<CacheIndexRecord> mRec;
 };
 
 class CacheIndexEntryUpdate : public CacheIndexEntry
@@ -371,17 +380,17 @@ public:
     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->mOriginAttrsHash = mRec->mOriginAttrsHash;
+    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);
     }
   }
@@ -611,18 +620,19 @@ public:
   // created. Like in case of AddEntry(), either InitEntry() or RemoveEntry()
   // must be called on the entry, since the entry is not initizlized if the
   // index is outdated.
   static nsresult EnsureEntryExists(const SHA1Sum::Hash *aHash);
 
   // Initialize the entry. It MUST be present in index. Call to AddEntry() or
   // EnsureEntryExists() must precede the call to this method.
   static nsresult InitEntry(const SHA1Sum::Hash *aHash,
-                            OriginAttrsHash      aOriginAttrsHash,
+                            uint32_t             aAppId,
                             bool                 aAnonymous,
+                            bool                 aInIsolatedMozBrowser,
                             bool                 aPinned);
 
   // Remove entry from index. The entry should be present in index.
   static nsresult RemoveEntry(const SHA1Sum::Hash *aHash);
 
   // Update some information in entry. The entry MUST be present in index and
   // MUST be initialized. Call to AddEntry() or EnsureEntryExists() and to
   // InitEntry() must precede the call to this method.
@@ -711,23 +721,24 @@ private:
   NS_IMETHOD OnFileRenamed(CacheFileHandle *aHandle, nsresult aResult) override;
 
   nsresult InitInternal(nsIFile *aCacheDirectory);
   void     PreShutdownInternal();
 
   // This method returns false when index is not initialized or is shut down.
   bool IsIndexUsable();
 
-  // This method checks whether the entry has the same values of
-  // originAttributes and isAnonymous. We don't expect to find a collision
-  // since these values are part of the key that we hash and we use a strong
-  // hash function.
+  // This method checks whether the entry has the same values of appId,
+  // isAnonymous and isInBrowser. We don't expect to find a collision since
+  // these values are part of the key that we hash and we use a strong hash
+  // function.
   static bool IsCollision(CacheIndexEntry *aEntry,
-                          OriginAttrsHash  aOriginAttrsHash,
-                          bool             aAnonymous);
+                          uint32_t         aAppId,
+                          bool             aAnonymous,
+                          bool             aInIsolatedMozBrowser);
 
   // 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.