Bug 1640135 - P4: update usage of PartitionKey; r=timhuang
authorLiang-Heng Chen <xeonchen@gmail.com>
Thu, 04 Jun 2020 10:51:21 +0000
changeset 533871 64399b8f0d7c0029a4d80b2e723228e7e5347a09
parent 533870 bd311336daa756c251f5b6a970ba638f7575a7b0
child 533872 f318f0c9b8f38f9e69eaa587d855f147ecff3e78
push id37479
push userapavel@mozilla.com
push dateThu, 04 Jun 2020 15:32:20 +0000
treeherdermozilla-central@0d21bdf3fc01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimhuang
bugs1640135
milestone79.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 1640135 - P4: update usage of PartitionKey; r=timhuang Differential Revision: https://phabricator.services.mozilla.com/D77917
dom/base/Document.cpp
netwerk/cookie/CookieJarSettings.cpp
netwerk/cookie/CookieJarSettings.h
netwerk/cookie/CookieService.cpp
netwerk/cookie/nsICookieJarSettings.idl
netwerk/ipc/NeckoChannelParams.ipdlh
netwerk/protocol/http/nsHttpChannel.cpp
toolkit/components/antitracking/StoragePrincipalHelper.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -16233,17 +16233,17 @@ nsICookieJarSettings* Document::CookieJa
     Document* inProcessParent = GetInProcessParentDocument();
 
     mCookieJarSettings =
         inProcessParent
             ? net::CookieJarSettings::Create(
                   inProcessParent->CookieJarSettings()->GetCookieBehavior(),
                   mozilla::net::CookieJarSettings::Cast(
                       inProcessParent->CookieJarSettings())
-                      ->GetFirstPartyDomain(),
+                      ->GetPartitionKey(),
                   inProcessParent->CookieJarSettings()
                       ->GetIsFirstPartyIsolated())
             : net::CookieJarSettings::Create();
 
     if (auto* wgc = GetWindowGlobalChild()) {
       net::CookieJarSettingsArgs csArgs;
       net::CookieJarSettings::Cast(mCookieJarSettings)->Serialize(csArgs);
       // Update cookie settings in the parent process
--- a/netwerk/cookie/CookieJarSettings.cpp
+++ b/netwerk/cookie/CookieJarSettings.cpp
@@ -98,23 +98,23 @@ already_AddRefed<nsICookieJarSettings> C
   RefPtr<CookieJarSettings> cookieJarSettings = new CookieJarSettings(
       nsICookieManager::GetCookieBehavior(),
       OriginAttributes::IsFirstPartyEnabled(), eProgressive);
   return cookieJarSettings.forget();
 }
 
 // static
 already_AddRefed<nsICookieJarSettings> CookieJarSettings::Create(
-    uint32_t aCookieBehavior, const nsAString& aFirstPartyDomain,
+    uint32_t aCookieBehavior, const nsAString& aPartitionKey,
     bool aIsFirstPartyIsolated) {
   MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<CookieJarSettings> cookieJarSettings = new CookieJarSettings(
       aCookieBehavior, aIsFirstPartyIsolated, eProgressive);
-  cookieJarSettings->mFirstPartyDomain = aFirstPartyDomain;
+  cookieJarSettings->mPartitionKey = aPartitionKey;
 
   return cookieJarSettings.forget();
 }
 
 CookieJarSettings::CookieJarSettings(uint32_t aCookieBehavior,
                                      bool aIsFirstPartyIsolated, State aState)
     : mCookieBehavior(aCookieBehavior),
       mIsFirstPartyIsolated(aIsFirstPartyIsolated),
@@ -191,18 +191,18 @@ CookieJarSettings::SetPartitionForeign(b
 NS_IMETHODIMP
 CookieJarSettings::GetIsOnContentBlockingAllowList(
     bool* aIsOnContentBlockingAllowList) {
   *aIsOnContentBlockingAllowList = mIsOnContentBlockingAllowList;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-CookieJarSettings::GetFirstPartyDomain(nsAString& aFirstPartyDomain) {
-  aFirstPartyDomain = mFirstPartyDomain;
+CookieJarSettings::GetPartitionKey(nsAString& aPartitionKey) {
+  aPartitionKey = mPartitionKey;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 CookieJarSettings::CookiePermission(nsIPrincipal* aPrincipal,
                                     uint32_t* aCookiePermission) {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_ARG_POINTER(aPrincipal);
@@ -277,17 +277,17 @@ CookieJarSettings::CookiePermission(nsIP
 
 void CookieJarSettings::Serialize(CookieJarSettingsArgs& aData) {
   MOZ_ASSERT(NS_IsMainThread());
 
   aData.isFixed() = mState == eFixed;
   aData.cookieBehavior() = mCookieBehavior;
   aData.isFirstPartyIsolated() = mIsFirstPartyIsolated;
   aData.isOnContentBlockingAllowList() = mIsOnContentBlockingAllowList;
-  aData.firstPartyDomain() = mFirstPartyDomain;
+  aData.partitionKey() = mPartitionKey;
 
   for (const RefPtr<nsIPermission>& permission : mCookiePermissions) {
     nsCOMPtr<nsIPrincipal> principal;
     nsresult rv = permission->GetPrincipal(getter_AddRefs(principal));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       continue;
     }
 
@@ -337,17 +337,17 @@ void CookieJarSettings::Serialize(Cookie
 
   RefPtr<CookieJarSettings> cookieJarSettings = new CookieJarSettings(
       aData.cookieBehavior(), aData.isFirstPartyIsolated(),
       aData.isFixed() ? eFixed : eProgressive);
 
   cookieJarSettings->mIsOnContentBlockingAllowList =
       aData.isOnContentBlockingAllowList();
   cookieJarSettings->mCookiePermissions.SwapElements(list);
-  cookieJarSettings->mFirstPartyDomain = aData.firstPartyDomain();
+  cookieJarSettings->mPartitionKey = aData.partitionKey();
 
   cookieJarSettings.forget(aCookieJarSettings);
 }
 
 void CookieJarSettings::Merge(const CookieJarSettingsArgs& aData) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(
       mCookieBehavior == aData.cookieBehavior() ||
@@ -406,22 +406,22 @@ void CookieJarSettings::Merge(const Cook
     }
 
     if (!mCookiePermissions.Contains(permission, comparator)) {
       mCookiePermissions.AppendElement(permission);
     }
   }
 }
 
-void CookieJarSettings::SetFirstPartyDomain(nsIURI* aURI) {
+void CookieJarSettings::SetPartitionKey(nsIURI* aURI) {
   MOZ_ASSERT(aURI);
 
   OriginAttributes attrs;
-  attrs.SetFirstPartyDomain(true, aURI, true);
-  mFirstPartyDomain = std::move(attrs.mFirstPartyDomain);
+  attrs.SetPartitionKey(aURI);
+  mPartitionKey = std::move(attrs.mPartitionKey);
 }
 
 void CookieJarSettings::UpdateIsOnContentBlockingAllowList(
     nsIChannel* aChannel) {
   MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(aChannel);
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
 
--- a/netwerk/cookie/CookieJarSettings.h
+++ b/netwerk/cookie/CookieJarSettings.h
@@ -112,17 +112,17 @@ class CookieJarSettings final : public n
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSICOOKIEJARSETTINGS
 
   static already_AddRefed<nsICookieJarSettings> GetBlockingAll();
 
   static already_AddRefed<nsICookieJarSettings> Create();
 
   static already_AddRefed<nsICookieJarSettings> Create(
-      uint32_t aCookieBehavior, const nsAString& aFirstPartyDomain,
+      uint32_t aCookieBehavior, const nsAString& aPartitionKey,
       bool aIsFirstPartyIsolated);
 
   static CookieJarSettings* Cast(nsICookieJarSettings* aCS) {
     return static_cast<CookieJarSettings*>(aCS);
   }
 
   void Serialize(CookieJarSettingsArgs& aData);
 
@@ -133,18 +133,18 @@ class CookieJarSettings final : public n
 
   // We don't want to send this object from parent to child process if there are
   // no reasons. HasBeenChanged() returns true if the object has changed its
   // internal state and it must be sent beck to the content process.
   bool HasBeenChanged() const { return mToBeMerged; }
 
   void UpdateIsOnContentBlockingAllowList(nsIChannel* aChannel);
 
-  void SetFirstPartyDomain(nsIURI* aURI);
-  const nsAString& GetFirstPartyDomain() { return mFirstPartyDomain; };
+  void SetPartitionKey(nsIURI* aURI);
+  const nsAString& GetPartitionKey() { return mPartitionKey; };
 
   // Utility function to test if the passed cookiebahvior is
   // BEHAVIOR_REJECT_TRACKER, BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN or
   // BEHAVIOR_REJECT_FOREIGN when
   // network.cookie.rejectForeignWithExceptions.enabled pref is set to true.
   static bool IsRejectThirdPartyContexts(uint32_t aCookieBehavior);
 
   // This static method returns true if aCookieBehavior is
@@ -165,17 +165,17 @@ class CookieJarSettings final : public n
   CookieJarSettings(uint32_t aCookieBehavior, bool aIsFirstPartyIsolated,
                     State aState);
   ~CookieJarSettings();
 
   uint32_t mCookieBehavior;
   bool mIsFirstPartyIsolated;
   CookiePermissionList mCookiePermissions;
   bool mIsOnContentBlockingAllowList;
-  nsString mFirstPartyDomain;
+  nsString mPartitionKey;
 
   State mState;
 
   bool mToBeMerged;
 };
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/cookie/CookieService.cpp
+++ b/netwerk/cookie/CookieService.cpp
@@ -1526,17 +1526,17 @@ CookieStatus CookieService::CheckPrefs(n
         CookieJarSettings::IsRejectThirdPartyWithExceptions(
             aCookieJarSettings->GetCookieBehavior());
 
     uint32_t rejectReason =
         rejectThirdPartyWithExceptions
             ? nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
             : nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
     if (StoragePartitioningEnabled(rejectReason, aCookieJarSettings)) {
-      MOZ_ASSERT(!aOriginAttrs.mFirstPartyDomain.IsEmpty(),
+      MOZ_ASSERT(!aOriginAttrs.mPartitionKey.IsEmpty(),
                  "We must have a StoragePrincipal here!");
       return STATUS_ACCEPTED;
     }
 
     COOKIE_LOGFAILURE(aCookieHeader.IsVoid() ? GET_COOKIE : SET_COOKIE,
                       aHostURI, aCookieHeader,
                       "cookies are disabled in trackers");
     if (aIsThirdPartySocialTrackingResource) {
--- a/netwerk/cookie/nsICookieJarSettings.idl
+++ b/netwerk/cookie/nsICookieJarSettings.idl
@@ -40,19 +40,19 @@ interface nsICookieJarSettings : nsISupp
   [infallible] attribute boolean partitionForeign;
 
   /**
    * Whether the top-level document is on the content blocking allow list.
    */
   [infallible] readonly attribute boolean isOnContentBlockingAllowList;
 
   /**
-   * The domain for the top-level document.
+   * The key used for partitioning.
    */
-  readonly attribute AString firstPartyDomain;
+  readonly attribute AString partitionKey;
 
   /**
    * CookiePermission at the loading of the document for a particular
    * principal. It returns the same cookiePermission also in case it changes
    * during the life-time of the top document.
    */
   unsigned long cookiePermission(in nsIPrincipal aPrincipal);
 };
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -42,17 +42,17 @@ struct CookiePermissionData
 struct CookieJarSettingsArgs
 {
   // Copy of the cookie jar settings for the top-level document.
   uint32_t cookieBehavior;
   bool isFirstPartyIsolated;
   bool isOnContentBlockingAllowList;
   CookiePermissionData[] cookiePermissions;
   bool isFixed;
-  nsString firstPartyDomain;
+  nsString partitionKey;
 };
 
 //-----------------------------------------------------------------------------
 // Preferrer alternative data type
 //-----------------------------------------------------------------------------
 
 struct PreferredAlternativeDataTypeParams
 {
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1864,17 +1864,17 @@ void nsHttpChannel::UpdateAntiTrackingIn
     // if this is a top level loading. For sub-document loading, this flag
     // would inherit from the parent.
     mozilla::net::CookieJarSettings::Cast(cookieJarSettings)
         ->UpdateIsOnContentBlockingAllowList(this);
 
     // We only need to set FPD for top-level loads. FPD will automatically be
     // propagated to non-top level loads via CookieJarSetting.
     mozilla::net::CookieJarSettings::Cast(cookieJarSettings)
-        ->SetFirstPartyDomain(mURI);
+        ->SetPartitionKey(mURI);
   }
 }
 
 nsresult nsHttpChannel::CallOnStartRequest() {
   LOG(("nsHttpChannel::CallOnStartRequest [this=%p]", this));
 
   MOZ_RELEASE_ASSERT(!mRequireCORSPreflight || mIsCorsPreflightDone,
                      "CORS preflight must have been finished by the time we "
--- a/toolkit/components/antitracking/StoragePrincipalHelper.cpp
+++ b/toolkit/components/antitracking/StoragePrincipalHelper.cpp
@@ -43,17 +43,17 @@ bool ChooseOriginAttributes(nsIChannel* 
     // check doesn't send notifications.
     if (!ShouldPartitionStorage(rejectedReason) ||
         !StoragePartitioningEnabled(rejectedReason, cjs)) {
       return false;
     }
   }
 
   nsAutoString partitionKey;
-  Unused << cjs->GetFirstPartyDomain(partitionKey);
+  Unused << cjs->GetPartitionKey(partitionKey);
 
   if (!partitionKey.IsEmpty()) {
     aAttrs.SetPartitionKey(partitionKey);
     return true;
   }
 
   // Fallback to get first-party domain from top-level principal when we can't
   // get it from CookieJarSetting. This might happen when a channel is not