Bug 1319536: Part 1 - Take private browsing ID from load info when load context is unavailable. r=ehsan a=jcristau a=gchang
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Nov 2016 15:51:15 -0800
changeset 352880 314b4c10adef7354e9d75bf906a47be71515a577
parent 352879 bf608ff5e3c8c7004b8c862d8e2d57cd3e776d57
child 352881 3d17099df5f38b6a315b64de1d2414905c57f17e
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, jcristau, gchang
bugs1319536
milestone52.0a2
Bug 1319536: Part 1 - Take private browsing ID from load info when load context is unavailable. r=ehsan a=jcristau a=gchang MozReview-Commit-ID: IoXFofyiKR1
netwerk/base/PrivateBrowsingChannel.h
--- a/netwerk/base/PrivateBrowsingChannel.h
+++ b/netwerk/base/PrivateBrowsingChannel.h
@@ -9,16 +9,17 @@
 
 #include "nsIPrivateBrowsingChannel.h"
 #include "nsCOMPtr.h"
 #include "nsILoadGroup.h"
 #include "nsILoadContext.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsNetUtil.h"
+#include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace net {
 
 template <class Channel>
 class PrivateBrowsingChannel : public nsIPrivateBrowsingChannel
 {
 public:
@@ -66,20 +67,30 @@ public:
   // Must be called every time the channel's callbacks or loadGroup is updated
   void UpdatePrivateBrowsing()
   {
       // once marked as private we never go un-private
       if (mPrivateBrowsing) {
           return;
       }
 
+      auto channel = static_cast<Channel*>(this);
+
       nsCOMPtr<nsILoadContext> loadContext;
-      NS_QueryNotificationCallbacks(static_cast<Channel*>(this), loadContext);
+      NS_QueryNotificationCallbacks(channel, loadContext);
       if (loadContext) {
           mPrivateBrowsing = loadContext->UsePrivateBrowsing();
+          return;
+      }
+
+      nsCOMPtr<nsILoadInfo> loadInfo;
+      Unused << channel->GetLoadInfo(getter_AddRefs(loadInfo));
+      if (loadInfo) {
+          NeckoOriginAttributes attrs = loadInfo->GetOriginAttributes();
+          mPrivateBrowsing = attrs.mPrivateBrowsingId > 0;
       }
   }
 
   bool CanSetCallbacks(nsIInterfaceRequestor* aCallbacks) const
   {
       // Make sure that the private bit override flag is not set.
       // This is a fatal error in debug builds, and a runtime error in release
       // builds.