Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java

Issue 2182123003: [Payments] Add information requested by merchant metrics to PR. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored and added integration tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
new file mode 100644
index 0000000000000000000000000000000000000000..f7b52acaa4ca394e277cb51fc22fc329f5098fba
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestMetrics.java
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.payments;
+
+import org.chromium.base.metrics.RecordHistogram;
+
+/**
+ * A class used to record metrics for the Payment Request feature.
+ */
+public final class PaymentRequestMetrics {
+
+ // PaymentRequestRequestedInformation defined in tools/metrics/histograms/histograms.xml.
+ public static final int REQUESTED_INFORMATION_NONE = 0;
please use gerrit instead 2016/07/27 16:24:40 Put @VisibleForTesting on all of these constants.
sebsg 2016/07/27 17:26:01 Done.
+ public static final int REQUESTED_INFORMATION_EMAIL = 1;
+ public static final int REQUESTED_INFORMATION_PHONE = 2;
+ public static final int REQUESTED_INFORMATION_SHIPPING = 3;
+ public static final int REQUESTED_INFORMATION_EMAIL_PHONE = 4;
+ public static final int REQUESTED_INFORMATION_EMAIL_SHIPPING = 5;
+ public static final int REQUESTED_INFORMATION_PHONE_SHIPPING = 6;
+ public static final int REQUESTED_INFORMATION_EMAIL_PHONE_SHIPPING = 7;
+ public static final int REQUESTED_INFORMATION_MAX = 8;
+
+ // There should be no instance of PaymentRequestMetrics created.
+ private PaymentRequestMetrics() {};
+
+ public static void recordRequestedInformationHistogram(boolean requestEmail,
please use gerrit instead 2016/07/27 16:24:40 All public functions need Javadoc.
sebsg 2016/07/27 17:26:01 Done.
+ boolean requestPhone, boolean requestShipping) {
+ int requestInformation;
+ if (requestEmail) {
please use gerrit instead 2016/07/27 16:24:40 The simpler way to map 3 booleans to a number: con
sebsg 2016/07/27 17:26:01 Nice thanks!
+ if (requestPhone) {
+ if (requestShipping) {
+ requestInformation = REQUESTED_INFORMATION_EMAIL_PHONE_SHIPPING;
+ } else {
+ requestInformation = REQUESTED_INFORMATION_EMAIL_PHONE;
+ }
+ } else {
+ if (requestShipping) {
+ requestInformation = REQUESTED_INFORMATION_EMAIL_SHIPPING;
+ } else {
+ requestInformation = REQUESTED_INFORMATION_EMAIL;
+ }
+ }
+ } else {
+ if (requestPhone) {
+ if (requestShipping) {
+ requestInformation = REQUESTED_INFORMATION_PHONE_SHIPPING;
+ } else {
+ requestInformation = REQUESTED_INFORMATION_PHONE;
+ }
+ } else {
+ if (requestShipping) {
+ requestInformation = REQUESTED_INFORMATION_SHIPPING;
+ } else {
+ requestInformation = REQUESTED_INFORMATION_NONE;
+ }
+ }
+ }
+ RecordHistogram.recordEnumeratedHistogram("PaymentRequest.RequestedInformation",
+ requestInformation, REQUESTED_INFORMATION_MAX);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698