Bug 1282882 - Remove LoadContextInfo and LoadContext private browsing flags; r=jdm,mayhemer
authorJames Andreou <jandreou25@gmail.com>
Tue, 23 Aug 2016 18:07:56 -0400
changeset 337233 b2b90d326543bb0c4d2bbf312f1aaca7558a6690
parent 337232 b8f1c3166fa2b388c9b655ce2abf1530bb93563f
child 337234 367dbfe0a898a8cc51f11264ac5fabe5309da57d
push id10033
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:50:26 +0000
treeherdermozilla-aurora@5dddbefdf759 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, mayhemer
bugs1282882
milestone51.0a1
Bug 1282882 - Remove LoadContextInfo and LoadContext private browsing flags; r=jdm,mayhemer
browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
docshell/base/LoadContext.cpp
docshell/base/LoadContext.h
docshell/base/SerializedLoadContext.cpp
docshell/base/SerializedLoadContext.h
netwerk/base/LoadContextInfo.cpp
netwerk/base/LoadContextInfo.h
netwerk/base/Predictor.cpp
netwerk/base/nsILoadContextInfo.idl
netwerk/cache2/CacheFileUtils.cpp
netwerk/cache2/CacheObserver.cpp
netwerk/cookie/CookieServiceParent.cpp
netwerk/ipc/NeckoParent.cpp
netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/test/mochitests/test_web_packaged_app.html
netwerk/test/unit/test_bug248970_cache.js
--- a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
@@ -164,22 +164,22 @@ function* test_cookie_cleared() {
 
 // Cache
 function* test_cache_cleared() {
   // First, add some caches.
   for (let userContextId of Object.keys(USER_CONTEXTS)) {
     yield OpenCacheEntry("http://" + TEST_HOST + "/",
                          "disk",
                          Ci.nsICacheStorage.OPEN_NORMALLY,
-                         LoadContextInfo.custom(false, false, {userContextId}));
+                         LoadContextInfo.custom(false, {userContextId}));
 
     yield OpenCacheEntry("http://" + TEST_HOST + "/",
                          "memory",
                          Ci.nsICacheStorage.OPEN_NORMALLY,
-                         LoadContextInfo.custom(false, false, {userContextId}));
+                         LoadContextInfo.custom(false, {userContextId}));
   }
 
 
   // Check that caches have been set correctly.
   for (let userContextId of Object.keys(USER_CONTEXTS)) {
     let mem = getCacheStorage("memory");
     let disk = getCacheStorage("disk");
 
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -47,23 +47,21 @@ LoadContext::LoadContext(nsIPrincipal* a
   , mIsContent(true)
   , mUseRemoteTabs(false)
 #ifdef DEBUG
   , mIsNotNull(true)
 #endif
 {
   PrincipalOriginAttributes poa = BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
   mOriginAttributes.InheritFromDocToChildDocShell(poa);
-  mUsePrivateBrowsing = (poa.mPrivateBrowsingId != 0);
   if (!aOptionalBase) {
     return;
   }
 
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetIsContent(&mIsContent));
-  MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing));
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs));
 }
 
 //-----------------------------------------------------------------------------
 // LoadContext::nsILoadContext
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
@@ -122,17 +120,17 @@ LoadContext::GetIsContent(bool* aIsConte
 
 NS_IMETHODIMP
 LoadContext::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
 {
   MOZ_ASSERT(mIsNotNull);
 
   NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
 
-  *aUsePrivateBrowsing = mUsePrivateBrowsing;
+  *aUsePrivateBrowsing = mOriginAttributes.mPrivateBrowsingId > 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 LoadContext::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
 {
   MOZ_ASSERT(mIsNotNull);
 
@@ -204,17 +202,17 @@ LoadContext::GetOriginAttributes(JS::Mut
 
 NS_IMETHODIMP
 LoadContext::IsTrackingProtectionOn(bool* aIsTrackingProtectionOn)
 {
   MOZ_ASSERT(mIsNotNull);
 
   if (Preferences::GetBool("privacy.trackingprotection.enabled", false)) {
     *aIsTrackingProtectionOn = true;
-  } else if (mUsePrivateBrowsing &&
+  } else if ((mOriginAttributes.mPrivateBrowsingId > 0) &&
              Preferences::GetBool("privacy.trackingprotection.pbmode.enabled", false)) {
     *aIsTrackingProtectionOn = true;
   } else {
     *aIsTrackingProtectionOn = false;
   }
 
   return NS_OK;
 }
--- a/docshell/base/LoadContext.h
+++ b/docshell/base/LoadContext.h
@@ -42,68 +42,61 @@ public:
   // appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
   // provided by child process.
   LoadContext(const IPC::SerializedLoadContext& aToCopy,
               dom::Element* aTopFrameElement,
               DocShellOriginAttributes& aAttrs)
     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
     , mNestedFrameId(0)
     , mIsContent(aToCopy.mIsContent)
-    , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(aToCopy.mIsNotNull)
 #endif
   {
-    MOZ_ASSERT(aToCopy.mUsePrivateBrowsing == (aAttrs.mPrivateBrowsingId != 0));
   }
 
   // appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
   // provided by child process.
   LoadContext(const IPC::SerializedLoadContext& aToCopy,
               uint64_t aNestedFrameId,
               DocShellOriginAttributes& aAttrs)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(aNestedFrameId)
     , mIsContent(aToCopy.mIsContent)
-    , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(aToCopy.mIsNotNull)
 #endif
   {
-    MOZ_ASSERT(aToCopy.mUsePrivateBrowsing == (aAttrs.mPrivateBrowsingId != 0));
   }
 
   LoadContext(dom::Element* aTopFrameElement,
               bool aIsContent,
               bool aUsePrivateBrowsing,
               bool aUseRemoteTabs,
               const DocShellOriginAttributes& aAttrs)
     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
     , mNestedFrameId(0)
     , mIsContent(aIsContent)
-    , mUsePrivateBrowsing(aUsePrivateBrowsing)
     , mUseRemoteTabs(aUseRemoteTabs)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
   {
-    MOZ_ASSERT(aUsePrivateBrowsing == (aAttrs.mPrivateBrowsingId != 0));
   }
 
   // Constructor taking reserved origin attributes.
   explicit LoadContext(DocShellOriginAttributes& aAttrs)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(0)
     , mIsContent(false)
-    , mUsePrivateBrowsing(aAttrs.mPrivateBrowsingId != 0)
     , mUseRemoteTabs(false)
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
   {
   }
 
@@ -113,17 +106,16 @@ public:
                        nsILoadContext* aOptionalBase = nullptr);
 
 private:
   ~LoadContext() {}
 
   nsWeakPtr mTopFrameElement;
   uint64_t mNestedFrameId;
   bool mIsContent;
-  bool mUsePrivateBrowsing;
   bool mUseRemoteTabs;
   DocShellOriginAttributes mOriginAttributes;
 #ifdef DEBUG
   bool mIsNotNull;
 #endif
 };
 
 } // namespace mozilla
--- a/docshell/base/SerializedLoadContext.cpp
+++ b/docshell/base/SerializedLoadContext.cpp
@@ -33,20 +33,19 @@ SerializedLoadContext::SerializedLoadCon
     // overriden.
     bool isPrivate = false;
     bool isOverriden = false;
     nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
     if (pbChannel &&
         NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate,
                                                        &isOverriden)) &&
         isOverriden) {
-      mUsePrivateBrowsing = isPrivate;
       mIsPrivateBitValid = true;
     }
-    mOriginAttributes.SyncAttributesWithPrivateBrowsing(mUsePrivateBrowsing);
+    mOriginAttributes.SyncAttributesWithPrivateBrowsing(isPrivate);
   }
 }
 
 SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel* aChannel)
 {
   nsCOMPtr<nsILoadContext> loadContext;
   if (aChannel) {
     NS_QueryNotificationCallbacks(aChannel, loadContext);
@@ -56,26 +55,23 @@ SerializedLoadContext::SerializedLoadCon
 
 void
 SerializedLoadContext::Init(nsILoadContext* aLoadContext)
 {
   if (aLoadContext) {
     mIsNotNull = true;
     mIsPrivateBitValid = true;
     aLoadContext->GetIsContent(&mIsContent);
-    aLoadContext->GetUsePrivateBrowsing(&mUsePrivateBrowsing);
-    mOriginAttributes.SyncAttributesWithPrivateBrowsing(mUsePrivateBrowsing);
     aLoadContext->GetUseRemoteTabs(&mUseRemoteTabs);
     if (!aLoadContext->GetOriginAttributes(mOriginAttributes)) {
       NS_WARNING("GetOriginAttributes failed");
     }
   } else {
     mIsNotNull = false;
     mIsPrivateBitValid = false;
     // none of below values really matter when mIsNotNull == false:
     // we won't be GetInterfaced to nsILoadContext
     mIsContent = true;
-    mUsePrivateBrowsing = false;
     mUseRemoteTabs = false;
   }
 }
 
 } // namespace IPC
--- a/docshell/base/SerializedLoadContext.h
+++ b/docshell/base/SerializedLoadContext.h
@@ -26,17 +26,16 @@ namespace IPC {
 
 class SerializedLoadContext
 {
 public:
   SerializedLoadContext()
     : mIsNotNull(false)
     , mIsPrivateBitValid(false)
     , mIsContent(false)
-    , mUsePrivateBrowsing(false)
     , mUseRemoteTabs(false)
   {
     Init(nullptr);
   }
 
   explicit SerializedLoadContext(nsILoadContext* aLoadContext);
   explicit SerializedLoadContext(nsIChannel* aChannel);
   explicit SerializedLoadContext(nsIWebSocketChannel* aChannel);
@@ -47,17 +46,16 @@ public:
   bool IsPrivateBitValid() const { return mIsPrivateBitValid; }
 
   // used to indicate if child-side LoadContext * was null.
   bool mIsNotNull;
   // used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
   // mIsNotNull is false, i.e., child LoadContext was null.
   bool mIsPrivateBitValid;
   bool mIsContent;
-  bool mUsePrivateBrowsing;
   bool mUseRemoteTabs;
   mozilla::DocShellOriginAttributes mOriginAttributes;
 };
 
 // Function to serialize over IPDL
 template<>
 struct ParamTraits<SerializedLoadContext>
 {
@@ -66,28 +64,26 @@ struct ParamTraits<SerializedLoadContext
   static void Write(Message* aMsg, const paramType& aParam)
   {
     nsAutoCString suffix;
     aParam.mOriginAttributes.CreateSuffix(suffix);
 
     WriteParam(aMsg, aParam.mIsNotNull);
     WriteParam(aMsg, aParam.mIsContent);
     WriteParam(aMsg, aParam.mIsPrivateBitValid);
-    WriteParam(aMsg, aParam.mUsePrivateBrowsing);
     WriteParam(aMsg, aParam.mUseRemoteTabs);
     WriteParam(aMsg, suffix);
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {
     nsAutoCString suffix;
     if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) ||
         !ReadParam(aMsg, aIter, &aResult->mIsContent) ||
         !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) ||
-        !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing) ||
         !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) ||
         !ReadParam(aMsg, aIter, &suffix)) {
       return false;
     }
     return aResult->mOriginAttributes.PopulateFromSuffix(suffix);
   }
 };
 
--- a/netwerk/base/LoadContextInfo.cpp
+++ b/netwerk/base/LoadContextInfo.cpp
@@ -13,31 +13,29 @@
 using namespace mozilla::dom;
 namespace mozilla {
 namespace net {
 
 // LoadContextInfo
 
 NS_IMPL_ISUPPORTS(LoadContextInfo, nsILoadContextInfo)
 
-LoadContextInfo::LoadContextInfo(bool aIsPrivate, bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes)
-  : mIsPrivate(aIsPrivate)
-  , mIsAnonymous(aIsAnonymous)
+LoadContextInfo::LoadContextInfo(bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes)
+  : mIsAnonymous(aIsAnonymous)
   , mOriginAttributes(aOriginAttributes)
 {
-  mOriginAttributes.SyncAttributesWithPrivateBrowsing(mIsPrivate);
 }
 
 LoadContextInfo::~LoadContextInfo()
 {
 }
 
 NS_IMETHODIMP LoadContextInfo::GetIsPrivate(bool *aIsPrivate)
 {
-  *aIsPrivate = mIsPrivate;
+  *aIsPrivate = mOriginAttributes.mPrivateBrowsingId > 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP LoadContextInfo::GetIsAnonymous(bool *aIsAnonymous)
 {
   *aIsAnonymous = mIsAnonymous;
   return NS_OK;
 }
@@ -57,46 +55,46 @@ NS_IMETHODIMP LoadContextInfo::GetOrigin
 }
 
 // LoadContextInfoFactory
 
 NS_IMPL_ISUPPORTS(LoadContextInfoFactory, nsILoadContextInfoFactory)
 
 NS_IMETHODIMP LoadContextInfoFactory::GetDefault(nsILoadContextInfo * *aDefault)
 {
-  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, false, NeckoOriginAttributes());
+  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, NeckoOriginAttributes());
   info.forget(aDefault);
   return NS_OK;
 }
 
 NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate)
 {
   NeckoOriginAttributes attrs;
-  attrs.SyncAttributesWithPrivateBrowsing(aPrivate);
-  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, false, attrs);
+  attrs.SyncAttributesWithPrivateBrowsing(true);
+  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, attrs);
   info.forget(aPrivate);
   return NS_OK;
 }
 
 NS_IMETHODIMP LoadContextInfoFactory::GetAnonymous(nsILoadContextInfo * *aAnonymous)
 {
-  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, true, NeckoOriginAttributes());
+  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, NeckoOriginAttributes());
   info.forget(aAnonymous);
   return NS_OK;
 }
 
-NS_IMETHODIMP LoadContextInfoFactory::Custom(bool aPrivate, bool aAnonymous,
+NS_IMETHODIMP LoadContextInfoFactory::Custom(bool aAnonymous,
                                              JS::HandleValue aOriginAttributes, JSContext *cx,
                                              nsILoadContextInfo * *_retval)
 {
   NeckoOriginAttributes attrs;
   bool status = attrs.Init(cx, aOriginAttributes);
   NS_ENSURE_TRUE(status, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(aPrivate, aAnonymous, attrs);
+  nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(aAnonymous, attrs);
   info.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP LoadContextInfoFactory::FromLoadContext(nsILoadContext *aLoadContext, bool aAnonymous,
                                                       nsILoadContextInfo * *_retval)
 {
   nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(aLoadContext, aAnonymous);
@@ -114,73 +112,70 @@ NS_IMETHODIMP LoadContextInfoFactory::Fr
 
 // Helper functions
 
 LoadContextInfo *
 GetLoadContextInfo(nsIChannel * aChannel)
 {
   nsresult rv;
 
-  bool pb = NS_UsePrivateBrowsing(aChannel);
+  DebugOnly<bool> pb = NS_UsePrivateBrowsing(aChannel);
 
   bool anon = false;
   nsLoadFlags loadFlags;
   rv = aChannel->GetLoadFlags(&loadFlags);
   if (NS_SUCCEEDED(rv)) {
     anon = !!(loadFlags & nsIChannel::LOAD_ANONYMOUS);
   }
 
   NeckoOriginAttributes oa;
   NS_GetOriginAttributes(aChannel, oa);
+  MOZ_ASSERT(pb == (oa.mPrivateBrowsingId > 0));
 
-  return new LoadContextInfo(pb, anon, oa);
+  return new LoadContextInfo(anon, oa);
 }
 
 LoadContextInfo *
 GetLoadContextInfo(nsILoadContext *aLoadContext, bool aIsAnonymous)
 {
   if (!aLoadContext) {
-    return new LoadContextInfo(false, aIsAnonymous,
+    return new LoadContextInfo(aIsAnonymous,
                                NeckoOriginAttributes(nsILoadContextInfo::NO_APP_ID, false));
   }
 
-  bool pb = aLoadContext->UsePrivateBrowsing();
+  DebugOnly<bool> pb = aLoadContext->UsePrivateBrowsing();
   DocShellOriginAttributes doa;
   aLoadContext->GetOriginAttributes(doa);
-
-  doa.SyncAttributesWithPrivateBrowsing(pb);
+  MOZ_ASSERT(pb == (doa.mPrivateBrowsingId > 0));
 
   NeckoOriginAttributes noa;
   noa.InheritFromDocShellToNecko(doa);
 
-  return new LoadContextInfo(pb, aIsAnonymous, noa);
+  return new LoadContextInfo(aIsAnonymous, noa);
 }
 
 LoadContextInfo*
 GetLoadContextInfo(nsIDOMWindow *aWindow,
                    bool aIsAnonymous)
 {
   nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
   nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
 
   return GetLoadContextInfo(loadContext, aIsAnonymous);
 }
 
 LoadContextInfo *
 GetLoadContextInfo(nsILoadContextInfo *aInfo)
 {
-  return new LoadContextInfo(aInfo->IsPrivate(),
-                             aInfo->IsAnonymous(),
+  return new LoadContextInfo(aInfo->IsAnonymous(),
                              *aInfo->OriginAttributesPtr());
 }
 
 LoadContextInfo *
-GetLoadContextInfo(bool const aIsPrivate,
-                   bool const aIsAnonymous,
+GetLoadContextInfo(bool const aIsAnonymous,
                    NeckoOriginAttributes const &aOriginAttributes)
 {
-  return new LoadContextInfo(aIsPrivate,
-                             aIsAnonymous,
+  return new LoadContextInfo(aIsAnonymous,
                              aOriginAttributes);
 }
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/base/LoadContextInfo.h
+++ b/netwerk/base/LoadContextInfo.h
@@ -14,23 +14,22 @@ namespace mozilla {
 namespace net {
 
 class LoadContextInfo : public nsILoadContextInfo
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSILOADCONTEXTINFO
 
-  LoadContextInfo(bool aIsPrivate, bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes);
+  LoadContextInfo(bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes);
 
 private:
   virtual ~LoadContextInfo();
 
 protected:
-  bool mIsPrivate : 1;
   bool mIsAnonymous : 1;
   NeckoOriginAttributes mOriginAttributes;
 };
 
 class LoadContextInfoFactory : public nsILoadContextInfoFactory
 {
   virtual ~LoadContextInfoFactory() {}
 public:
@@ -48,16 +47,15 @@ GetLoadContextInfo(nsILoadContext *aLoad
 LoadContextInfo*
 GetLoadContextInfo(nsIDOMWindow *aLoadContext,
                    bool aIsAnonymous);
 
 LoadContextInfo*
 GetLoadContextInfo(nsILoadContextInfo *aInfo);
 
 LoadContextInfo*
-GetLoadContextInfo(bool const aIsPrivate,
-                   bool const aIsAnonymous,
+GetLoadContextInfo(bool const aIsAnonymous,
                    NeckoOriginAttributes const &aOriginAttributes);
 
 } // namespace net
 } // namespace mozilla
 
 #endif
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -615,17 +615,17 @@ Predictor::Init()
     mDNSListener = new DNSListener();
   }
 
   nsCOMPtr<nsICacheStorageService> cacheStorageService =
     do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<LoadContextInfo> lci =
-    new LoadContextInfo(false, false, NeckoOriginAttributes());
+    new LoadContextInfo(false, NeckoOriginAttributes());
 
   rv = cacheStorageService->DiskCacheStorage(lci, false,
                                              getter_AddRefs(mCacheDiskStorage));
   NS_ENSURE_SUCCESS(rv, rv);
 
   mIOService = do_GetService("@mozilla.org/network/io-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/netwerk/base/nsILoadContextInfo.idl
+++ b/netwerk/base/nsILoadContextInfo.idl
@@ -59,18 +59,17 @@ interface nsILoadContextInfo : nsISuppor
   {
     bool anon;
     GetIsAnonymous(&anon);
     return anon;
   }
 
   bool Equals(nsILoadContextInfo *aOther)
   {
-    return IsPrivate() == aOther->IsPrivate() &&
-           IsAnonymous() == aOther->IsAnonymous() &&
+    return IsAnonymous() == aOther->IsAnonymous() &&
            *OriginAttributesPtr() == *aOther->OriginAttributesPtr();
   }
 %}
 };
 
 /**
  * Since NeckoOriginAttributes struct limits the implementation of
  * nsILoadContextInfo (that needs to be thread safe) to C++,
@@ -79,12 +78,12 @@ interface nsILoadContextInfo : nsISuppor
  */
 [scriptable, uuid(c1c7023d-4318-4f99-8307-b5ccf0558793)]
 interface nsILoadContextInfoFactory : nsISupports
 {
   readonly attribute nsILoadContextInfo default;
   readonly attribute nsILoadContextInfo private;
   readonly attribute nsILoadContextInfo anonymous;
   [implicit_jscontext]
-  nsILoadContextInfo custom(in boolean aPrivate, in boolean aAnonymous, in jsval aOriginAttributes);
+  nsILoadContextInfo custom(in boolean aAnonymous, in jsval aOriginAttributes);
   nsILoadContextInfo fromLoadContext(in nsILoadContext aLoadContext, in boolean aAnonymous);
   nsILoadContextInfo fromWindow(in nsIDOMWindow aWindow, in boolean aAnonymous);
 };
--- a/netwerk/cache2/CacheFileUtils.cpp
+++ b/netwerk/cache2/CacheFileUtils.cpp
@@ -31,27 +31,25 @@ namespace {
  */
 class KeyParser : protected Tokenizer
 {
 public:
   explicit KeyParser(nsACString const& aInput)
     : Tokenizer(aInput)
     // Initialize attributes to their default values
     , originAttribs(0, false)
-    , isPrivate(false)
     , isAnonymous(false)
     // Initialize the cache key to a zero length by default
     , lastTag(0)
   {
   }
 
 private:
   // Results
   NeckoOriginAttributes originAttribs;
-  bool isPrivate;
   bool isAnonymous;
   nsCString idEnhance;
   nsDependentCSubstring cacheKey;
 
   // Keeps the last tag name, used for alphabetical sort checking
   char lastTag;
 
   // Classifier for the 'tag' character valid range
@@ -87,17 +85,17 @@ private:
     case 'O': {
       nsAutoCString originSuffix;
       if (!ParseValue(&originSuffix) || !originAttribs.PopulateFromSuffix(originSuffix)) {
         return false;
       }
       break;
     }
     case 'p':
-      isPrivate = true;
+      originAttribs.SyncAttributesWithPrivateBrowsing(true);
       break;
     case 'b':
       // Leaving to be able to read and understand oldformatted entries
       originAttribs.mInIsolatedMozBrowser = true;
       break;
     case 'a':
       isAnonymous = true;
       break;
@@ -161,17 +159,17 @@ private:
     return false;
   }
 
 public:
   already_AddRefed<LoadContextInfo> Parse()
   {
     RefPtr<LoadContextInfo> info;
     if (ParseTags()) {
-      info = GetLoadContextInfo(isPrivate, isAnonymous, originAttribs);
+      info = GetLoadContextInfo(isAnonymous, originAttribs);
     }
 
     return info.forget();
   }
 
   void URISpec(nsACString &result)
   {
     result.Assign(cacheKey);
--- a/netwerk/cache2/CacheObserver.cpp
+++ b/netwerk/cache2/CacheObserver.cpp
@@ -405,21 +405,22 @@ void CacheObserver::ParentDirOverride(ns
   sSelf->mCacheParentDirectoryOverride->Clone(aDir);
 }
 
 namespace {
 namespace CacheStorageEvictHelper {
 
 nsresult ClearStorage(bool const aPrivate,
                       bool const aAnonymous,
-                      NeckoOriginAttributes const &aOa)
+                      NeckoOriginAttributes &aOa)
 {
   nsresult rv;
 
-  RefPtr<LoadContextInfo> info = GetLoadContextInfo(aPrivate, aAnonymous, aOa);
+  aOa.SyncAttributesWithPrivateBrowsing(aPrivate);
+  RefPtr<LoadContextInfo> info = GetLoadContextInfo(aAnonymous, aOa);
 
   nsCOMPtr<nsICacheStorage> storage;
   RefPtr<CacheStorageService> service = CacheStorageService::Self();
   NS_ENSURE_TRUE(service, NS_ERROR_FAILURE);
 
   // Clear disk storage
   rv = service->DiskCacheStorage(info, false, getter_AddRefs(storage));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -430,17 +431,17 @@ nsresult ClearStorage(bool const aPrivat
   rv = service->MemoryCacheStorage(info, getter_AddRefs(storage));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = storage->AsyncEvictStorage(nullptr);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-nsresult Run(NeckoOriginAttributes const &aOa)
+nsresult Run(NeckoOriginAttributes &aOa)
 {
   nsresult rv;
 
   // Clear all [private X anonymous] combinations
   rv = ClearStorage(false, false, aOa);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = ClearStorage(false, true, aOa);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/netwerk/cookie/CookieServiceParent.cpp
+++ b/netwerk/cookie/CookieServiceParent.cpp
@@ -85,17 +85,17 @@ CookieServiceParent::GetOriginAttributes
   if (error) {
     NS_WARNING(nsPrintfCString("CookieServiceParent: GetOriginAttributesFromParams: "
                                "FATAL error: %s: KILLING CHILD PROCESS\n",
                                error).get());
     return false;
   }
 
   if (aLoadContext.IsPrivateBitValid()) {
-    aIsPrivate = aLoadContext.mUsePrivateBrowsing;
+    aIsPrivate = aLoadContext.mOriginAttributes.mPrivateBrowsingId > 0;
   }
 
   aAttrs.InheritFromDocShellToNecko(docShellAttrs);
   return true;
 }
 
 CookieServiceParent::CookieServiceParent()
 {
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -94,17 +94,17 @@ NeckoParent::~NeckoParent()
     mObserver->RemoveObserver();
   }
 }
 
 static PBOverrideStatus
 PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized)
 {
   if (!aSerialized.IsNotNull() && aSerialized.IsPrivateBitValid()) {
-    return aSerialized.mUsePrivateBrowsing ?
+    return (aSerialized.mOriginAttributes.mPrivateBrowsingId > 0) ?
       kPBOverride_Private :
       kPBOverride_NotPrivate;
   }
   return kPBOverride_Unset;
 }
 
 const char*
 NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
@@ -179,17 +179,17 @@ NeckoParent::CreateChannelLoadContext(co
   const char* error = GetValidatedAppInfo(aSerialized, aContent, attrs);
   if (error) {
     return error;
   }
 
   // if !UsingNeckoIPCSecurity(), we may not have a LoadContext to set. This is
   // the common case for most xpcshell tests.
   if (aSerialized.IsNotNull()) {
-    attrs.SyncAttributesWithPrivateBrowsing(aSerialized.mUsePrivateBrowsing);
+    attrs.SyncAttributesWithPrivateBrowsing(aSerialized.mOriginAttributes.mPrivateBrowsingId > 0);
     switch (aBrowser.type()) {
       case PBrowserOrId::TPBrowserParent:
       {
         RefPtr<TabParent> tabParent =
           TabParent::GetFrom(aBrowser.get_PBrowserParent());
         dom::Element* topFrameElement = nullptr;
         if (tabParent) {
           topFrameElement = tabParent->GetOwnerElement();
@@ -820,17 +820,17 @@ NeckoParent::RecvPredPredict(const ipc::
   nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI);
 
   // We only actually care about the loadContext.mPrivateBrowsing, so we'll just
   // pass dummy params for nestFrameId, and originAttributes.
   uint64_t nestedFrameId = 0;
   DocShellOriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false);
   nsCOMPtr<nsILoadContext> loadContext;
   if (aLoadContext.IsNotNull()) {
-    attrs.SyncAttributesWithPrivateBrowsing(aLoadContext.mUsePrivateBrowsing);
+    attrs.SyncAttributesWithPrivateBrowsing(aLoadContext.mOriginAttributes.mPrivateBrowsingId > 0);
     loadContext = new LoadContext(aLoadContext, nestedFrameId, attrs);
   }
 
   // Get the current predictor
   nsresult rv = NS_OK;
   nsCOMPtr<nsINetworkPredictor> predictor =
     do_GetService("@mozilla.org/network/predictor;1", &rv);
   NS_ENSURE_SUCCESS(rv, false);
@@ -853,17 +853,17 @@ NeckoParent::RecvPredLearn(const ipc::UR
   nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI);
 
   // We only actually care about the loadContext.mPrivateBrowsing, so we'll just
   // pass dummy params for nestFrameId, and originAttributes;
   uint64_t nestedFrameId = 0;
   DocShellOriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false);
   nsCOMPtr<nsILoadContext> loadContext;
   if (aLoadContext.IsNotNull()) {
-    attrs.SyncAttributesWithPrivateBrowsing(aLoadContext.mUsePrivateBrowsing);
+    attrs.SyncAttributesWithPrivateBrowsing(aLoadContext.mOriginAttributes.mPrivateBrowsingId > 0);
     loadContext = new LoadContext(aLoadContext, nestedFrameId, attrs);
   }
 
   // Get the current predictor
   nsresult rv = NS_OK;
   nsCOMPtr<nsINetworkPredictor> predictor =
     do_GetService("@mozilla.org/network/predictor;1", &rv);
   NS_ENSURE_SUCCESS(rv, false);
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
@@ -139,17 +139,17 @@ WyciwygChannelParent::SetupAppData(const
     printf_stderr("WyciwygChannelParent::SetupAppData: FATAL ERROR: %s\n",
                   error);
     return false;
   }
 
   if (!mLoadContext && loadContext.IsPrivateBitValid()) {
     nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(mChannel);
     if (pbChannel)
-      pbChannel->SetPrivate(loadContext.mUsePrivateBrowsing);
+      pbChannel->SetPrivate(loadContext.mOriginAttributes.mPrivateBrowsingId > 0);
   }
 
   mReceivedAppData = true;
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvAsyncOpen(const URIParams& aOriginal,
--- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
@@ -783,18 +783,18 @@ nsWyciwygChannel::OpenCacheEntry(nsIURI 
 {
   nsresult rv;
 
   nsCOMPtr<nsICacheStorageService> cacheService =
     do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool anonymous = mLoadFlags & LOAD_ANONYMOUS;
-  RefPtr<LoadContextInfo> loadInfo = mozilla::net::GetLoadContextInfo(
-    mPrivateBrowsing, anonymous, mOriginAttributes);
+  mOriginAttributes.SyncAttributesWithPrivateBrowsing(mPrivateBrowsing);
+  RefPtr<LoadContextInfo> loadInfo = mozilla::net::GetLoadContextInfo(anonymous, mOriginAttributes);
 
   nsCOMPtr<nsICacheStorage> cacheStorage;
   if (mLoadFlags & INHIBIT_PERSISTENT_CACHING)
     rv = cacheService->MemoryCacheStorage(loadInfo, getter_AddRefs(cacheStorage));
   else
     rv = cacheService->DiskCacheStorage(loadInfo, false, getter_AddRefs(cacheStorage));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/netwerk/test/mochitests/test_web_packaged_app.html
+++ b/netwerk/test/mochitests/test_web_packaged_app.html
@@ -38,17 +38,17 @@ CacheCallback.prototype = {
   onCacheEntryAvailable: function(entry, isnew, applicationCache, status) {
     is(status, this.expect ? Cr.NS_OK : Cr.NS_ERROR_CACHE_KEY_NOT_FOUND, "check status");
     is(!!entry, this.expect, "check if entry exists");
     SpecialPowers.executeSoon(continueTest);
   }
 };
 
 function checkCacheEntry(url, exists, appId) {
-  var loadContext = appId ? LoadContextInfo.custom(false, false, {appId: appId}) : LoadContextInfo.default;
+  var loadContext = appId ? LoadContextInfo.custom(false, {appId: appId}) : LoadContextInfo.default;
   var cacheService = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
                      .getService(Ci.nsICacheStorageService);
   var cache = cacheService.diskCacheStorage(loadContext, false);
   cache.asyncOpenURI(CommonUtils.makeURI(url), "", 0, new CacheCallback(exists));
 }
 
 var gGenerator = runTest();
 
--- a/netwerk/test/unit/test_bug248970_cache.js
+++ b/netwerk/test/unit/test_bug248970_cache.js
@@ -42,17 +42,18 @@ function store_entries(cb)
   if (store_idx == entries.length) {
     do_execute_soon(store_cb);
     return;
   }
 
   asyncOpenCacheEntry(entries[store_idx][0],
                       entries[store_idx][2],
                       Ci.nsICacheStorage.OPEN_TRUNCATE,
-                      LoadContextInfo.custom(!entries[store_idx][3], false, {}),
+                      LoadContextInfo.custom(false,
+                        {privateBrowsingId : entries[store_idx][3] ? 0 : 1}),
                       store_data,
                       appCache);
 }
 
 var store_data = function(status, entry) {
   do_check_eq(status, Cr.NS_OK);
   var os = entry.openOutputStream(0);
 
@@ -82,17 +83,18 @@ function check_entries(cb, pbExited)
   if (check_idx == entries.length) {
     do_execute_soon(check_cb);
     return;
   }
 
   asyncOpenCacheEntry(entries[check_idx][0],
                       entries[check_idx][2],
                       Ci.nsICacheStorage.OPEN_READONLY,
-                      LoadContextInfo.custom(!entries[check_idx][3], false, {}),
+                      LoadContextInfo.custom(false,
+                        {privateBrowsingId : entries[check_idx][3] ? 0 : 1}),
                       check_data,
                       appCache);
 }
 
 var check_data = function (status, entry) {
   var cont = function() {
     check_idx++;
     do_execute_soon(check_entries);