Bug 1244340 - Part 1: Use origin attributes as cstor arg for LoadContext r=sicking
authorYoshi Huang <allstars.chh@mozilla.com>
Thu, 19 May 2016 15:49:41 +0800
changeset 311333 4a18d3c8af3c1aadfecb373ac72818a2c35ba6b3
parent 311332 e5a3913dec6f1a7fce9a7511f912302e83740c04
child 311334 8627e28f153d281e534170932957092abdc7c0c8
push id81106
push useryhuang@mozilla.com
push dateFri, 26 Aug 2016 10:59:21 +0000
treeherdermozilla-inbound@bc99aaf0d06f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1244340
milestone51.0a1
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
Bug 1244340 - Part 1: Use origin attributes as cstor arg for LoadContext r=sicking
docshell/base/LoadContext.h
toolkit/components/downloads/ApplicationReputation.cpp
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
--- a/docshell/base/LoadContext.h
+++ b/docshell/base/LoadContext.h
@@ -88,24 +88,24 @@ public:
     , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
   {
     MOZ_ASSERT(aUsePrivateBrowsing == (aAttrs.mPrivateBrowsingId != 0));
   }
 
-  // Constructor taking reserved appId for the safebrowsing cookie.
-  explicit LoadContext(uint32_t aAppId)
+  // Constructor taking reserved origin attributes.
+  explicit LoadContext(DocShellOriginAttributes& aAttrs)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(0)
     , mIsContent(false)
-    , mUsePrivateBrowsing(false)
+    , mUsePrivateBrowsing(aAttrs.mPrivateBrowsingId != 0)
     , mUseRemoteTabs(false)
-    , mOriginAttributes(aAppId, false)
+    , mOriginAttributes(aAttrs)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
   {
   }
 
   // Constructor for creating a LoadContext with a given principal's appId and
   // browser flag.
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ b/toolkit/components/downloads/ApplicationReputation.cpp
@@ -47,16 +47,17 @@
 #include "nsThreadUtils.h"
 #include "nsXPCOMStrings.h"
 
 #include "nsIContentPolicy.h"
 #include "nsILoadInfo.h"
 #include "nsContentUtils.h"
 
 using mozilla::BasePrincipal;
+using mozilla::DocShellOriginAttributes;
 using mozilla::PrincipalOriginAttributes;
 using mozilla::Preferences;
 using mozilla::TimeStamp;
 using mozilla::Telemetry::Accumulate;
 using safe_browsing::ClientDownloadRequest;
 using safe_browsing::ClientDownloadRequest_CertificateChain;
 using safe_browsing::ClientDownloadRequest_Resource;
 using safe_browsing::ClientDownloadRequest_SignatureInfo;
@@ -1277,18 +1278,19 @@ PendingLookup::SendRemoteQueryInternal()
 
   rv = uploadChannel->ExplicitSetUploadStream(sstream,
     NS_LITERAL_CSTRING("application/octet-stream"), serialized.size(),
     NS_LITERAL_CSTRING("POST"), false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Set the Safebrowsing cookie jar, so that the regular Google cookie is not
   // sent with this request. See bug 897516.
-  nsCOMPtr<nsIInterfaceRequestor> loadContext =
-    new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID);
+  DocShellOriginAttributes attrs;
+  attrs.mAppId = NECKO_SAFEBROWSING_APP_ID;
+  nsCOMPtr<nsIInterfaceRequestor> loadContext = new mozilla::LoadContext(attrs);
   rv = mChannel->SetNotificationCallbacks(loadContext);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t timeoutMs = Preferences::GetUint(PREF_SB_DOWNLOADS_REMOTE_TIMEOUT, 10000);
   mTimeoutTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
   mTimeoutTimer->InitWithCallback(this, timeoutMs, nsITimer::TYPE_ONE_SHOT);
 
   rv = mChannel->AsyncOpen2(this);
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -19,16 +19,18 @@
 #include "mozilla/ErrorNames.h"
 #include "mozilla/Logging.h"
 #include "nsIInterfaceRequestor.h"
 #include "mozilla/LoadContext.h"
 #include "mozilla/Telemetry.h"
 #include "nsContentUtils.h"
 #include "nsIURLFormatter.h"
 
+using mozilla::DocShellOriginAttributes;
+
 static const char* gQuitApplicationMessage = "quit-application";
 
 // Limit the list file size to 32mb
 const uint32_t MAX_FILE_SIZE = (32 * 1024 * 1024);
 
 #undef LOG
 
 // MOZ_LOG=UrlClassifierStreamUpdater:5
@@ -173,18 +175,19 @@ nsUrlClassifierStreamUpdater::FetchUpdat
     NS_ENSURE_SUCCESS(rv, rv);
     rv = httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Connection"), NS_LITERAL_CSTRING("close"), false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Create a custom LoadContext for SafeBrowsing, so we can use callbacks on
   // the channel to query the appId which allows separation of safebrowsing
   // cookies in a separate jar.
-  nsCOMPtr<nsIInterfaceRequestor> sbContext =
-    new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID);
+  DocShellOriginAttributes attrs;
+  attrs.mAppId = NECKO_SAFEBROWSING_APP_ID;
+  nsCOMPtr<nsIInterfaceRequestor> sbContext = new mozilla::LoadContext(attrs);
   rv = mChannel->SetNotificationCallbacks(sbContext);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Make the request.
   rv = mChannel->AsyncOpen2(this);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mStreamTable = aStreamTable;