Bug 1338033 - Remove URLCLASSIFIER_PREFIX_MATCH. r?francois draft
authordimi <dlee@mozilla.com>
Wed, 22 Mar 2017 17:27:11 +0800
changeset 502747 32ae8053ec15a323b01a117da3451371b39aad9d
parent 497206 f9362554866b327700c7f9b18050d7b7eb3d2b23
child 550251 40833774026b965ad597e1abef29f80735f52f21
push id50385
push userdlee@mozilla.com
push dateWed, 22 Mar 2017 09:27:46 +0000
reviewersfrancois
bugs1338033, 1311931
milestone55.0a1
Bug 1338033 - Remove URLCLASSIFIER_PREFIX_MATCH. r?francois URLCLASSIFIER_PREFIX_MATCH is replaced by URLCLASSIFIER_FULL_MATCH(Bug 1311931) so it should be removed. MozReview-Commit-ID: 4F1B07bGwRP
toolkit/components/telemetry/Histograms.json
toolkit/components/url-classifier/Classifier.cpp
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4224,24 +4224,16 @@
     "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
     "expires_in_version": "59",
     "kind": "enumerated",
     "keyed": true,
     "n_values": 16,
     "bug_numbers": [1311910],
     "description": "Whether or not an error was encountered while processing a Safe Browsing update (0 = success, 1 = unspecified error, 2 = addition of an already existing prefix, 3 = parser got into an infinite loop, 4 = removal index out of bounds, 5 = checksum mismatch, 6 = missing checksum, 7 = update while shutdown, 8 = cannot find table, 9 = build prefix failure, 10 = write disk failure, 11 = protocol parser error). Keyed by provider"
   },
-  "URLCLASSIFIER_PREFIX_MATCH": {
-    "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
-    "expires_in_version": "58",
-    "kind": "enumerated",
-    "n_values": 4,
-    "bug_numbers": [1298257],
-    "description": "Classifier prefix matching result (0 = no match, 1 = match only V2, 2 = match only V4, 3 = match both V2 and V4)"
-  },
   "URLCLASSIFIER_MATCH_RESULT": {
     "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
     "expires_in_version": "60",
     "kind": "enumerated",
     "n_values": 16,
     "bug_numbers": [1311931],
     "description": "The result of each URL lookup against both google and google4 lists(0 = no match, 1 = V2 prefix only, 2 = V4 prefix only, 3 = V2 and V4 prefixes, 4 = V2 and V4 completions, 5 = V2 completion only, 6 = V4 completion only, 7 = V2 completion and v4 prefix, 8 = V2 prefix and V4 completion, 9 = unexpected result)"
   },
--- a/toolkit/components/url-classifier/Classifier.cpp
+++ b/toolkit/components/url-classifier/Classifier.cpp
@@ -17,17 +17,16 @@
 #include "nsThreadUtils.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/Base64.h"
 #include "mozilla/Unused.h"
 #include "mozilla/SizePrintfMacros.h"
-#include "mozilla/TypedEnumBits.h"
 #include "nsIUrlClassifierUtils.h"
 #include "nsUrlClassifierDBService.h"
 
 // MOZ_LOG=UrlClassifierDbService:5
 extern mozilla::LazyLogModule gUrlClassifierDbServiceLog;
 #define LOG(args) MOZ_LOG(gUrlClassifierDbServiceLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gUrlClassifierDbServiceLog, mozilla::LogLevel::Debug)
 
@@ -410,26 +409,16 @@ Classifier::TableRequest(nsACString& aRe
     aResult.Append(metadata);
   }
 
   // Update the TableRequest result in-memory cache.
   mTableRequestResult = aResult;
   mIsTableRequestResultOutdated = false;
 }
 
-// This is used to record the matching statistics for v2 and v4.
-enum class PrefixMatch : uint8_t {
-  eNoMatch = 0x00,
-  eMatchV2Prefix = 0x01,
-  eMatchV4Prefix = 0x02,
-  eMatchBoth = eMatchV2Prefix | eMatchV4Prefix
-};
-
-MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PrefixMatch)
-
 nsresult
 Classifier::Check(const nsACString& aSpec,
                   const nsACString& aTables,
                   uint32_t aFreshnessGuarantee,
                   LookupResultArray& aResults)
 {
   Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_CL_CHECK_TIME> timer;
 
@@ -461,18 +450,16 @@ Classifier::Check(const nsACString& aSpe
     bool& ref = LookupCache::Cast<LookupCacheV2>(cache) ? isV2Empty : isV4Empty;
     ref = ref ? cache->IsEmpty() : false;
     if (!isV2Empty && !isV4Empty) {
       shouldDoTelemetry = true;
       break;
     }
   }
 
-  PrefixMatch matchingStatistics = PrefixMatch::eNoMatch;
-
   // Now check each lookup fragment against the entries in the DB.
   for (uint32_t i = 0; i < fragments.Length(); i++) {
     Completion lookupHash;
     lookupHash.FromPlaintext(fragments[i], mCryptoHash);
 
     if (LOG_ENABLED()) {
       nsAutoCString checking;
       lookupHash.ToHexString(checking);
@@ -514,31 +501,20 @@ Classifier::Check(const nsACString& aSpe
         // There are two cases we are going to ignore the result for telemetry:
         // 1. shouldDoTelemetry == false(when either v2 or v4 table is empty)
         // 2. When match was found in the table which is not provided by google.
         if (!shouldDoTelemetry ||
             !StringBeginsWith(result->mTableName, NS_LITERAL_CSTRING("goog"))) {
           continue;
         }
 
-        if (result->mProtocolV2) {
-          matchingStatistics |= PrefixMatch::eMatchV2Prefix;
-          result->mMatchResult = MatchResult::eV2Prefix;
-        } else {
-          matchingStatistics |= PrefixMatch::eMatchV2Prefix;
-          result->mMatchResult = MatchResult::eV4Prefix;
-        }
+        result->mMatchResult = result->mProtocolV2 ?
+                               MatchResult::eV2Prefix : MatchResult::eV4Prefix;
       }
     }
-
-    // TODO : This will be removed in Bug 1338033.
-    if (shouldDoTelemetry) {
-      Telemetry::Accumulate(Telemetry::URLCLASSIFIER_PREFIX_MATCH,
-                            static_cast<uint8_t>(matchingStatistics));
-    }
   }
 
   // If we cannot find the prefix in neither the v2 nor the v4 database, record the
   // telemetry here because we won't reach nsUrlClassifierLookupCallback:::HandleResult.
   if (shouldDoTelemetry && aResults.Length() == 0) {
     Telemetry::Accumulate(Telemetry::URLCLASSIFIER_MATCH_RESULT,
                           static_cast<uint8_t>(MatchResult::eNoMatch));
   }