summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autofill/autofill_cc_infobar_delegate.cc14
-rw-r--r--chrome/browser/autofill/autofill_cc_infobar_delegate.h2
-rw-r--r--chrome/browser/autofill/autofill_download.cc2
-rw-r--r--chrome/browser/autofill/autofill_download_unittest.cc32
-rw-r--r--chrome/browser/autofill/autofill_metrics.cc78
-rw-r--r--chrome/browser/autofill/autofill_metrics.h77
-rw-r--r--chrome/browser/autofill/autofill_metrics_unittest.cc269
-rw-r--r--chrome/browser/autofill/form_structure.cc76
-rw-r--r--chrome/browser/autofill/phone_number.cc19
9 files changed, 325 insertions, 244 deletions
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
index 9d37e64..8a1b86a 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
@@ -24,17 +24,17 @@ AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
personal_data_(personal_data),
metric_logger_(metric_logger),
had_user_interaction_(false) {
- metric_logger_->Log(AutofillMetrics::CREDIT_CARD_INFOBAR_SHOWN);
+ metric_logger_->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
}
AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
}
void AutofillCCInfoBarDelegate::LogUserAction(
- AutofillMetrics::CreditCardInfoBarMetric user_action) {
+ AutofillMetrics::InfoBarMetric user_action) {
DCHECK(!had_user_interaction_);
- metric_logger_->Log(user_action);
+ metric_logger_->LogCreditCardInfoBarMetric(user_action);
had_user_interaction_ = true;
}
@@ -48,13 +48,13 @@ bool AutofillCCInfoBarDelegate::ShouldExpire(
void AutofillCCInfoBarDelegate::InfoBarClosed() {
if (!had_user_interaction_)
- LogUserAction(AutofillMetrics::CREDIT_CARD_INFOBAR_IGNORED);
+ LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
delete this;
}
void AutofillCCInfoBarDelegate::InfoBarDismissed() {
- LogUserAction(AutofillMetrics::CREDIT_CARD_INFOBAR_DENIED);
+ LogUserAction(AutofillMetrics::INFOBAR_DENIED);
}
gfx::Image* AutofillCCInfoBarDelegate::GetIcon() const {
@@ -77,12 +77,12 @@ string16 AutofillCCInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
bool AutofillCCInfoBarDelegate::Accept() {
personal_data_->SaveImportedCreditCard(*credit_card_);
- LogUserAction(AutofillMetrics::CREDIT_CARD_INFOBAR_ACCEPTED);
+ LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
return true;
}
bool AutofillCCInfoBarDelegate::Cancel() {
- LogUserAction(AutofillMetrics::CREDIT_CARD_INFOBAR_DENIED);
+ LogUserAction(AutofillMetrics::INFOBAR_DENIED);
return true;
}
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.h b/chrome/browser/autofill/autofill_cc_infobar_delegate.h
index 1ff3576..a686b93 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.h
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.h
@@ -32,7 +32,7 @@ class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate {
private:
virtual ~AutofillCCInfoBarDelegate();
- void LogUserAction(AutofillMetrics::CreditCardInfoBarMetric user_action);
+ void LogUserAction(AutofillMetrics::InfoBarMetric user_action);
// ConfirmInfoBarDelegate:
virtual bool ShouldExpire(
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc
index aa231cc..a8ce10e 100644
--- a/chrome/browser/autofill/autofill_download.cc
+++ b/chrome/browser/autofill/autofill_download.cc
@@ -86,7 +86,7 @@ bool AutofillDownloadManager::StartQueryRequest(
}
request_data.request_type = AutofillDownloadManager::REQUEST_QUERY;
- metric_logger.Log(AutofillMetrics::QUERY_SENT);
+ metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_SENT);
std::string query_data;
if (CheckCacheForQueryRequest(request_data.form_signatures, &query_data)) {
diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc
index 326961f..1261568 100644
--- a/chrome/browser/autofill/autofill_download_unittest.cc
+++ b/chrome/browser/autofill/autofill_download_unittest.cc
@@ -30,7 +30,7 @@ namespace {
class MockAutofillMetrics : public AutofillMetrics {
public:
MockAutofillMetrics() {}
- MOCK_CONST_METHOD1(Log, void(ServerQueryMetric metric));
+ MOCK_CONST_METHOD1(LogServerQueryMetric, void(ServerQueryMetric metric));
private:
DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics);
@@ -202,7 +202,8 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
// Request with id 0.
MockAutofillMetrics mock_metric_logger;
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(2);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(2);
// First one will fail because context is not set up.
EXPECT_FALSE(helper.download_manager.StartQueryRequest(form_structures,
mock_metric_logger));
@@ -306,7 +307,8 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
form_structures.push_back(form_structure);
// Request with id 3.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures,
mock_metric_logger));
fetcher = factory.GetFetcherByID(3);
@@ -325,7 +327,8 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
helper.responses_.pop_front();
// Query requests should be ignored for the next 10 seconds.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(0);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0);
EXPECT_FALSE(helper.download_manager.StartQueryRequest(form_structures,
mock_metric_logger));
fetcher = factory.GetFetcherByID(4);
@@ -439,7 +442,8 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
// Request with id 0.
MockAutofillMetrics mock_metric_logger;
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures0,
mock_metric_logger));
// No responses yet
@@ -457,7 +461,8 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
helper.responses_.clear();
// No actual request - should be a cache hit.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures0,
mock_metric_logger));
// Data is available immediately from cache - no over-the-wire trip.
@@ -466,7 +471,8 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
helper.responses_.clear();
// Request with id 1.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures1,
mock_metric_logger));
// No responses yet
@@ -484,7 +490,8 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
helper.responses_.clear();
// Request with id 2.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures2,
mock_metric_logger));
@@ -500,11 +507,13 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
helper.responses_.clear();
// No actual requests - should be a cache hit.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures1,
mock_metric_logger));
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures2,
mock_metric_logger));
@@ -515,7 +524,8 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) {
// The first structure should've expired.
// Request with id 3.
- EXPECT_CALL(mock_metric_logger, Log(AutofillMetrics::QUERY_SENT)).Times(1);
+ EXPECT_CALL(mock_metric_logger,
+ LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures0,
mock_metric_logger));
// No responses yet
diff --git a/chrome/browser/autofill/autofill_metrics.cc b/chrome/browser/autofill/autofill_metrics.cc
index 793d578..eb327e5 100644
--- a/chrome/browser/autofill/autofill_metrics.cc
+++ b/chrome/browser/autofill/autofill_metrics.cc
@@ -29,9 +29,25 @@ enum FieldTypeGroupForMetrics {
NUM_FIELD_TYPE_GROUPS_FOR_METRICS
};
-// Translates |field_type| to the corresponding logical grouping for metrics,
-// and then interpolates this with the given |metric|, which should be in the
-// range [0, |num_possible_metrics|). Returns the interpolated metric.
+// First, translates |field_type| to the corresponding logical |group| from
+// |FieldTypeGroupForMetrics|. Then, interpolates this with the given |metric|,
+// which should be in the range [0, |num_possible_metrics|).
+// Returns the interpolated index.
+//
+// The interpolation maps the pair (|group|, |metric|) to a single index, so
+// that all the indicies for a given group are adjacent. In particular, with
+// the groups {AMBIGUOUS, NAME, ...} combining with the metrics {UNKNOWN, MATCH,
+// MISMATCH}, we create this set of mapped indices:
+// {
+// AMBIGUOUS+UNKNOWN,
+// AMBIGUOUS+MATCH,
+// AMBIGUOUS+MISMATCH,
+// NAME+UNKNOWN,
+// NAME+MATCH,
+// NAME+MISMATCH,
+// ...
+// }.
+//
// Clients must ensure that |field_type| is one of the types Chrome supports
// natively, e.g. |field_type| must not be a billng address.
int GetFieldTypeGroupMetric(const AutofillFieldType field_type,
@@ -110,14 +126,7 @@ int GetFieldTypeGroupMetric(const AutofillFieldType field_type,
}
// Interpolate the |metric| with the |group|, so that all metrics for a given
- // |group| are adjacent. The resulting metrics will be arranged as:
- // AMBIGUOUS_UNKNOWN
- // AMBIGUOUS_MATCH
- // AMBIGUOUS_MISMATCH
- // NAME_UNKNOWN
- // NAME_MATCH
- // NAME_MISMATCH
- // ...
+ // |group| are adjacent.
return (group * num_possible_metrics) + metric;
}
@@ -175,31 +184,42 @@ AutofillMetrics::AutofillMetrics() {
AutofillMetrics::~AutofillMetrics() {
}
-void AutofillMetrics::Log(CreditCardInfoBarMetric metric) const {
- DCHECK(metric < NUM_CREDIT_CARD_INFO_BAR_METRICS);
+void AutofillMetrics::LogCreditCardInfoBarMetric(InfoBarMetric metric) const {
+ DCHECK(metric < NUM_INFO_BAR_METRICS);
UMA_HISTOGRAM_ENUMERATION("Autofill.CreditCardInfoBar", metric,
- NUM_CREDIT_CARD_INFO_BAR_METRICS);
+ NUM_INFO_BAR_METRICS);
}
-void AutofillMetrics::Log(HeuristicTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id) const {
+void AutofillMetrics::LogHeuristicTypePrediction(
+ FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id) const {
LogTypeQualityMetric("Autofill.Quality.HeuristicType",
- metric, NUM_HEURISTIC_TYPE_QUALITY_METRICS,
+ metric, NUM_FIELD_TYPE_QUALITY_METRICS,
field_type, experiment_id);
}
-void AutofillMetrics::Log(PredictedTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id) const {
+void AutofillMetrics::LogOverallTypePrediction(
+ FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id) const {
LogTypeQualityMetric("Autofill.Quality.PredictedType",
- metric, NUM_PREDICTED_TYPE_QUALITY_METRICS,
+ metric, NUM_FIELD_TYPE_QUALITY_METRICS,
field_type, experiment_id);
}
-void AutofillMetrics::Log(QualityMetric metric,
- const std::string& experiment_id) const {
+void AutofillMetrics::LogServerTypePrediction(
+ FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id) const {
+ LogTypeQualityMetric("Autofill.Quality.ServerType",
+ metric, NUM_FIELD_TYPE_QUALITY_METRICS,
+ field_type, experiment_id);
+}
+
+void AutofillMetrics::LogQualityMetric(QualityMetric metric,
+ const std::string& experiment_id) const {
DCHECK(metric < NUM_QUALITY_METRICS);
std::string histogram_name = "Autofill.Quality";
@@ -209,21 +229,13 @@ void AutofillMetrics::Log(QualityMetric metric,
LogUMAHistogramEnumeration(histogram_name, metric, NUM_QUALITY_METRICS);
}
-void AutofillMetrics::Log(ServerQueryMetric metric) const {
+void AutofillMetrics::LogServerQueryMetric(ServerQueryMetric metric) const {
DCHECK(metric < NUM_SERVER_QUERY_METRICS);
UMA_HISTOGRAM_ENUMERATION("Autofill.ServerQueryResponse", metric,
NUM_SERVER_QUERY_METRICS);
}
-void AutofillMetrics::Log(ServerTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id) const {
- LogTypeQualityMetric("Autofill.Quality.ServerType",
- metric, NUM_SERVER_TYPE_QUALITY_METRICS,
- field_type, experiment_id);
-}
-
void AutofillMetrics::LogIsAutofillEnabledAtStartup(bool enabled) const {
UMA_HISTOGRAM_BOOLEAN("Autofill.IsEnabled.Startup", enabled);
}
diff --git a/chrome/browser/autofill/autofill_metrics.h b/chrome/browser/autofill/autofill_metrics.h
index 2b1b18f..e55464d 100644
--- a/chrome/browser/autofill/autofill_metrics.h
+++ b/chrome/browser/autofill/autofill_metrics.h
@@ -14,36 +14,25 @@
class AutofillMetrics {
public:
- enum CreditCardInfoBarMetric {
- CREDIT_CARD_INFOBAR_SHOWN = 0, // We showed an infobar prompting to save
- // credit card info.
- CREDIT_CARD_INFOBAR_ACCEPTED, // The user explicitly accepted the infobar.
- CREDIT_CARD_INFOBAR_DENIED, // The user explicitly denied the infobar.
- CREDIT_CARD_INFOBAR_IGNORED, // The user completely ignored the infobar
- // (logged on tab close).
- NUM_CREDIT_CARD_INFO_BAR_METRICS
+ enum InfoBarMetric {
+ INFOBAR_SHOWN = 0, // We showed an infobar, e.g. prompting to save credit
+ // card info.
+ INFOBAR_ACCEPTED, // The user explicitly accepted the infobar.
+ INFOBAR_DENIED, // The user explicitly denied the infobar.
+ INFOBAR_IGNORED, // The user completely ignored the infobar (logged on
+ // tab close).
+ NUM_INFO_BAR_METRICS
};
- // Metrics measuring how well we predict field types. Exactly one metric from
- // each set is logged for each fillable field in a submitted form.
- enum HeuristicTypeQualityMetric {
- HEURISTIC_TYPE_UNKNOWN = 0, // Our heuristics offered no prediction.
- HEURISTIC_TYPE_MATCH, // Our heuristics predicted correctly.
- HEURISTIC_TYPE_MISMATCH, // Our heuristics predicted incorrectly.
- NUM_HEURISTIC_TYPE_QUALITY_METRICS
- };
- enum ServerTypeQualityMetric {
- SERVER_TYPE_UNKNOWN = 0, // The server offered no prediction.
- SERVER_TYPE_MATCH, // The server predicted correctly.
- SERVER_TYPE_MISMATCH, // The server predicted incorrectly.
- NUM_SERVER_TYPE_QUALITY_METRICS
- };
- enum PredictedTypeQualityMetric {
- PREDICTED_TYPE_UNKNOWN = 0, // Neither server nor heuristics offered a
- // prediction.
- PREDICTED_TYPE_MATCH, // Overall, predicted correctly.
- PREDICTED_TYPE_MISMATCH, // Overall, predicted incorrectly.
- NUM_PREDICTED_TYPE_QUALITY_METRICS
+ // Metrics measuring how well we predict field types. Exactly three such
+ // metrics are logged for each fillable field in a submitted form: for
+ // the heuristic prediction, for the crowd-sourced prediction, and for the
+ // overall prediction.
+ enum FieldTypeQualityMetric {
+ TYPE_UNKNOWN = 0, // Offered no prediction.
+ TYPE_MATCH, // Predicted correctly.
+ TYPE_MISMATCH, // Predicted incorrectly.
+ NUM_FIELD_TYPE_QUALITY_METRICS
};
enum QualityMetric {
@@ -93,19 +82,25 @@ class AutofillMetrics {
AutofillMetrics();
virtual ~AutofillMetrics();
- virtual void Log(CreditCardInfoBarMetric metric) const;
- virtual void Log(HeuristicTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id) const;
- virtual void Log(PredictedTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id) const;
- virtual void Log(QualityMetric metric,
- const std::string& experiment_id) const;
- virtual void Log(ServerQueryMetric metric) const;
- virtual void Log(ServerTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id) const;
+ virtual void LogCreditCardInfoBarMetric(InfoBarMetric metric) const;
+
+ virtual void LogHeuristicTypePrediction(
+ FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id) const;
+ virtual void LogOverallTypePrediction(
+ FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id) const;
+ virtual void LogServerTypePrediction(FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id) const;
+
+ virtual void LogQualityMetric(QualityMetric metric,
+ const std::string& experiment_id) const;
+
+ virtual void LogServerQueryMetric(ServerQueryMetric metric) const;
+
// This should be called each time a page containing forms is loaded.
virtual void LogIsAutofillEnabledAtPageLoad(bool enabled) const;
diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc
index 728731d..286a65a 100644
--- a/chrome/browser/autofill/autofill_metrics_unittest.cc
+++ b/chrome/browser/autofill/autofill_metrics_unittest.cc
@@ -29,19 +29,22 @@ namespace {
class MockAutofillMetrics : public AutofillMetrics {
public:
MockAutofillMetrics() {}
- MOCK_CONST_METHOD1(Log, void(CreditCardInfoBarMetric metric));
- MOCK_CONST_METHOD3(Log, void(HeuristicTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id));
- MOCK_CONST_METHOD3(Log, void(PredictedTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id));
- MOCK_CONST_METHOD2(Log, void(QualityMetric metric,
- const std::string& experiment_id));
- MOCK_CONST_METHOD1(Log, void(ServerQueryMetric metric));
- MOCK_CONST_METHOD3(Log, void(ServerTypeQualityMetric metric,
- AutofillFieldType field_type,
- const std::string& experiment_id));
+ MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric));
+ MOCK_CONST_METHOD3(LogHeuristicTypePrediction,
+ void(FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id));
+ MOCK_CONST_METHOD3(LogOverallTypePrediction,
+ void(FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id));
+ MOCK_CONST_METHOD3(LogServerTypePrediction,
+ void(FieldTypeQualityMetric metric,
+ AutofillFieldType field_type,
+ const std::string& experiment_id));
+ MOCK_CONST_METHOD2(LogQualityMetric, void(QualityMetric metric,
+ const std::string& experiment_id));
+ MOCK_CONST_METHOD1(LogServerQueryMetric, void(ServerQueryMetric metric));
MOCK_CONST_METHOD1(LogIsAutofillEnabledAtPageLoad, void(bool enabled));
MOCK_CONST_METHOD1(LogIsAutofillEnabledAtStartup, void(bool enabled));
MOCK_CONST_METHOD1(LogStoredProfileCount, void(size_t num_profiles));
@@ -263,70 +266,81 @@ TEST_F(AutofillMetricsTest, QualityMetrics) {
::testing::InSequence dummy;
// Autofilled field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MATCH,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
UNKNOWN_TYPE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MISMATCH,
+ LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
UNKNOWN_TYPE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MISMATCH,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
UNKNOWN_TYPE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
+ std::string()));
// Non-autofilled field for which we had data
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MISMATCH,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MISMATCH,
EMAIL_ADDRESS, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MATCH,
+ LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
EMAIL_ADDRESS, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MATCH,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
EMAIL_ADDRESS, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_NOT_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
std::string()));
// Empty field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
// Unknown field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
// <select> field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_UNKNOWN,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
ADDRESS_HOME_COUNTRY, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_UNKNOWN,
+ LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
ADDRESS_HOME_COUNTRY, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_UNKNOWN,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
ADDRESS_HOME_COUNTRY, std::string()));
// Phone field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MATCH,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
PHONE_HOME_WHOLE_NUMBER, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MATCH,
+ LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
PHONE_HOME_WHOLE_NUMBER, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MATCH,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
PHONE_HOME_WHOLE_NUMBER, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
+ std::string()));
// Simulate form submission.
EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form));
@@ -430,13 +444,17 @@ TEST_F(AutofillMetricsTest, QualityMetricsForFailure) {
::testing::InSequence dummy;
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failure_cases); ++i) {
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_NOT_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(failure_cases[i].heuristic_metric, std::string()));
+ LogQualityMetric(failure_cases[i].heuristic_metric,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(failure_cases[i].server_metric, std::string()));
+ LogQualityMetric(failure_cases[i].server_metric,
+ std::string()));
}
// Simulate form submission.
@@ -500,81 +518,96 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
::testing::InSequence dummy;
// New field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_UNKNOWN,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
ADDRESS_HOME_STATE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_UNKNOWN,
+ LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
ADDRESS_HOME_STATE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_UNKNOWN,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
ADDRESS_HOME_STATE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_NOT_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_UNKNOWN,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_UNKNOWN,
std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_UNKNOWN,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_UNKNOWN,
std::string()));
// Only heuristics match
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MATCH,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
ADDRESS_HOME_CITY, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MISMATCH,
+ LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
ADDRESS_HOME_CITY, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MISMATCH,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
ADDRESS_HOME_CITY, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_NOT_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MATCH,
std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
std::string()));
// Both mismatch
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MISMATCH,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MISMATCH,
EMAIL_ADDRESS, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MISMATCH,
+ LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
EMAIL_ADDRESS, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MISMATCH,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
EMAIL_ADDRESS, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_NOT_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
std::string()));
// Unknown
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
// Both match
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MATCH,
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
UNKNOWN_TYPE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MATCH,
+ LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
UNKNOWN_TYPE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MATCH,
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
UNKNOWN_TYPE, std::string()));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_AUTOFILLED, std::string()));
+ LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
+ std::string()));
// Simulate form submission.
EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form));
@@ -601,7 +634,8 @@ TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) {
// Simulate form submission.
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string())).Times(0);
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string())).Times(0);
EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form));
// Search forms are not auto-fillable.
@@ -612,7 +646,8 @@ TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) {
// Simulate form submission.
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, std::string())).Times(0);
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ std::string())).Times(0);
EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form));
}
@@ -673,56 +708,65 @@ TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) {
::testing::InSequence dummy;
// Autofilled field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MATCH,
- UNKNOWN_TYPE, experiment_id));
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
+ UNKNOWN_TYPE, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MISMATCH,
- UNKNOWN_TYPE, experiment_id));
+ LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ UNKNOWN_TYPE, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MISMATCH,
- UNKNOWN_TYPE, experiment_id));
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ UNKNOWN_TYPE, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_AUTOFILLED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
+ experiment_id));
// Non-autofilled field for which we had data
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_MISMATCH,
- EMAIL_ADDRESS, experiment_id));
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ EMAIL_ADDRESS, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_MATCH,
- EMAIL_ADDRESS, experiment_id));
+ LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
+ EMAIL_ADDRESS, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_MATCH,
- EMAIL_ADDRESS, experiment_id));
+ LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
+ EMAIL_ADDRESS, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_NOT_AUTOFILLED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
+ LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
experiment_id));
// Empty field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ experiment_id));
// Unknown field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ experiment_id));
// <select> field
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id));
+ LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::HEURISTIC_TYPE_UNKNOWN,
- ADDRESS_HOME_COUNTRY, experiment_id));
+ LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ ADDRESS_HOME_COUNTRY, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::SERVER_TYPE_UNKNOWN,
- ADDRESS_HOME_COUNTRY, experiment_id));
+ LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ ADDRESS_HOME_COUNTRY, experiment_id));
EXPECT_CALL(*autofill_manager_->metric_logger(),
- Log(AutofillMetrics::PREDICTED_TYPE_UNKNOWN,
- ADDRESS_HOME_COUNTRY, experiment_id));
+ LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ ADDRESS_HOME_COUNTRY, experiment_id));
// Simulate form submission.
EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form));
@@ -854,7 +898,8 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
::testing::InSequence dummy;
// Accept the infobar.
- EXPECT_CALL(metric_logger, Log(AutofillMetrics::CREDIT_CARD_INFOBAR_SHOWN));
+ EXPECT_CALL(metric_logger,
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
credit_card = new CreditCard();
infobar = new AutofillCCInfoBarDelegate(contents(),
credit_card,
@@ -863,14 +908,17 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
EXPECT_CALL(*test_personal_data_.get(), SaveImportedCreditCard(*credit_card));
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_ACCEPTED)).Times(1);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED))
+ .Times(1);
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_IGNORED)).Times(0);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED))
+ .Times(0);
EXPECT_TRUE(infobar->Accept());
infobar->InfoBarClosed();
// Cancel the infobar.
- EXPECT_CALL(metric_logger, Log(AutofillMetrics::CREDIT_CARD_INFOBAR_SHOWN));
+ EXPECT_CALL(metric_logger,
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
credit_card = new CreditCard();
infobar = new AutofillCCInfoBarDelegate(contents(),
credit_card,
@@ -878,14 +926,17 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
&metric_logger);
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_DENIED)).Times(1);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED))
+ .Times(1);
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_IGNORED)).Times(0);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED))
+ .Times(0);
EXPECT_TRUE(infobar->Cancel());
infobar->InfoBarClosed();
// Dismiss the infobar.
- EXPECT_CALL(metric_logger, Log(AutofillMetrics::CREDIT_CARD_INFOBAR_SHOWN));
+ EXPECT_CALL(metric_logger,
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
credit_card = new CreditCard();
infobar = new AutofillCCInfoBarDelegate(contents(),
credit_card,
@@ -893,14 +944,17 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
&metric_logger);
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_DENIED)).Times(1);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED))
+ .Times(1);
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_IGNORED)).Times(0);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED))
+ .Times(0);
infobar->InfoBarDismissed();
infobar->InfoBarClosed();
// Ignore the infobar.
- EXPECT_CALL(metric_logger, Log(AutofillMetrics::CREDIT_CARD_INFOBAR_SHOWN));
+ EXPECT_CALL(metric_logger,
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
credit_card = new CreditCard();
infobar = new AutofillCCInfoBarDelegate(contents(),
credit_card,
@@ -908,6 +962,7 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
&metric_logger);
EXPECT_CALL(metric_logger,
- Log(AutofillMetrics::CREDIT_CARD_INFOBAR_IGNORED)).Times(1);
+ LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED))
+ .Times(1);
infobar->InfoBarClosed();
}
diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc
index 7c22a2b..e7b0ad9 100644
--- a/chrome/browser/autofill/form_structure.cc
+++ b/chrome/browser/autofill/form_structure.cc
@@ -199,7 +199,7 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml,
const std::vector<FormStructure*>& forms,
UploadRequired* upload_required,
const AutofillMetrics& metric_logger) {
- metric_logger.Log(AutofillMetrics::QUERY_RESPONSE_RECEIVED);
+ metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED);
// Parse the field types from the server response to the query.
std::vector<AutofillFieldType> field_types;
@@ -211,7 +211,7 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml,
if (!parse_handler.succeeded())
return;
- metric_logger.Log(AutofillMetrics::QUERY_RESPONSE_PARSED);
+ metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED);
bool heuristics_detected_fillable_field = false;
bool query_response_overrode_heuristics = false;
@@ -268,7 +268,7 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml,
} else {
metric = AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS;
}
- metric_logger.Log(metric);
+ metric_logger.LogServerQueryMetric(metric);
}
std::string FormStructure::FormSignature() const {
@@ -351,7 +351,8 @@ void FormStructure::LogQualityMetrics(
std::string experiment_id = server_experiment_id();
for (size_t i = 0; i < field_count(); ++i) {
const AutofillField* field = this->field(i);
- metric_logger.Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id);
+ metric_logger.LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
+ experiment_id);
// No further logging for empty fields nor for fields where the entered data
// does not appear to already exist in the user's stored Autofill data.
@@ -390,36 +391,36 @@ void FormStructure::LogQualityMetrics(
// Log heuristic, server, and overall type quality metrics, independently of
// whether the field was autofilled.
if (heuristic_type == UNKNOWN_TYPE) {
- metric_logger.Log(AutofillMetrics::HEURISTIC_TYPE_UNKNOWN,
- field_type, experiment_id);
+ metric_logger.LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ field_type, experiment_id);
} else if (field_types.count(heuristic_type)) {
- metric_logger.Log(AutofillMetrics::HEURISTIC_TYPE_MATCH,
- field_type, experiment_id);
+ metric_logger.LogHeuristicTypePrediction(AutofillMetrics::TYPE_MATCH,
+ field_type, experiment_id);
} else {
- metric_logger.Log(AutofillMetrics::HEURISTIC_TYPE_MISMATCH,
- field_type, experiment_id);
+ metric_logger.LogHeuristicTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ field_type, experiment_id);
}
if (server_type == NO_SERVER_DATA) {
- metric_logger.Log(AutofillMetrics::SERVER_TYPE_UNKNOWN,
- field_type, experiment_id);
+ metric_logger.LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ field_type, experiment_id);
} else if (field_types.count(server_type)) {
- metric_logger.Log(AutofillMetrics::SERVER_TYPE_MATCH,
- field_type, experiment_id);
+ metric_logger.LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
+ field_type, experiment_id);
} else {
- metric_logger.Log(AutofillMetrics::SERVER_TYPE_MISMATCH,
- field_type, experiment_id);
+ metric_logger.LogServerTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ field_type, experiment_id);
}
if (predicted_type == UNKNOWN_TYPE) {
- metric_logger.Log(AutofillMetrics::PREDICTED_TYPE_UNKNOWN,
- field_type, experiment_id);
+ metric_logger.LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
+ field_type, experiment_id);
} else if (field_types.count(predicted_type)) {
- metric_logger.Log(AutofillMetrics::PREDICTED_TYPE_MATCH,
- field_type, experiment_id);
+ metric_logger.LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
+ field_type, experiment_id);
} else {
- metric_logger.Log(AutofillMetrics::PREDICTED_TYPE_MISMATCH,
- field_type, experiment_id);
+ metric_logger.LogOverallTypePrediction(AutofillMetrics::TYPE_MISMATCH,
+ field_type, experiment_id);
}
// TODO(isherman): <select> fields don't support |is_autofilled()|, so we
@@ -428,33 +429,38 @@ void FormStructure::LogQualityMetrics(
continue;
if (field->is_autofilled) {
- metric_logger.Log(AutofillMetrics::FIELD_AUTOFILLED, experiment_id);
+ metric_logger.LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
+ experiment_id);
} else {
- metric_logger.Log(AutofillMetrics::FIELD_NOT_AUTOFILLED,
- experiment_id);
+ metric_logger.LogQualityMetric(AutofillMetrics::FIELD_NOT_AUTOFILLED,
+ experiment_id);
if (heuristic_type == UNKNOWN_TYPE) {
- metric_logger.Log(
+ metric_logger.LogQualityMetric(
AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_UNKNOWN,
experiment_id);
} else if (field_types.count(heuristic_type)) {
- metric_logger.Log(AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MATCH,
- experiment_id);
+ metric_logger.LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MATCH,
+ experiment_id);
} else {
- metric_logger.Log(
+ metric_logger.LogQualityMetric(
AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH,
experiment_id);
}
if (server_type == NO_SERVER_DATA) {
- metric_logger.Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_UNKNOWN,
- experiment_id);
+ metric_logger.LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_UNKNOWN,
+ experiment_id);
} else if (field_types.count(server_type)) {
- metric_logger.Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
- experiment_id);
+ metric_logger.LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MATCH,
+ experiment_id);
} else {
- metric_logger.Log(AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
- experiment_id);
+ metric_logger.LogQualityMetric(
+ AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH,
+ experiment_id);
}
}
}
diff --git a/chrome/browser/autofill/phone_number.cc b/chrome/browser/autofill/phone_number.cc
index ff05da8..5b7c939 100644
--- a/chrome/browser/autofill/phone_number.cc
+++ b/chrome/browser/autofill/phone_number.cc
@@ -203,14 +203,17 @@ void PhoneNumber::set_whole_number(const string16& whole_number) {
bool PhoneNumber::IsNumber(const string16& text) const {
// TODO(isherman): This will need to be updated once we add support for
// international phone numbers.
- const size_t kPhoneNumberPrefixLength = 3;
- const size_t kPhoneNumberSuffixLength = 4;
- return
- (text == number_) ||
- (text.length() == kPhoneNumberPrefixLength &&
- StartsWith(number_, text, true)) ||
- (text.length() == kPhoneNumberSuffixLength &&
- EndsWith(number_, text, true));
+ const size_t kPrefixLength = 3;
+ const size_t kSuffixLength = 4;
+
+ if (text == number_)
+ return true;
+ if (text.length() == kPrefixLength && StartsWith(number_, text, true))
+ return true;
+ if (text.length() == kSuffixLength && EndsWith(number_, text, true))
+ return true;
+
+ return false;
}
bool PhoneNumber::IsCityCode(const string16& text) const {