Bug 1522265 - Moving malware, phishing and blocked URIs to features - part 2 - factory updated, r=dimi
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 29 Jan 2019 10:11:33 +0100
changeset 455952 32eedda05a808eff9872c162be28d2a96693571c
parent 455951 ce4973824e42402d6481f1078e01400791d92575
child 455953 ac7f6aeaa6de5f057d5ee3957da64153a168d85d
push id35463
push usershindli@mozilla.com
push dateTue, 29 Jan 2019 21:38:17 +0000
treeherdermozilla-central@4440fbf71c72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi
bugs1522265
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 1522265 - Moving malware, phishing and blocked URIs to features - part 2 - factory updated, r=dimi
netwerk/url-classifier/UrlClassifierFeatureFactory.cpp
netwerk/url-classifier/UrlClassifierFeatureFactory.h
netwerk/url-classifier/UrlClassifierFeatureNoChannel.cpp
netwerk/url-classifier/UrlClassifierFeatureNoChannel.h
--- a/netwerk/url-classifier/UrlClassifierFeatureFactory.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureFactory.cpp
@@ -74,16 +74,21 @@ namespace net {
   }
 
   // Flash
   nsTArray<nsCOMPtr<nsIUrlClassifierFeature>> flashFeatures;
   UrlClassifierFeatureFlash::MaybeCreate(aChannel, flashFeatures);
   aFeatures.AppendElements(flashFeatures);
 }
 
+/* static */ void UrlClassifierFeatureFactory::GetFeaturesNoChannel(
+    nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures) {
+  UrlClassifierFeatureNoChannel::MaybeCreate(aFeatures);
+}
+
 /* static */
 nsIUrlClassifierFeature*
 UrlClassifierFeatureFactory::GetFeatureLoginReputation() {
   return UrlClassifierFeatureLoginReputation::MaybeGetOrCreate();
 }
 
 /* static */ already_AddRefed<nsIUrlClassifierFeature>
 UrlClassifierFeatureFactory::GetFeatureByName(const nsACString& aName) {
--- a/netwerk/url-classifier/UrlClassifierFeatureFactory.h
+++ b/netwerk/url-classifier/UrlClassifierFeatureFactory.h
@@ -19,16 +19,19 @@ namespace net {
 class UrlClassifierFeatureFactory final {
  public:
   static void Shutdown();
 
   static void GetFeaturesFromChannel(
       nsIChannel* aChannel,
       nsTArray<nsCOMPtr<nsIUrlClassifierFeature>>& aFeatures);
 
+  static void GetFeaturesNoChannel(
+      nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures);
+
   static nsIUrlClassifierFeature* GetFeatureLoginReputation();
 
   static already_AddRefed<nsIUrlClassifierFeature> GetFeatureByName(
       const nsACString& aFeatureName);
 
   static void GetFeatureNames(nsTArray<nsCString>& aArray);
 
   static already_AddRefed<nsIUrlClassifierFeature> CreateFeatureWithTables(
--- a/netwerk/url-classifier/UrlClassifierFeatureNoChannel.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureNoChannel.cpp
@@ -66,16 +66,28 @@ UrlClassifierFeatureNoChannel::UrlClassi
   for (NoChannelFeature& feature : sNoChannelFeaturesMap) {
     if (feature.mFeature) {
       feature.mFeature->ShutdownPreferences();
       feature.mFeature = nullptr;
     }
   }
 }
 
+/* static */ void UrlClassifierFeatureNoChannel::MaybeCreate(
+    nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures) {
+  MaybeInitialize();
+
+  for (const NoChannelFeature& feature : sNoChannelFeaturesMap) {
+    if (feature.mPref()) {
+      MOZ_ASSERT(feature.mFeature);
+      aFeatures.AppendElement(feature.mFeature);
+    }
+  }
+}
+
 /* static */ already_AddRefed<nsIUrlClassifierFeature>
 UrlClassifierFeatureNoChannel::GetIfNameMatches(const nsACString& aName) {
   MaybeInitialize();
 
   for (const NoChannelFeature& feature : sNoChannelFeaturesMap) {
     if (feature.mPref() && aName.Equals(feature.mName)) {
       MOZ_ASSERT(feature.mFeature);
       nsCOMPtr<nsIUrlClassifierFeature> self = feature.mFeature.get();
--- a/netwerk/url-classifier/UrlClassifierFeatureNoChannel.h
+++ b/netwerk/url-classifier/UrlClassifierFeatureNoChannel.h
@@ -15,16 +15,19 @@ namespace net {
 class UrlClassifierFeatureNoChannel final : public UrlClassifierFeatureBase {
  public:
   struct NoChannelFeature;
 
   static void GetFeatureNames(nsTArray<nsCString>& aNames);
 
   static void MaybeShutdown();
 
+  static void MaybeCreate(
+      nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures);
+
   static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
       const nsACString& aName);
 
   NS_IMETHOD
   ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
                  bool* aShouldContinue) override;
 
   NS_IMETHOD GetURIByListType(nsIChannel* aChannel,