Bug 1532734 - Rename Cryptomining to CryptominingProtection, r=dimi
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 05 Mar 2019 19:11:06 +0000
changeset 520380 31694cc74f7d2aaf3178ffa5ccb29b58486d89a1
parent 520379 97e21604ea3668584c23e025e09961009c49406a
child 520381 53ac343019c69ea5b529a47308761626f903497b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi
bugs1532734
milestone67.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 1532734 - Rename Cryptomining to CryptominingProtection, r=dimi Depends on D22144 Differential Revision: https://phabricator.services.mozilla.com/D22145
netwerk/url-classifier/UrlClassifierFeatureCryptomining.cpp
netwerk/url-classifier/UrlClassifierFeatureCryptomining.h
netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp
netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.h
netwerk/url-classifier/UrlClassifierFeatureFactory.cpp
netwerk/url-classifier/moz.build
rename from netwerk/url-classifier/UrlClassifierFeatureCryptomining.cpp
rename to netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp
--- a/netwerk/url-classifier/UrlClassifierFeatureCryptomining.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp
@@ -1,15 +1,15 @@
 /* -*- 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/. */
 
-#include "UrlClassifierFeatureCryptomining.h"
+#include "UrlClassifierFeatureCryptominingProtection.h"
 
 #include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "mozilla/StaticPrefs.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
@@ -25,62 +25,66 @@ namespace {
   "urlclassifier.features.cryptomining.blacklistHosts"
 #define URLCLASSIFIER_CRYPTOMINING_WHITELIST \
   "urlclassifier.features.cryptomining.whitelistTables"
 #define URLCLASSIFIER_CRYPTOMINING_WHITELIST_TEST_ENTRIES \
   "urlclassifier.features.cryptomining.whitelistHosts"
 #define TABLE_CRYPTOMINING_BLACKLIST_PREF "cryptomining-blacklist-pref"
 #define TABLE_CRYPTOMINING_WHITELIST_PREF "cryptomining-whitelist-pref"
 
-StaticRefPtr<UrlClassifierFeatureCryptomining> gFeatureCryptomining;
+StaticRefPtr<UrlClassifierFeatureCryptominingProtection>
+    gFeatureCryptominingProtection;
 
 }  // namespace
 
-UrlClassifierFeatureCryptomining::UrlClassifierFeatureCryptomining()
+UrlClassifierFeatureCryptominingProtection::
+    UrlClassifierFeatureCryptominingProtection()
     : UrlClassifierFeatureBase(
           NS_LITERAL_CSTRING(CRYPTOMINING_FEATURE_NAME),
           NS_LITERAL_CSTRING(URLCLASSIFIER_CRYPTOMINING_BLACKLIST),
           NS_LITERAL_CSTRING(URLCLASSIFIER_CRYPTOMINING_WHITELIST),
           NS_LITERAL_CSTRING(URLCLASSIFIER_CRYPTOMINING_BLACKLIST_TEST_ENTRIES),
           NS_LITERAL_CSTRING(URLCLASSIFIER_CRYPTOMINING_WHITELIST_TEST_ENTRIES),
           NS_LITERAL_CSTRING(TABLE_CRYPTOMINING_BLACKLIST_PREF),
           NS_LITERAL_CSTRING(TABLE_CRYPTOMINING_WHITELIST_PREF),
           EmptyCString()) {}
 
-/* static */ const char* UrlClassifierFeatureCryptomining::Name() {
+/* static */ const char* UrlClassifierFeatureCryptominingProtection::Name() {
   return CRYPTOMINING_FEATURE_NAME;
 }
 
 /* static */
-void UrlClassifierFeatureCryptomining::MaybeInitialize() {
-  UC_LOG(("UrlClassifierFeatureCryptomining: MaybeInitialize"));
+void UrlClassifierFeatureCryptominingProtection::MaybeInitialize() {
+  UC_LOG(("UrlClassifierFeatureCryptominingProtection: MaybeInitialize"));
 
-  if (!gFeatureCryptomining) {
-    gFeatureCryptomining = new UrlClassifierFeatureCryptomining();
-    gFeatureCryptomining->InitializePreferences();
+  if (!gFeatureCryptominingProtection) {
+    gFeatureCryptominingProtection =
+        new UrlClassifierFeatureCryptominingProtection();
+    gFeatureCryptominingProtection->InitializePreferences();
   }
 }
 
 /* static */
-void UrlClassifierFeatureCryptomining::MaybeShutdown() {
-  UC_LOG(("UrlClassifierFeatureCryptomining: MaybeShutdown"));
+void UrlClassifierFeatureCryptominingProtection::MaybeShutdown() {
+  UC_LOG(("UrlClassifierFeatureCryptominingProtection: MaybeShutdown"));
 
-  if (gFeatureCryptomining) {
-    gFeatureCryptomining->ShutdownPreferences();
-    gFeatureCryptomining = nullptr;
+  if (gFeatureCryptominingProtection) {
+    gFeatureCryptominingProtection->ShutdownPreferences();
+    gFeatureCryptominingProtection = nullptr;
   }
 }
 
 /* static */
-already_AddRefed<UrlClassifierFeatureCryptomining>
-UrlClassifierFeatureCryptomining::MaybeCreate(nsIChannel* aChannel) {
+already_AddRefed<UrlClassifierFeatureCryptominingProtection>
+UrlClassifierFeatureCryptominingProtection::MaybeCreate(nsIChannel* aChannel) {
   MOZ_ASSERT(aChannel);
 
-  UC_LOG(("UrlClassifierFeatureCryptomining: MaybeCreate for channel %p",
-          aChannel));
+  UC_LOG(
+      ("UrlClassifierFeatureCryptominingProtection: MaybeCreate for channel %p",
+       aChannel));
 
   if (!StaticPrefs::privacy_trackingprotection_cryptomining_enabled()) {
     return nullptr;
   }
 
   nsCOMPtr<nsIURI> chanURI;
   nsresult rv = aChannel->GetURI(getter_AddRefs(chanURI));
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -90,54 +94,57 @@ UrlClassifierFeatureCryptomining::MaybeC
   bool isThirdParty =
       nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel, chanURI);
   if (!isThirdParty) {
     if (UC_LOG_ENABLED()) {
       nsCString spec = chanURI->GetSpecOrDefault();
       spec.Truncate(
           std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength));
       UC_LOG(
-          ("UrlClassifierFeatureCryptomining: Skipping cryptomining checks "
+          ("UrlClassifierFeatureCryptominingProtection: Skipping cryptomining "
+           "checks "
            "for first party or top-level load channel[%p] "
            "with uri %s",
            aChannel, spec.get()));
     }
 
     return nullptr;
   }
 
   if (!UrlClassifierCommon::ShouldEnableClassifier(aChannel)) {
     return nullptr;
   }
 
   MaybeInitialize();
-  MOZ_ASSERT(gFeatureCryptomining);
+  MOZ_ASSERT(gFeatureCryptominingProtection);
 
-  RefPtr<UrlClassifierFeatureCryptomining> self = gFeatureCryptomining;
+  RefPtr<UrlClassifierFeatureCryptominingProtection> self =
+      gFeatureCryptominingProtection;
   return self.forget();
 }
 
 /* static */
 already_AddRefed<nsIUrlClassifierFeature>
-UrlClassifierFeatureCryptomining::GetIfNameMatches(const nsACString& aName) {
+UrlClassifierFeatureCryptominingProtection::GetIfNameMatches(
+    const nsACString& aName) {
   if (!aName.EqualsLiteral(CRYPTOMINING_FEATURE_NAME)) {
     return nullptr;
   }
 
   MaybeInitialize();
-  MOZ_ASSERT(gFeatureCryptomining);
+  MOZ_ASSERT(gFeatureCryptominingProtection);
 
-  RefPtr<UrlClassifierFeatureCryptomining> self = gFeatureCryptomining;
+  RefPtr<UrlClassifierFeatureCryptominingProtection> self =
+      gFeatureCryptominingProtection;
   return self.forget();
 }
 
 NS_IMETHODIMP
-UrlClassifierFeatureCryptomining::ProcessChannel(nsIChannel* aChannel,
-                                                 const nsACString& aList,
-                                                 bool* aShouldContinue) {
+UrlClassifierFeatureCryptominingProtection::ProcessChannel(
+    nsIChannel* aChannel, const nsACString& aList, bool* aShouldContinue) {
   NS_ENSURE_ARG_POINTER(aChannel);
   NS_ENSURE_ARG_POINTER(aShouldContinue);
 
   bool isAllowListed =
       IsAllowListed(aChannel, AntiTrackingCommon::eCryptomining);
 
   // This is a blocking feature.
   *aShouldContinue = isAllowListed;
@@ -151,34 +158,35 @@ UrlClassifierFeatureCryptomining::Proces
     UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
         aChannel, nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT);
   } else {
     UrlClassifierCommon::SetBlockedContent(aChannel, NS_ERROR_CRYPTOMINING_URI,
                                            aList, EmptyCString(),
                                            EmptyCString());
 
     UC_LOG(
-        ("UrlClassifierFeatureCryptomining::ProcessChannel, cancelling "
+        ("UrlClassifierFeatureCryptominingProtection::ProcessChannel, "
+         "cancelling "
          "channel[%p]",
          aChannel));
     nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);
 
     if (httpChannel) {
       Unused << httpChannel->CancelByChannelClassifier(
           NS_ERROR_CRYPTOMINING_URI);
     } else {
       Unused << aChannel->Cancel(NS_ERROR_CRYPTOMINING_URI);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-UrlClassifierFeatureCryptomining::GetURIByListType(
+UrlClassifierFeatureCryptominingProtection::GetURIByListType(
     nsIChannel* aChannel, nsIUrlClassifierFeature::listType aListType,
     nsIURI** aURI) {
   NS_ENSURE_ARG_POINTER(aChannel);
   NS_ENSURE_ARG_POINTER(aURI);
 
   if (aListType == nsIUrlClassifierFeature::blacklist) {
     return aChannel->GetURI(aURI);
   }
rename from netwerk/url-classifier/UrlClassifierFeatureCryptomining.h
rename to netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.h
--- a/netwerk/url-classifier/UrlClassifierFeatureCryptomining.h
+++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.h
@@ -1,45 +1,46 @@
 /* -*- 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_net_UrlClassifierFeatureCryptomining_h
-#define mozilla_net_UrlClassifierFeatureCryptomining_h
+#ifndef mozilla_net_UrlClassifierFeatureCryptominingProtection_h
+#define mozilla_net_UrlClassifierFeatureCryptominingProtection_h
 
 #include "UrlClassifierFeatureBase.h"
 
 class nsIChannel;
 
 namespace mozilla {
 namespace net {
 
-class UrlClassifierFeatureCryptomining final : public UrlClassifierFeatureBase {
+class UrlClassifierFeatureCryptominingProtection final
+    : public UrlClassifierFeatureBase {
  public:
   static const char* Name();
 
   static void MaybeShutdown();
 
-  static already_AddRefed<UrlClassifierFeatureCryptomining> MaybeCreate(
-      nsIChannel* aChannel);
+  static already_AddRefed<UrlClassifierFeatureCryptominingProtection>
+  MaybeCreate(nsIChannel* aChannel);
 
   static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
       const nsACString& aName);
 
   NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
                             bool* aShouldContinue) override;
 
   NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
                               nsIUrlClassifierFeature::listType aListType,
                               nsIURI** aURI) override;
 
  private:
-  UrlClassifierFeatureCryptomining();
+  UrlClassifierFeatureCryptominingProtection();
 
   static void MaybeInitialize();
 };
 
 }  // namespace net
 }  // namespace mozilla
 
-#endif  // mozilla_net_UrlClassifierFeatureCryptomining_h
+#endif  // mozilla_net_UrlClassifierFeatureCryptominingProtection_h
--- a/netwerk/url-classifier/UrlClassifierFeatureFactory.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureFactory.cpp
@@ -2,17 +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/net/UrlClassifierFeatureFactory.h"
 
 // List of Features
-#include "UrlClassifierFeatureCryptomining.h"
+#include "UrlClassifierFeatureCryptominingProtection.h"
 #include "UrlClassifierFeatureFingerprintingProtection.h"
 #include "UrlClassifierFeatureFlash.h"
 #include "UrlClassifierFeatureLoginReputation.h"
 #include "UrlClassifierFeaturePhishingProtection.h"
 #include "UrlClassifierFeatureTrackingProtection.h"
 #include "UrlClassifierFeatureTrackingAnnotation.h"
 #include "UrlClassifierFeatureCustomTables.h"
 
@@ -23,17 +23,17 @@ namespace net {
 
 /* static */
 void UrlClassifierFeatureFactory::Shutdown() {
   // We want to expose Features only in the parent process.
   if (!XRE_IsParentProcess()) {
     return;
   }
 
-  UrlClassifierFeatureCryptomining::MaybeShutdown();
+  UrlClassifierFeatureCryptominingProtection::MaybeShutdown();
   UrlClassifierFeatureFingerprintingProtection::MaybeShutdown();
   UrlClassifierFeatureFlash::MaybeShutdown();
   UrlClassifierFeatureLoginReputation::MaybeShutdown();
   UrlClassifierFeaturePhishingProtection::MaybeShutdown();
   UrlClassifierFeatureTrackingAnnotation::MaybeShutdown();
   UrlClassifierFeatureTrackingProtection::MaybeShutdown();
 }
 
@@ -46,18 +46,18 @@ void UrlClassifierFeatureFactory::GetFea
 
   nsCOMPtr<nsIUrlClassifierFeature> feature;
 
   // Note that the order of the features is extremely important! When more than
   // 1 feature classifies the channel, we call ::ProcessChannel() following this
   // feature order, and this could produce different results with a different
   // feature ordering.
 
-  // Cryptomining
-  feature = UrlClassifierFeatureCryptomining::MaybeCreate(aChannel);
+  // Cryptomining Protection
+  feature = UrlClassifierFeatureCryptominingProtection::MaybeCreate(aChannel);
   if (feature) {
     aFeatures.AppendElement(feature);
   }
 
   // Fingerprinting Protection
   feature = UrlClassifierFeatureFingerprintingProtection::MaybeCreate(aChannel);
   if (feature) {
     aFeatures.AppendElement(feature);
@@ -97,18 +97,18 @@ UrlClassifierFeatureFactory::GetFeatureL
 already_AddRefed<nsIUrlClassifierFeature>
 UrlClassifierFeatureFactory::GetFeatureByName(const nsACString& aName) {
   if (!XRE_IsParentProcess()) {
     return nullptr;
   }
 
   nsCOMPtr<nsIUrlClassifierFeature> feature;
 
-  // Cryptomining
-  feature = UrlClassifierFeatureCryptomining::GetIfNameMatches(aName);
+  // Cryptomining Protection
+  feature = UrlClassifierFeatureCryptominingProtection::GetIfNameMatches(aName);
   if (feature) {
     return feature.forget();
   }
 
   // Fingerprinting Protection
   feature =
       UrlClassifierFeatureFingerprintingProtection::GetIfNameMatches(aName);
   if (feature) {
@@ -149,19 +149,19 @@ UrlClassifierFeatureFactory::GetFeatureB
 }
 
 /* static */
 void UrlClassifierFeatureFactory::GetFeatureNames(nsTArray<nsCString>& aArray) {
   if (!XRE_IsParentProcess()) {
     return;
   }
 
-  // Cryptomining
+  // Cryptomining Protection
   nsAutoCString name;
-  name.Assign(UrlClassifierFeatureCryptomining::Name());
+  name.Assign(UrlClassifierFeatureCryptominingProtection::Name());
   if (!name.IsEmpty()) {
     aArray.AppendElement(name);
   }
 
   // Fingerprinting Protection
   name.Assign(UrlClassifierFeatureFingerprintingProtection::Name());
   if (!name.IsEmpty()) {
     aArray.AppendElement(name);
--- a/netwerk/url-classifier/moz.build
+++ b/netwerk/url-classifier/moz.build
@@ -17,17 +17,17 @@ XPIDL_MODULE = 'url-classifier'
 DEFINES['GOOGLE_PROTOBUF_NO_RTTI'] = True
 DEFINES['GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER'] = True
 
 UNIFIED_SOURCES += [
     'AsyncUrlChannelClassifier.cpp',
     'nsChannelClassifier.cpp',
     'UrlClassifierCommon.cpp',
     'UrlClassifierFeatureBase.cpp',
-    'UrlClassifierFeatureCryptomining.cpp',
+    'UrlClassifierFeatureCryptominingProtection.cpp',
     'UrlClassifierFeatureCustomTables.cpp',
     'UrlClassifierFeatureFactory.cpp',
     'UrlClassifierFeatureFingerprintingProtection.cpp',
     'UrlClassifierFeatureFlash.cpp',
     'UrlClassifierFeatureLoginReputation.cpp',
     'UrlClassifierFeaturePhishingProtection.cpp',
     'UrlClassifierFeatureResult.cpp',
     'UrlClassifierFeatureTrackingAnnotation.cpp',