[go: nahoru, domu]

[search_engines] Obsolete Search.TemplateURL.Events and remove logging

Removes the logging code for Search.TemplateURL.Events and marks it as
explicitly obsolete in the xml file too.

Bug: 1426139
Change-Id: If9184fc3191804bdda073d52f3919114433bc38e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4575339
Reviewed-by: Tomasz Wiszkowski <ender@google.com>
Commit-Queue: Tomasz Wiszkowski <ender@google.com>
Reviewed-by: Justin Donnelly <jdonnelly@chromium.org>
Reviewed-by: Angela Yoeurng <yoangela@chromium.org>
Auto-Submit: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1152059}
diff --git a/components/search_engines/android/template_url_service_android.cc b/components/search_engines/android/template_url_service_android.cc
index 1cc492a..6017a7f 100644
--- a/components/search_engines/android/template_url_service_android.cc
+++ b/components/search_engines/android/template_url_service_android.cc
@@ -327,8 +327,6 @@
     // TODO(tommycli): Delete this once the below metric approaches zero.
     TemplateURL* turl = *existing_play_api_turl;
     if (turl->safe_for_autoreplace()) {
-      TemplateURLService::LogSearchTemplateURLEvent(
-          TemplateURLService::MIGRATE_SAFE_FOR_AUTOREPLACE_PLAY_API_ENGINE);
       template_url_service_->ResetTemplateURL(turl, turl->short_name(),
                                               turl->keyword(), turl->url());
     }
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index cfb55a4a..faab9daf 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -316,13 +316,6 @@
 }
 
 // static
-void TemplateURLService::LogSearchTemplateURLEvent(
-    SearchTemplateURLEvent event) {
-  UMA_HISTOGRAM_ENUMERATION("Search.TemplateURL.Events", event,
-                            SEARCH_TEMPLATE_URL_EVENT_MAX);
-}
-
-// static
 void TemplateURLService::RegisterProfilePrefs(
     user_prefs::PrefRegistrySyncable* registry) {
 #if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID)
@@ -1213,8 +1206,7 @@
         syncer::SyncChange::ChangeTypeToString(iter->change_type());
     if (iter->change_type() == syncer::SyncChange::ACTION_DELETE) {
       if (!existing_turl) {
-        // Can't DELETE a non-existent engine, although we log it.
-        LogSearchTemplateURLEvent(SYNC_DELETE_FAIL_NONEXISTENT_ENGINE);
+        // Can't DELETE a non-existent engine.
         error = syncer::ModelError(FROM_HERE, error_msg);
         continue;
       }
@@ -1232,9 +1224,6 @@
       // likely a source of duplicate search engine entries. crbug.com/1022775
       if (existing_turl != GetDefaultSearchProvider()) {
         Remove(existing_turl);
-        LogSearchTemplateURLEvent(SYNC_DELETE_SUCCESS);
-      } else {
-        LogSearchTemplateURLEvent(SYNC_DELETE_FAIL_DEFAULT_SEARCH_PROVIDER);
       }
       continue;
     }
@@ -1247,12 +1236,6 @@
            iter->change_type() == syncer::SyncChange::ACTION_UPDATE);
 
     if (!existing_turl) {
-      if (iter->change_type() == syncer::SyncChange::ACTION_UPDATE) {
-        // This can happen if we have silently deleted a replaceable engine due
-        // to keyword conflict, and Sync server sends us an UPDATE to it.
-        LogSearchTemplateURLEvent(SYNC_UPDATE_CONVERTED_TO_ADD);
-      }
-
       base::AutoReset<DefaultSearchChangeOrigin> change_origin_add(
           &dsp_change_origin_, DSP_CHANGE_SYNC_ADD);
       // Force the local ID to kInvalidTemplateURLID so we can add it.
@@ -1262,22 +1245,8 @@
       TemplateURL* added = Add(std::make_unique<TemplateURL>(data));
       if (added) {
         MaybeUpdateDSEViaPrefs(added);
-
-        LogSearchTemplateURLEvent(SYNC_ADD_SUCCESS);
-      } else {
-        // Currently, in practice, this means that we tried to add a replaceable
-        // duplicate that was worse than our existing entry, but the API doesn't
-        // promise that, so we just log a generic SYNC_ADD_FAIL_OTHER_ERROR.
-        LogSearchTemplateURLEvent(SYNC_ADD_FAIL_OTHER_ERROR);
       }
     } else {
-      if (iter->change_type() == syncer::SyncChange::ACTION_ADD) {
-        // This can happen if we have ignored a DELETE request in the past to
-        // avoid deleting the default search provider, and later on, Sync tries
-        // to re-ADD something it thinks it has deleted.
-        LogSearchTemplateURLEvent(SYNC_ADD_CONVERTED_TO_UPDATE);
-      }
-
       // Since we've already found |existing_turl| by GUID, this Update() should
       // always return true, but we still don't want to crash if it fails.
       DCHECK(existing_turl);
@@ -1285,7 +1254,6 @@
       DCHECK(update_success);
 
       MaybeUpdateDSEViaPrefs(existing_turl);
-      LogSearchTemplateURLEvent(SYNC_UPDATE_SUCCESS);
     }
   }
 
diff --git a/components/search_engines/template_url_service.h b/components/search_engines/template_url_service.h
index 63e684f..111f1ef1 100644
--- a/components/search_engines/template_url_service.h
+++ b/components/search_engines/template_url_service.h
@@ -113,21 +113,6 @@
     std::u16string search_terms;
   };
 
-  // Values for an enumerated histogram used to track TemplateURL edge cases.
-  // These are persisted. Do not re-number.
-  enum SearchTemplateURLEvent {
-    SYNC_DELETE_SUCCESS = 0,
-    SYNC_DELETE_FAIL_NONEXISTENT_ENGINE = 1,
-    SYNC_DELETE_FAIL_DEFAULT_SEARCH_PROVIDER = 2,
-    SYNC_ADD_SUCCESS = 3,
-    SYNC_ADD_CONVERTED_TO_UPDATE = 4,
-    SYNC_ADD_FAIL_OTHER_ERROR = 5,
-    SYNC_UPDATE_SUCCESS = 6,
-    SYNC_UPDATE_CONVERTED_TO_ADD = 7,
-    MIGRATE_SAFE_FOR_AUTOREPLACE_PLAY_API_ENGINE = 8,
-    SEARCH_TEMPLATE_URL_EVENT_MAX,
-  };
-
   TemplateURLService(
       PrefService* prefs,
       std::unique_ptr<SearchTermsData> search_terms_data,
@@ -142,9 +127,6 @@
 
   ~TemplateURLService() override;
 
-  // Log a SearchTemplateURLEvent.
-  static void LogSearchTemplateURLEvent(SearchTemplateURLEvent event);
-
   // Register Profile preferences in |registry|.
   static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
 
diff --git a/tools/metrics/histograms/metadata/search/histograms.xml b/tools/metrics/histograms/metadata/search/histograms.xml
index 2b58235..49fffdf 100644
--- a/tools/metrics/histograms/metadata/search/histograms.xml
+++ b/tools/metrics/histograms/metadata/search/histograms.xml
@@ -1762,6 +1762,9 @@
 
 <histogram name="Search.TemplateURL.Events" enum="SearchTemplateURLEvent"
     expires_after="2023-05-01">
+  <obsolete>
+    Expired and removed 05/2023.
+  </obsolete>
   <owner>tommycli@chromium.org</owner>
   <owner>chrome-omnibox-team@google.com</owner>
   <summary>