Backed out changeset dbf610ddefe1 (bug 1505198) for conflicts when backing out bug 1504728. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Fri, 09 Nov 2018 18:47:14 +0200
changeset 501879 bb493144227655b461d0e482f7e75b0e56ff20fc
parent 501878 948718214f0b2ec4c9d8b6fca73fbca50c211239
child 501880 447536cc6c984ae06ae44a25194d5612fad6628b
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1505198, 1504728
milestone65.0a1
backs outdbf610ddefe12d639e3d39881729a38bce871164
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 dbf610ddefe1 (bug 1505198) for conflicts when backing out bug 1504728. CLOSED TREE
dom/base/ContentBlockingLog.h
toolkit/components/antitracking/test/browser/browser_subResources.js
--- a/dom/base/ContentBlockingLog.h
+++ b/dom/base/ContentBlockingLog.h
@@ -3,19 +3,17 @@
 /* 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/. */
 
 #ifndef mozilla_dom_ContentBlockingLog_h
 #define mozilla_dom_ContentBlockingLog_h
 
 #include "mozilla/JSONWriter.h"
-#include "mozilla/Maybe.h"
 #include "mozilla/StaticPrefs.h"
-#include "mozilla/Tuple.h"
 #include "mozilla/UniquePtr.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
 #include "nsReadableUtils.h"
 #include "nsTArray.h"
 #include "nsWindowSizes.h"
 
 namespace mozilla {
@@ -27,17 +25,17 @@ class ContentBlockingLog final
     uint32_t mType;
     uint32_t mRepeatCount;
     bool mBlocked;
   };
 
   // Each element is a tuple of (type, blocked, repeatCount). The type values
   // come from the blocking types defined in nsIWebProgressListener.
   typedef nsTArray<LogEntry> OriginLog;
-  typedef Tuple<bool, Maybe<bool>, OriginLog> OriginData;
+  typedef Pair<bool, OriginLog> OriginData;
   typedef nsClassHashtable<nsStringHashKey, OriginData> OriginDataHashTable;
 
   struct StringWriteFunc : public JSONWriteFunc
   {
     nsAString& mBuffer; // The lifetime of the struct must be bound to the buffer
     explicit StringWriteFunc(nsAString& aBuffer)
       : mBuffer(aBuffer)
     {}
@@ -56,28 +54,20 @@ public:
   {
     if (aOrigin.IsVoid()) {
       return;
     }
     auto entry = mLog.LookupForAdd(aOrigin);
     if (entry) {
       auto& data = entry.Data();
       if (aType == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
-        Get<0>(*data) = aBlocked;
+        data->first() = aBlocked;
         return;
       }
-      if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED) {
-        if (Get<1>(*data).isSome()) {
-          Get<1>(*data).ref() = aBlocked;
-        } else {
-          Get<1>(*data).emplace(aBlocked);
-        }
-        return;
-      }
-      auto& log = Get<2>(*data);
+      auto& log = data->second();
       if (!log.IsEmpty()) {
         auto& last = log.LastElement();
         if (last.mType == aType &&
             last.mBlocked == aBlocked) {
           ++last.mRepeatCount;
           // Don't record recorded events.  This helps compress our log.
           return;
         }
@@ -85,27 +75,21 @@ public:
       if (log.Length() ==
             std::max(1u, StaticPrefs::browser_contentblocking_originlog_length())) {
         // Cap the size at the maximum length adjustable by the pref
         log.RemoveElementAt(0);
       }
       log.AppendElement(LogEntry{aType, 1u, aBlocked});
     } else {
       entry.OrInsert([=] {
-        nsAutoPtr<OriginData> data(new OriginData(false, Maybe<bool>(), OriginLog()));
+        nsAutoPtr<OriginData> data(new OriginData(false, OriginLog()));
         if (aType == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
-          Get<0>(*data) = aBlocked;
-        } else if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED) {
-          if (Get<1>(*data).isSome()) {
-            Get<1>(*data).ref() = aBlocked;
-          } else {
-            Get<1>(*data).emplace(aBlocked);
-          }
+          data->first() = true;
         } else {
-          Get<2>(*data).AppendElement(LogEntry{aType, 1u, aBlocked});
+          data->second().AppendElement(LogEntry{aType, 1u, aBlocked});
         }
         return data.forget();
       });
     }
   }
 
   nsAutoString Stringify()
   {
@@ -118,35 +102,26 @@ public:
       if (!iter.UserData()) {
         w.StartArrayProperty(NS_ConvertUTF16toUTF8(iter.Key()).get(), w.SingleLineStyle);
         w.EndArray();
         continue;
       }
 
       w.StartArrayProperty(NS_ConvertUTF16toUTF8(iter.Key()).get(), w.SingleLineStyle);
       auto& data = *iter.UserData();
-      if (Get<0>(data)) {
+      if (data.first()) {
         w.StartArrayElement(w.SingleLineStyle);
         {
           w.IntElement(nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT);
           w.BoolElement(true); // blocked
           w.IntElement(1);     // repeat count
         }
         w.EndArray();
       }
-      if (Get<1>(data).isSome()) {
-        w.StartArrayElement(w.SingleLineStyle);
-        {
-          w.IntElement(nsIWebProgressListener::STATE_COOKIES_LOADED);
-          w.BoolElement(Get<1>(data).value()); // blocked
-          w.IntElement(1);                     // repeat count
-        }
-        w.EndArray();
-      }
-      for (auto& item: Get<2>(data)) {
+      for (auto& item: data.second()) {
         w.StartArrayElement(w.SingleLineStyle);
         {
           w.IntElement(item.mType);
           w.BoolElement(item.mBlocked);
           w.IntElement(item.mRepeatCount);
         }
         w.EndArray();
       }
@@ -161,26 +136,21 @@ public:
   bool HasBlockedAnyOfType(uint32_t aType)
   {
     for (auto iter = mLog.Iter(); !iter.Done(); iter.Next()) {
       if (!iter.UserData()) {
         continue;
       }
 
       if (aType == nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT) {
-        if (Get<0>(*iter.UserData())) {
+        if (iter.UserData()->first()) {
           return true;
         }
-      } else if (aType == nsIWebProgressListener::STATE_COOKIES_LOADED) {
-        if (Get<1>(*iter.UserData()).isSome()) {
-          return Get<1>(*iter.UserData()).value();
-        }
-        return true; // true means blocked, aka not loaded any cookies
       } else {
-        for (auto& item: Get<2>(*iter.UserData())) {
+        for (auto& item: iter.UserData()->second()) {
           if ((item.mType & aType) != 0) {
             return true;
           }
         }
       }
     }
     return false;
   }
@@ -191,17 +161,17 @@ public:
 
     // Now add the sizes of each origin log queue.
     // The const_cast is needed because the nsTHashtable::Iterator interface is
     // not const-safe.  :-(
     for (auto iter = const_cast<OriginDataHashTable&>(mLog).Iter();
          !iter.Done(); iter.Next()) {
       if (iter.UserData()) {
         aSizes.mDOMOtherSize +=
-          Get<2>(*iter.UserData()).ShallowSizeOfIncludingThis(aSizes.mState.mMallocSizeOf);
+          iter.UserData()->second().ShallowSizeOfIncludingThis(aSizes.mState.mMallocSizeOf);
       }
     }
   }
 
 private:
   OriginDataHashTable mLog;
 };
 
--- a/toolkit/components/antitracking/test/browser/browser_subResources.js
+++ b/toolkit/components/antitracking/test/browser/browser_subResources.js
@@ -182,21 +182,33 @@ add_task(async function() {
     ok(item[2] >= 1,
        "Correct repeat count reported");
   };
 
   let log = JSON.parse(await browser.getContentBlockingLog());
   for (let trackerOrigin in log) {
     is(trackerOrigin, TEST_3RD_PARTY_DOMAIN, "Correct tracker origin must be reported");
     let originLog = log[trackerOrigin];
-    is(originLog.length, 4, "We should have 4 entries in the compressed log");
+    is(originLog.length, 16, "We should have 16 entries in the compressed log");
     expectTrackerFound(originLog[0]);
     expectCookiesLoaded(originLog[1]);
     expectTrackerBlocked(originLog[2], true);
-    expectTrackerBlocked(originLog[3], false);
+    expectCookiesLoaded(originLog[3]);
+    expectTrackerBlocked(originLog[4], true);
+    expectCookiesLoaded(originLog[5]);
+    expectTrackerBlocked(originLog[6], true);
+    expectCookiesLoaded(originLog[7]);
+    expectTrackerBlocked(originLog[8], true);
+    expectCookiesLoaded(originLog[9]);
+    expectTrackerBlocked(originLog[10], true);
+    expectCookiesLoaded(originLog[11]);
+    expectTrackerBlocked(originLog[12], true);
+    expectCookiesLoaded(originLog[13]);
+    expectTrackerBlocked(originLog[14], false);
+    expectCookiesLoaded(originLog[15]);
   }
 
   info("Removing the tab");
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function() {
   info("Cleaning up.");