Bug 1620322 - Part 9: Move ContentBlockingLog to antitracking to keep all related code together in the same place; r=baku
☠☠ backed out by 5b47cfcab155 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 09 Mar 2020 18:12:42 +0000
changeset 517657 f41739c64dff7f559754d90f993b5abe60f5f8a1
parent 517656 be942a7f329e12b591f318c11f9d09caab59fc6f
child 517658 e0291795a75011884160c92ff363bd2873bc4524
push id37199
push useropoprus@mozilla.com
push dateTue, 10 Mar 2020 03:43:44 +0000
treeherdermozilla-central@6f21f98dcfcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1620322
milestone75.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 1620322 - Part 9: Move ContentBlockingLog to antitracking to keep all related code together in the same place; r=baku Differential Revision: https://phabricator.services.mozilla.com/D65822
dom/base/ContentBlockingLog.cpp
dom/base/ContentBlockingLog.h
dom/base/Document.h
dom/base/moz.build
dom/base/nsWindowRoot.cpp
dom/ipc/WindowGlobalParent.h
dom/media/MediaCache.cpp
dom/reporting/CrashReport.cpp
image/imgFrame.cpp
js/xpconnect/src/XPCJSContext.cpp
layout/style/GeckoBindings.cpp
toolkit/components/antitracking/ContentBlockingLog.cpp
toolkit/components/antitracking/ContentBlockingLog.h
toolkit/components/antitracking/moz.build
toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -43,21 +43,21 @@
 #include "nsURIHashKey.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/UseCounter.h"
 #include "mozilla/WeakPtr.h"
 #include "Units.h"
 #include "nsContentListDeclarations.h"
 #include "nsExpirationTracker.h"
 #include "nsClassHashtable.h"
+#include "nsWindowSizes.h"
 #include "ReferrerInfo.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CallState.h"
 #include "mozilla/CORSMode.h"
-#include "mozilla/dom/ContentBlockingLog.h"
 #include "mozilla/dom/DispatcherTrait.h"
 #include "mozilla/dom/DocumentOrShadowRoot.h"
 #include "mozilla/dom/ViewportMetaData.h"
 #include "mozilla/HashTable.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/SegmentedVector.h"
 #include "mozilla/TimeStamp.h"
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -151,17 +151,16 @@ EXPORTS.mozilla.dom += [
     'CharacterData.h',
     'ChildIterator.h',
     'ChildProcessMessageManager.h',
     'ChromeMessageBroadcaster.h',
     'ChromeMessageSender.h',
     'ChromeNodeList.h',
     'ChromeUtils.h',
     'Comment.h',
-    'ContentBlockingLog.h',
     'ContentFrameMessageManager.h',
     'ContentProcessMessageManager.h',
     'CustomElementRegistry.h',
     'DirectionalityUtils.h',
     'DispatcherTrait.h',
     'DocGroup.h',
     'Document.h',
     'DocumentFragment.h',
@@ -275,17 +274,16 @@ UNIFIED_SOURCES += [
     'BorrowedAttrInfo.cpp',
     'CharacterData.cpp',
     'ChildIterator.cpp',
     'ChromeMessageBroadcaster.cpp',
     'ChromeMessageSender.cpp',
     'ChromeNodeList.cpp',
     'ChromeUtils.cpp',
     'Comment.cpp',
-    'ContentBlockingLog.cpp',
     'ContentFrameMessageManager.cpp',
     'ContentIterator.cpp',
     'ContentProcessMessageManager.cpp',
     'Crypto.cpp',
     'CustomElementRegistry.cpp',
     'DirectionalityUtils.cpp',
     'DispatcherTrait.cpp',
     'DocGroup.cpp',
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "mozilla/BasicEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventListenerManager.h"
+#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/dom/WindowRootBinding.h"
 #include "nsCOMPtr.h"
 #include "nsWindowRoot.h"
 #include "nsPIDOMWindow.h"
 #include "nsPresContext.h"
 #include "nsLayoutCID.h"
 #include "nsContentCID.h"
 #include "nsString.h"
--- a/dom/ipc/WindowGlobalParent.h
+++ b/dom/ipc/WindowGlobalParent.h
@@ -2,28 +2,28 @@
 /* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
 /* 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_WindowGlobalParent_h
 #define mozilla_dom_WindowGlobalParent_h
 
+#include "mozilla/ContentBlockingLog.h"
 #include "mozilla/ContentBlockingNotifier.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/dom/DOMRect.h"
 #include "mozilla/dom/PWindowGlobalParent.h"
 #include "mozilla/dom/BrowserParent.h"
 #include "mozilla/dom/WindowContext.h"
 #include "nsRefPtrHashtable.h"
 #include "nsWrapperCache.h"
 #include "nsISupports.h"
 #include "mozilla/dom/WindowGlobalActor.h"
 #include "mozilla/dom/CanonicalBrowsingContext.h"
-#include "mozilla/dom/ContentBlockingLog.h"
 
 class nsIPrincipal;
 class nsIURI;
 class nsFrameLoader;
 
 namespace mozilla {
 
 namespace gfx {
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -14,16 +14,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_media.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/Telemetry.h"
 #include "nsContentUtils.h"
 #include "nsINetworkLinkService.h"
 #include "nsIObserverService.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
--- a/dom/reporting/CrashReport.cpp
+++ b/dom/reporting/CrashReport.cpp
@@ -4,16 +4,17 @@
  * 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/. */
 
 #include "mozilla/dom/CrashReport.h"
 
 #include "mozilla/dom/Navigator.h"
 #include "mozilla/dom/ReportingHeader.h"
 #include "mozilla/dom/ReportDeliver.h"
+#include "mozilla/JSONWriter.h"
 #include "nsIPrincipal.h"
 #include "nsIURIMutator.h"
 #include "nsString.h"
 
 namespace mozilla {
 namespace dom {
 
 struct StringWriteFunc : public JSONWriteFunc {
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -22,16 +22,17 @@
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/Tools.h"
 #include "mozilla/gfx/SourceSurfaceRawData.h"
 #include "mozilla/image/RecyclingSourceSurface.h"
 #include "mozilla/layers/SourceSurfaceSharedData.h"
 #include "mozilla/layers/SourceSurfaceVolatileData.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/StaticPrefs_browser.h"
 #include "nsMargin.h"
 #include "nsRefreshDriver.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 
 using namespace gfx;
 
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -23,16 +23,17 @@
 #include "nsPIDOMWindow.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
 #ifdef FUZZING
 #  include "mozilla/StaticPrefs_fuzzing.h"
 #endif
+#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_javascript.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollector.h"
 #include "jsapi.h"
--- a/layout/style/GeckoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -50,16 +50,17 @@
 #include "mozilla/EventStates.h"
 #include "mozilla/FontPropertyTypes.h"
 #include "mozilla/Keyframe.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ServoElementSnapshot.h"
 #include "mozilla/ShadowParts.h"
 #include "mozilla/StaticPresData.h"
+#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/SizeOfState.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoTraversalStatistics.h"
 #include "mozilla/Telemetry.h"
rename from dom/base/ContentBlockingLog.cpp
rename to toolkit/components/antitracking/ContentBlockingLog.cpp
--- a/dom/base/ContentBlockingLog.cpp
+++ b/toolkit/components/antitracking/ContentBlockingLog.cpp
@@ -25,18 +25,16 @@ namespace mozilla {
 using ipc::AutoIPCStream;
 
 static LazyLogModule gContentBlockingLog("ContentBlockingLog");
 #define LOG(fmt, ...) \
   MOZ_LOG(gContentBlockingLog, LogLevel::Debug, (fmt, ##__VA_ARGS__))
 
 typedef Telemetry::OriginMetricID OriginMetricID;
 
-namespace dom {
-
 // sync with TelemetryOriginData.inc
 NS_NAMED_LITERAL_CSTRING(ContentBlockingLog::kDummyOriginHash, "PAGELOAD");
 
 // randomly choose 1% users included in the content blocking measurement
 // based on their client id.
 static constexpr double kRatioReportUser = 0.01;
 
 // randomly choose 0.14% documents when the page is unload.
@@ -288,10 +286,9 @@ void ContentBlockingLog::ReportOrigins()
         lookupTable.AppendElement(key);
         ReportOriginSingleHash(metricId, hash);
       }
       break;
     }
   }
 }
 
-}  // namespace dom
 }  // namespace mozilla
rename from dom/base/ContentBlockingLog.h
rename to toolkit/components/antitracking/ContentBlockingLog.h
--- a/dom/base/ContentBlockingLog.h
+++ b/toolkit/components/antitracking/ContentBlockingLog.h
@@ -1,32 +1,31 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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
+#ifndef mozilla_ContentBlockingLog_h
+#define mozilla_ContentBlockingLog_h
 
 #include "mozilla/ContentBlockingNotifier.h"
 #include "mozilla/JSONWriter.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/UniquePtr.h"
 #include "nsIWebProgressListener.h"
 #include "nsReadableUtils.h"
 #include "nsTArray.h"
 #include "nsWindowSizes.h"
 
 class nsIPrincipal;
 
 namespace mozilla {
-namespace dom {
 
 class ContentBlockingLog final {
   typedef ContentBlockingNotifier::StorageAccessGrantedReason
       StorageAccessGrantedReason;
 
   struct LogEntry {
     uint32_t mType;
     uint32_t mRepeatCount;
@@ -421,12 +420,11 @@ class ContentBlockingLog final {
       aWriter.EndArray();
     }
   }
 
  private:
   OriginDataTable mLog;
 };
 
-}  // namespace dom
 }  // namespace mozilla
 
 #endif
--- a/toolkit/components/antitracking/moz.build
+++ b/toolkit/components/antitracking/moz.build
@@ -31,28 +31,30 @@ XPCOM_MANIFESTS += [
 ]
 
 EXPORTS.mozilla = [
     'AntiTrackingIPCUtils.h',
     'AntiTrackingRedirectHeuristic.h',
     'AntiTrackingUtils.h',
     'ContentBlocking.h',
     'ContentBlockingAllowList.h',
+    'ContentBlockingLog.h',
     'ContentBlockingNotifier.h',
     'ContentBlockingUserInteraction.h',
     'StorageAccess.h',
     'StoragePrincipalHelper.h',
     'URLDecorationStripper.h',
 ]
 
 UNIFIED_SOURCES += [
     'AntiTrackingRedirectHeuristic.cpp',
     'AntiTrackingUtils.cpp',
     'ContentBlocking.cpp',
     'ContentBlockingAllowList.cpp',
+    'ContentBlockingLog.cpp',
     'ContentBlockingNotifier.cpp',
     'ContentBlockingUserInteraction.cpp',
     'SettingsChangeObserver.cpp',
     'StorageAccess.cpp',
     'StoragePrincipalHelper.cpp',
     'TemporaryAccessGrantObserver.cpp',
     'URLDecorationStripper.cpp',
 ]
--- a/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
+++ b/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
@@ -1,17 +1,17 @@
 /* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 #include "core/TelemetryOrigin.h"
 #include "gtest/gtest.h"
 #include "gmock/gmock.h"
-#include "mozilla/dom/ContentBlockingLog.h"
+#include "mozilla/ContentBlockingLog.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include "nsIObserverService.h"
 #include "TelemetryFixture.h"
 #include "TelemetryTestHelpers.h"
 
 using namespace mozilla;
@@ -43,34 +43,34 @@ NS_NAMED_LITERAL_CSTRING(
 // Test that we can properly record origin stuff using the C++ API.
 TEST_F(TelemetryTestFixture, RecordOrigin) {
   AutoJSContextWithGlobal cx(mCleanGlobal);
   JSContext* aCx = cx.GetJSContext();
 
   Unused << mTelemetry->ClearOrigins();
 
   Telemetry::RecordOrigin(OriginMetricID::TelemetryTest_Test1,
-                          mozilla::dom::ContentBlockingLog::kDummyOriginHash);
+                          mozilla::ContentBlockingLog::kDummyOriginHash);
 
   JS::RootedValue originSnapshot(aCx);
   GetOriginSnapshot(aCx, &originSnapshot);
 
   ASSERT_FALSE(originSnapshot.isNullOrUndefined())
   << "Origin snapshot must not be null/undefined.";
 
   JS::RootedValue origins(aCx);
   JS::RootedObject snapshotObj(aCx, &originSnapshot.toObject());
   ASSERT_TRUE(
       JS_GetProperty(aCx, snapshotObj, kTelemetryTest1Metric.get(), &origins))
   << "telemetry.test_test1 must be in the snapshot.";
 
   JS::RootedObject originsObj(aCx, &origins.toObject());
   JS::RootedValue count(aCx);
   ASSERT_TRUE(JS_GetProperty(
-      aCx, originsObj, mozilla::dom::ContentBlockingLog::kDummyOriginHash.get(),
+      aCx, originsObj, mozilla::ContentBlockingLog::kDummyOriginHash.get(),
       &count));
   ASSERT_TRUE(count.isInt32() && count.toInt32() == 1)
   << "Must have recorded the origin exactly once.";
 
   // Now test that the snapshot didn't clear things out.
   GetOriginSnapshot(aCx, &originSnapshot);
   ASSERT_FALSE(originSnapshot.isNullOrUndefined());
   JS::RootedObject unemptySnapshotObj(aCx, &originSnapshot.toObject());