[UPMLocalPwd] Refactor the histogram names creation

The goal of this CL is to make it easier to understand how histogram
names are created.

Bug: b/306674952
Change-Id: Ia142db94be07264d9f7d8a7286d9e628680b9324
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5255524
Reviewed-by: Viktor Semeniuk <vsemeniuk@google.com>
Commit-Queue: Ivana Žužić <izuzic@google.com>
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1255113}
diff --git a/chrome/browser/password_manager/android/password_store_android_backend.cc b/chrome/browser/password_manager/android/password_store_android_backend.cc
index a86a04e..bf895cb4 100644
--- a/chrome/browser/password_manager/android/password_store_android_backend.cc
+++ b/chrome/browser/password_manager/android/password_store_android_backend.cc
@@ -395,7 +395,7 @@
     base::TimeDelta delay) {
   JobId job_id = bridge_helper_->GetAutofillableLogins(std::move(account));
   QueueNewJob(job_id, std::move(callback),
-              MetricInfix("GetAutofillableLoginsAsync"), operation, delay);
+              MethodName("GetAutofillableLoginsAsync"), operation, delay);
 }
 
 void PasswordStoreAndroidBackend::
@@ -405,7 +405,7 @@
   JobId job_id =
       bridge_helper_->GetAllLoginsWithBrandingInfo(std::move(account));
   QueueNewJob(job_id, std::move(callback),
-              MetricInfix("GetAllLoginsWithBrandingInfoAsync"),
+              MethodName("GetAllLoginsWithBrandingInfoAsync"),
               PasswordStoreOperation::kGetAllLoginsWithBrandingInfoAsync,
               /*delay=*/base::Seconds(0));
 }
@@ -416,7 +416,7 @@
     PasswordStoreOperation operation,
     base::TimeDelta delay) {
   JobId job_id = bridge_helper_->GetAllLogins(std::move(account));
-  QueueNewJob(job_id, std::move(callback), MetricInfix("GetAllLoginsAsync"),
+  QueueNewJob(job_id, std::move(callback), MethodName("GetAllLoginsAsync"),
               operation, delay);
 }
 
@@ -432,7 +432,7 @@
   QueueNewJob(job_id,
               base::BindOnce(&ValidateSignonRealm, std::move(form), include_psl,
                              std::move(callback)),
-              MetricInfix("GetLoginsAsync"),
+              MethodName("GetLoginsAsync"),
               PasswordStoreOperation::kFillMatchingLoginsAsync,
               /*delay=*/base::Seconds(0));
 }
@@ -447,7 +447,7 @@
     sanitized_form.password_value.clear();
   }
   JobId job_id = bridge_helper_->AddLogin(sanitized_form, std::move(account));
-  QueueNewJob(job_id, std::move(callback), MetricInfix("AddLoginAsync"),
+  QueueNewJob(job_id, std::move(callback), MethodName("AddLoginAsync"),
               PasswordStoreOperation::kAddLoginAsync,
               /*delay=*/base::Seconds(0));
 }
@@ -463,7 +463,7 @@
   }
   JobId job_id =
       bridge_helper_->UpdateLogin(sanitized_form, std::move(account));
-  QueueNewJob(job_id, std::move(callback), MetricInfix("UpdateLoginAsync"),
+  QueueNewJob(job_id, std::move(callback), MethodName("UpdateLoginAsync"),
               PasswordStoreOperation::kUpdateLoginAsync,
               /*delay=*/base::Seconds(0));
 }
@@ -473,7 +473,7 @@
     const PasswordForm& form,
     PasswordChangesOrErrorReply callback) {
   JobId job_id = bridge_helper_->RemoveLogin(form, std::move(account));
-  QueueNewJob(job_id, std::move(callback), MetricInfix("RemoveLoginAsync"),
+  QueueNewJob(job_id, std::move(callback), MethodName("RemoveLoginAsync"),
               PasswordStoreOperation::kRemoveLoginAsync,
               /*delay=*/base::Seconds(0));
 }
@@ -491,7 +491,7 @@
   // Record FillMatchingLoginsAsync metrics prior to invoking |callback|.
   LoginsOrErrorReply record_metrics_and_reply =
       ReportMetricsAndInvokeCallbackForLoginsRetrieval(
-          MetricInfix("FillMatchingLoginsAsync"), std::move(callback));
+          MethodName("FillMatchingLoginsAsync"), std::move(callback));
 
   // Create a barrier callback that aggregates results of a multiple
   // calls to GetLoginsInternal.
@@ -520,7 +520,7 @@
   QueueNewJob(job_id,
               base::BindOnce(&ProcessGroupedLoginsAndReply, form_digest,
                              std::move(callback)),
-              MetricInfix("GetGroupedMatchingLoginsAsync"),
+              MethodName("GetGroupedMatchingLoginsAsync"),
               PasswordStoreOperation::kGetGroupedMatchingLoginsAsync,
               /*delay=*/base::Seconds(0));
 }
@@ -534,7 +534,7 @@
   // Record metrics prior to invoking |callback|.
   PasswordChangesOrErrorReply record_metrics_and_reply =
       ReportMetricsAndInvokeCallbackForStoreModifications(
-          MetricInfix("RemoveLoginsByURLAndTimeAsync"), std::move(callback));
+          MethodName("RemoveLoginsByURLAndTimeAsync"), std::move(callback));
 
   GetAllLoginsInternal(
       account,
@@ -553,7 +553,7 @@
   // Record metrics prior to invoking |callback|.
   PasswordChangesOrErrorReply record_metrics_and_reply =
       ReportMetricsAndInvokeCallbackForStoreModifications(
-          MetricInfix("RemoveLoginsCreatedBetweenAsync"), std::move(callback));
+          MethodName("RemoveLoginsCreatedBetweenAsync"), std::move(callback));
 
   GetAllLoginsInternal(
       account,
@@ -585,7 +585,7 @@
           },
           PasswordStoreBackendMetricsRecorder(
               BackendInfix("AndroidBackend"),
-              MetricInfix("DisableAutoSignInForOriginsAsync")),
+              MethodName("DisableAutoSignInForOriginsAsync")),
           std::move(completion));
 
   GetAllLoginsInternal(
@@ -789,7 +789,7 @@
 template <typename Callback>
 void PasswordStoreAndroidBackend::QueueNewJob(JobId job_id,
                                               Callback callback,
-                                              MetricInfix metric_infix,
+                                              MethodName method_name,
                                               PasswordStoreOperation operation,
                                               base::TimeDelta delay) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_);
@@ -797,7 +797,7 @@
       job_id, JobReturnHandler(
                   std::move(callback),
                   PasswordStoreBackendMetricsRecorder(
-                      BackendInfix("AndroidBackend"), std::move(metric_infix)),
+                      BackendInfix("AndroidBackend"), std::move(method_name)),
                   delay, operation));
 }
 
@@ -890,7 +890,7 @@
 // static
 LoginsOrErrorReply
 PasswordStoreAndroidBackend::ReportMetricsAndInvokeCallbackForLoginsRetrieval(
-    const MetricInfix& metric_infix,
+    const MethodName& method_name,
     LoginsOrErrorReply callback) {
   // TODO(https://crbug.com/1229655) Switch to using base::PassThrough to handle
   // this callback more gracefully when it's implemented.
@@ -905,14 +905,14 @@
         std::move(callback).Run(std::move(results));
       },
       PasswordStoreBackendMetricsRecorder(BackendInfix("AndroidBackend"),
-                                          metric_infix),
+                                          method_name),
       std::move(callback));
 }
 
 // static
 PasswordChangesOrErrorReply PasswordStoreAndroidBackend::
     ReportMetricsAndInvokeCallbackForStoreModifications(
-        const MetricInfix& metric_infix,
+        const MethodName& method_name,
         PasswordChangesOrErrorReply callback) {
   // TODO(https://crbug.com/1229655) Switch to using base::PassThrough to handle
   // this callback more gracefully when it's implemented.
@@ -927,7 +927,7 @@
         std::move(callback).Run(std::move(results));
       },
       PasswordStoreBackendMetricsRecorder(BackendInfix("AndroidBackend"),
-                                          metric_infix),
+                                          method_name),
       std::move(callback));
 }
 
diff --git a/chrome/browser/password_manager/android/password_store_android_backend.h b/chrome/browser/password_manager/android/password_store_android_backend.h
index 0d893b8..9af824d 100644
--- a/chrome/browser/password_manager/android/password_store_android_backend.h
+++ b/chrome/browser/password_manager/android/password_store_android_backend.h
@@ -266,7 +266,7 @@
   // doesn't introduce any delay.
   void QueueNewJob(JobId job_id,
                    Callback callback,
-                   MetricInfix metric_infix,
+                   MethodName method_name,
                    PasswordStoreOperation operation,
                    base::TimeDelta delay);
   std::optional<JobReturnHandler> GetAndEraseJob(JobId job_id);
@@ -292,18 +292,18 @@
       LoginsResultOrError result);
 
   // Creates a metrics recorder that records latency and success metrics for
-  // logins retrieval operation with |metric_infix| name prior to calling
+  // logins retrieval operation with |method_name| name prior to calling
   // |callback|.
   static LoginsOrErrorReply ReportMetricsAndInvokeCallbackForLoginsRetrieval(
-      const MetricInfix& metric_infix,
+      const MethodName& method_name,
       LoginsOrErrorReply callback);
 
   // Creates a metrics recorder that records latency and success metrics for
-  // store modification operation with |metric_infix| name prior to
+  // store modification operation with |method_name| name prior to
   // calling |callback|.
   static PasswordChangesOrErrorReply
   ReportMetricsAndInvokeCallbackForStoreModifications(
-      const MetricInfix& metric_infix,
+      const MethodName& method_name,
       PasswordChangesOrErrorReply callback);
 
   // Invoked synchronously by `lifecycle_helper_` when Chrome is foregrounded.
diff --git a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc
index 82d8ca2..c2cad384 100644
--- a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc
+++ b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc
@@ -10,6 +10,7 @@
 #include "base/metrics/histogram_functions.h"
 #include "base/notreached.h"
 #include "base/strings/strcat.h"
+#include "base/strings/string_util.h"
 
 namespace password_manager {
 
@@ -38,9 +39,9 @@
 
 PasswordStoreBackendMetricsRecorder::PasswordStoreBackendMetricsRecorder(
     BackendInfix backend_infix,
-    MetricInfix metric_infix)
+    MethodName method_name)
     : backend_infix_(std::move(backend_infix)),
-      metric_infix_(std::move(metric_infix)) {
+      method_name_(std::move(method_name)) {
   RecordRequestStatus(StoreBackendRequestStatus::kRequestIssued);
 }
 
@@ -83,16 +84,31 @@
 
 void PasswordStoreBackendMetricsRecorder::RecordRequestStatus(
     StoreBackendRequestStatus request_status) const {
-  base::UmaHistogramEnumeration(GetBackendMetricName(), request_status);
-  base::UmaHistogramEnumeration(GetOverallMetricName(), request_status);
+  // Infixes for the overall and backend specific histogram.
+  const std::array<std::string_view, 2> possible_infixes = {"Backend",
+                                                            *backend_infix_};
+
+  for (const auto& infix : possible_infixes) {
+    base::UmaHistogramEnumeration(
+        base::JoinString({base::StrCat({kMetricPrefix, infix}), *method_name_},
+                         "."),
+        request_status);
+  }
 }
 
 void PasswordStoreBackendMetricsRecorder::RecordSuccess(
     SuccessStatus success_status) const {
-  base::UmaHistogramBoolean(BuildMetricName("Success"),
-                            success_status == SuccessStatus::kSuccess);
-  base::UmaHistogramBoolean(BuildOverallMetricName("Success"),
-                            success_status == SuccessStatus::kSuccess);
+  // Infixes for the overall and backend specific histogram.
+  const std::array<std::string_view, 2> possible_infixes = {"Backend",
+                                                            *backend_infix_};
+
+  for (const auto& infix : possible_infixes) {
+    base::UmaHistogramBoolean(
+        base::JoinString(
+            {base::StrCat({kMetricPrefix, infix}), *method_name_, "Success"},
+            "."),
+        success_status == SuccessStatus::kSuccess);
+  }
 }
 
 void PasswordStoreBackendMetricsRecorder::RecordErrorCode(
@@ -100,12 +116,16 @@
   base::UmaHistogramEnumeration(
       base::StrCat({kMetricPrefix, "AndroidBackend.ErrorCode"}),
       backend_error.type);
-  base::UmaHistogramEnumeration(BuildMetricName("ErrorCode"),
-                                backend_error.type);
+  base::UmaHistogramEnumeration(
+      base::JoinString({base::StrCat({kMetricPrefix, *backend_infix_}),
+                        *method_name_, "ErrorCode"},
+                       "."),
+      backend_error.type);
+
   if (backend_error.type == AndroidBackendErrorType::kExternalError) {
     DCHECK(backend_error.api_error_code.has_value());
     RecordApiErrorCode(backend_error.api_error_code.value());
-    LOG(ERROR) << "Password Manager API call for " << metric_infix_
+    LOG(ERROR) << "Password Manager API call for " << method_name_
                << " failed with error code: "
                << backend_error.api_error_code.value();
   }
@@ -116,15 +136,29 @@
 
 void PasswordStoreBackendMetricsRecorder::RecordLatency() const {
   base::TimeDelta duration = GetElapsedTimeSinceCreation();
-  base::UmaHistogramMediumTimes(BuildMetricName("Latency"), duration);
-  base::UmaHistogramMediumTimes(BuildOverallMetricName("Latency"), duration);
+
+  // Infixes for the overall and backend specific histogram.
+  const std::array<std::string_view, 2> possible_infixes = {"Backend",
+                                                            *backend_infix_};
+
+  for (const auto& infix : possible_infixes) {
+    base::UmaHistogramMediumTimes(
+        base::JoinString(
+            {base::StrCat({kMetricPrefix, infix}), *method_name_, "Latency"},
+            "."),
+        duration);
+  }
 }
 
 void PasswordStoreBackendMetricsRecorder::RecordApiErrorCode(
     int api_error_code) const {
   base::UmaHistogramSparse(
       base::StrCat({kMetricPrefix, "AndroidBackend.APIError"}), api_error_code);
-  base::UmaHistogramSparse(BuildMetricName("APIError"), api_error_code);
+  base::UmaHistogramSparse(
+      base::JoinString({base::StrCat({kMetricPrefix, *backend_infix_}),
+                        *method_name_, "APIError"},
+                       "."),
+      api_error_code);
 }
 
 void PasswordStoreBackendMetricsRecorder::RecordConnectionResultCode(
@@ -132,25 +166,10 @@
   base::UmaHistogramSparse(
       base::StrCat({kMetricPrefix, "AndroidBackend.ConnectionResultCode"}),
       connection_result_code);
-  base::UmaHistogramSparse(BuildMetricName("ConnectionResultCode"),
-                           connection_result_code);
-}
-
-std::string PasswordStoreBackendMetricsRecorder::GetBackendMetricName() const {
-  return base::StrCat({kMetricPrefix, *backend_infix_, ".", *metric_infix_});
-}
-
-std::string PasswordStoreBackendMetricsRecorder::BuildMetricName(
-    base::StringPiece suffix) const {
-  return base::StrCat({GetBackendMetricName(), ".", suffix});
-}
-
-std::string PasswordStoreBackendMetricsRecorder::GetOverallMetricName() const {
-  return base::StrCat({kMetricPrefix, "Backend.", *metric_infix_});
-}
-
-std::string PasswordStoreBackendMetricsRecorder::BuildOverallMetricName(
-    base::StringPiece suffix) const {
-  return base::StrCat({GetOverallMetricName(), ".", suffix});
+  base::UmaHistogramSparse(
+      base::JoinString({base::StrCat({kMetricPrefix, *backend_infix_}),
+                        *method_name_, "ConnectionResultCode"},
+                       "."),
+      connection_result_code);
 }
 }  // namespace password_manager
diff --git a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h
index ea948eca2..7ccd1ee 100644
--- a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h
+++ b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h
@@ -20,7 +20,7 @@
 using ErrorFromPasswordStoreOrAndroidBackend =
     absl::variant<PasswordStoreBackendError, AndroidBackendError>;
 
-using MetricInfix = base::StrongAlias<struct MetricNameTag, std::string>;
+using MethodName = base::StrongAlias<struct MetricNameTag, std::string>;
 using BackendInfix = base::StrongAlias<struct BackendNameTag, std::string>;
 
 // Records metrics for an asynchronous job or a series of jobs. The job is
@@ -40,7 +40,7 @@
   // Constructs a new recorder and immediately calls `RecordRequestStatus()` to
   // indicate a new request is started.
   explicit PasswordStoreBackendMetricsRecorder(BackendInfix backend_name,
-                                               MetricInfix metric_name);
+                                               MethodName method_name);
   PasswordStoreBackendMetricsRecorder(PasswordStoreBackendMetricsRecorder&&);
   PasswordStoreBackendMetricsRecorder& operator=(
       PasswordStoreBackendMetricsRecorder&&);
@@ -71,44 +71,39 @@
   };
 
   // Records a broad status for an ongoing request:
-  // - "PasswordManager.PasswordStoreBackend.<metric_infix_>"
-  // - "PasswordManager.PasswordStore<backend_infix_>.<metric_infix_>"
+  // - "PasswordManager.PasswordStoreBackend.<method_name_>"
+  // - "PasswordManager.PasswordStore<backend_infix_>.<method_name_>"
   void RecordRequestStatus(StoreBackendRequestStatus request_status) const;
 
   // Records the following metrics:
-  // - "PasswordManager.PasswordStore<backend_infix_>.<metric_infix_>.Success"
-  // - "PasswordManager.PasswordStoreBackend.<metric_infix_>.Success"
+  // - "PasswordManager.PasswordStore<backend_infix_>.<method_name_>.Success"
+  // - "PasswordManager.PasswordStoreBackend.<method_name_>.Success"
   void RecordSuccess(SuccessStatus success_status) const;
 
   // Records metrics from `RecordApiErrorCode` if `backend_error`
   // requires it. Additionally records the following metrics:
   // - "PasswordManager.PasswordStoreAndroidBackend.ErrorCode"
-  // - "PasswordManager.PasswordStoreAndroidBackend.<metric_infix_>.ErrorCode"
+  // - "PasswordManager.PasswordStoreAndroidBackend.<method_name_>.ErrorCode"
   void RecordErrorCode(const AndroidBackendError& backend_error) const;
 
   // Records the following metrics:
-  // - "PasswordManager.PasswordStore<backend_infix_>.<metric_infix_>.Latency"
-  // - "PasswordManager.PasswordStoreBackend.<metric_infix_>.Latency"
+  // - "PasswordManager.PasswordStore<backend_infix_>.<method_name_>.Latency"
+  // - "PasswordManager.PasswordStoreBackend.<method_name_>.Latency"
   void RecordLatency() const;
 
   // Records the following metrics:
   // - "PasswordManager.PasswordStoreAndroidBackend.APIError"
-  // - "PasswordManager.PasswordStoreAndroidBackend.<metric_infix_>.APIError"
+  // - "PasswordManager.PasswordStoreAndroidBackend.<method_name_>.APIError"
   void RecordApiErrorCode(int api_error_code) const;
 
   // Records the following metrics:
   // - "PasswordManager.PasswordStoreAndroidBackend.ConnectionResultCode"
-  // - "PasswordManager.PasswordStoreAndroidBackend.<metric_infix_>
+  // - "PasswordManager.PasswordStoreAndroidBackend.<method_name_>
   //        .ConnectionResultCode"
   void RecordConnectionResultCode(int connection_result_code) const;
 
-  std::string GetBackendMetricName() const;
-  std::string BuildMetricName(base::StringPiece suffix) const;
-  std::string GetOverallMetricName() const;
-  std::string BuildOverallMetricName(base::StringPiece suffix) const;
-
   BackendInfix backend_infix_;
-  MetricInfix metric_infix_;
+  MethodName method_name_;
   base::Time start_ = base::Time::Now();
 };
 }  // namespace password_manager
diff --git a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc
index 1187e58..cd60387 100644
--- a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc
+++ b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc
@@ -69,7 +69,7 @@
 
   PasswordStoreBackendMetricsRecorder metrics_recorder =
       PasswordStoreBackendMetricsRecorder(BackendInfix(kSomeBackend),
-                                          MetricInfix(kSomeMethod));
+                                          MethodName(kSomeMethod));
 
   // Checking started requests in the overall and backend-specific histogram.
   EXPECT_THAT(histogram_tester.GetAllSamples(kSpecificMetric),
@@ -110,7 +110,7 @@
 
   PasswordStoreBackendMetricsRecorder metrics_recorder =
       PasswordStoreBackendMetricsRecorder(BackendInfix(kSomeBackend),
-                                          MetricInfix(kSomeMethod));
+                                          MethodName(kSomeMethod));
 
   AdvanceClock(kLatencyDelta);
 
@@ -161,7 +161,7 @@
 
   PasswordStoreBackendMetricsRecorder metrics_recorder =
       PasswordStoreBackendMetricsRecorder(BackendInfix(kSomeBackend),
-                                          MetricInfix(kSomeMethod));
+                                          MethodName(kSomeMethod));
 
   AdvanceClock(kLatencyDelta);
 
@@ -211,7 +211,7 @@
 
   PasswordStoreBackendMetricsRecorder metrics_recorder =
       PasswordStoreBackendMetricsRecorder(BackendInfix(kSomeBackend),
-                                          MetricInfix(kSomeMethod));
+                                          MethodName(kSomeMethod));
 
   AdvanceClock(kLatencyDelta);
 
@@ -244,7 +244,7 @@
 
   PasswordStoreBackendMetricsRecorder metrics_recorder =
       PasswordStoreBackendMetricsRecorder(BackendInfix(kSomeBackend),
-                                          MetricInfix(kSomeMethod));
+                                          MethodName(kSomeMethod));
 
   AdvanceClock(kLatencyDelta);
 
diff --git a/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc b/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc
index 696630c..73845d4 100644
--- a/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc
+++ b/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc
@@ -29,9 +29,9 @@
 // PasswordChangesOrError as a result.
 template <typename Result>
 base::OnceCallback<Result(Result)> ReportMetricsForResultCallback(
-    MetricInfix infix) {
+    MethodName method_name) {
   PasswordStoreBackendMetricsRecorder metrics_reporter(
-      BackendInfix("BuiltInBackend"), infix);
+      BackendInfix("BuiltInBackend"), method_name);
   return base::BindOnce(
       [](PasswordStoreBackendMetricsRecorder reporter,
          Result result) -> Result {
@@ -105,7 +105,7 @@
           &LoginDatabaseAsyncHelper::GetAllLogins,
           base::Unretained(helper_.get())),  // Safe until `Shutdown()`.
       ReportMetricsForResultCallback<LoginsResultOrError>(
-          MetricInfix("GetAllLoginsAsync"))
+          MethodName("GetAllLoginsAsync"))
           .Then(std::move(callback)));
 }
 
@@ -129,7 +129,7 @@
           &LoginDatabaseAsyncHelper::GetAutofillableLogins,
           base::Unretained(helper_.get())),  // Safe until `Shutdown()`.
       ReportMetricsForResultCallback<LoginsResultOrError>(
-          MetricInfix("GetAutofillableLoginsAsync"))
+          MethodName("GetAutofillableLoginsAsync"))
           .Then(std::move(callback)));
 }
 
@@ -157,7 +157,7 @@
           base::Unretained(helper_.get()),  // Safe until `Shutdown()`.
           forms, include_psl),
       ReportMetricsForResultCallback<LoginsResultOrError>(
-          MetricInfix("FillMatchingLoginsAsync"))
+          MethodName("FillMatchingLoginsAsync"))
           .Then(std::move(callback)));
 }
 
@@ -181,7 +181,7 @@
       base::BindOnce(&LoginDatabaseAsyncHelper::AddLogin,
                      base::Unretained(helper_.get()), form),
       ReportMetricsForResultCallback<PasswordChangesOrError>(
-          MetricInfix("AddLoginAsync"))
+          MethodName("AddLoginAsync"))
           .Then(std::move(callback)));
 }
 
@@ -195,7 +195,7 @@
       base::BindOnce(&LoginDatabaseAsyncHelper::UpdateLogin,
                      base::Unretained(helper_.get()), form),
       ReportMetricsForResultCallback<PasswordChangesOrError>(
-          MetricInfix("UpdateLoginAsync"))
+          MethodName("UpdateLoginAsync"))
           .Then(std::move(callback)));
 }
 
@@ -211,7 +211,7 @@
           base::Unretained(helper_.get()),  // Safe until `Shutdown()`.
           form),
       ReportMetricsForResultCallback<PasswordChangesOrError>(
-          MetricInfix("RemoveLoginAsync"))
+          MethodName("RemoveLoginAsync"))
           .Then(std::move(callback)));
 }
 
@@ -228,7 +228,7 @@
           base::Unretained(helper_.get()),  // Safe until `Shutdown()`.
           delete_begin, delete_end),
       ReportMetricsForResultCallback<PasswordChangesOrError>(
-          MetricInfix("RemoveLoginsCreatedBetweenAsync"))
+          MethodName("RemoveLoginsCreatedBetweenAsync"))
           .Then(std::move(callback)));
 }
 
@@ -247,7 +247,7 @@
           base::Unretained(helper_.get()),  // Safe until `Shutdown()`.
           url_filter, delete_begin, delete_end, std::move(sync_completion)),
       ReportMetricsForResultCallback<PasswordChangesOrError>(
-          MetricInfix("RemoveLoginsByURLAndTimeAsync"))
+          MethodName("RemoveLoginsByURLAndTimeAsync"))
           .Then(std::move(callback)));
 }