Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
Mathieu
2017/03/23 21:19:48
would have been great to "git mv" the PaymentReque
sebsg
2017/03/24 13:35:29
Hum, I actually used git mv... Maybe because I cha
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.components.payments; | |
| 6 | |
| 7 import org.chromium.base.annotations.JNINamespace; | |
| 8 | |
| 9 /** | |
| 10 * A class used to record journey metrics for the Payment Request feature. | |
| 11 */ | |
| 12 @JNINamespace("payments") | |
| 13 public class JourneyLogger { | |
| 14 // The index of the different sections of a Payment Request. Used to record journey stats. | |
|
Mathieu
2017/03/23 21:19:48
if we are going to mirror these constants to C++,
sebsg
2017/03/24 13:35:29
Done.
| |
| 15 public static final int SECTION_CONTACT_INFO = 0; | |
| 16 public static final int SECTION_CREDIT_CARDS = 1; | |
| 17 public static final int SECTION_SHIPPING_ADDRESS = 2; | |
| 18 public static final int SECTION_MAX = 3; | |
| 19 | |
| 20 // For the CanMakePayment histograms. | |
| 21 public static final int CAN_MAKE_PAYMENT_USED = 0; | |
| 22 public static final int CAN_MAKE_PAYMENT_NOT_USED = 1; | |
| 23 public static final int CAN_MAKE_PAYMENT_USE_MAX = 2; | |
| 24 | |
| 25 // Used to log different parameters' effect on whether the transaction was c ompleted. | |
| 26 public static final int COMPLETION_STATUS_COMPLETED = 0; | |
| 27 public static final int COMPLETION_STATUS_ABORTED = 1; | |
| 28 public static final int COMPLETION_STATUS_MAX = 2; | |
| 29 | |
| 30 // Used to mesure the impact of the CanMakePayment return value on whether t he Payment Request | |
| 31 // is shown to the user. | |
| 32 public static final int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0 ; | |
| 33 public static final int CMP_SHOW_DID_SHOW = 1 << 0; | |
| 34 public static final int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1; | |
| 35 public static final int CMP_SHOW_MAX = 4; | |
| 36 | |
| 37 // The minimum expected value of CustomCountHistograms is always set to 1. I t is still possible | |
| 38 // to log the value 0 to that type of histogram. | |
| 39 private static final int MIN_EXPECTED_SAMPLE = 1; | |
| 40 private static final int MAX_EXPECTED_SAMPLE = 49; | |
| 41 private static final int NUMBER_BUCKETS = 50; | |
| 42 | |
| 43 /** | |
| 44 * Pointer to the native implementation. | |
| 45 */ | |
| 46 private long mJourneyLoggerAndroid; | |
| 47 | |
| 48 public JourneyLogger() { | |
| 49 // Note that this pointer could leak the native object. The called must call destroy() to | |
| 50 // ensure that the native object is destroyed. | |
| 51 mJourneyLoggerAndroid = nativeInitJourneyLoggerAndroid(); | |
| 52 } | |
| 53 | |
| 54 /** Will destroy the native object. This class shouldn't be used afterwards. */ | |
| 55 public void destroy() { | |
| 56 if (mJourneyLoggerAndroid != 0) { | |
| 57 nativeDestroy(mJourneyLoggerAndroid); | |
| 58 mJourneyLoggerAndroid = 0; | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 /** | |
| 63 * Sets the number of suggestions shown for the specified section. | |
| 64 * | |
| 65 * @param section The section for which to log. | |
| 66 * @param number The number of suggestions. | |
| 67 */ | |
| 68 public void setNumberOfSuggestionsShown(int section, int number) { | |
| 69 assert section < SECTION_MAX; | |
| 70 nativeSetNumberOfSuggestionsShown(mJourneyLoggerAndroid, section, number ); | |
| 71 } | |
| 72 | |
| 73 /** | |
| 74 * Increments the number of selection changes for the specified section. | |
| 75 * | |
| 76 * @param section The section for which to log. | |
| 77 */ | |
| 78 public void incrementSelectionChanges(int section) { | |
| 79 assert section < SECTION_MAX; | |
| 80 nativeIncrementSelectionChanges(mJourneyLoggerAndroid, section); | |
| 81 } | |
| 82 | |
| 83 /** | |
| 84 * Increments the number of selection edits for the specified section. | |
| 85 * | |
| 86 * @param section The section for which to log. | |
| 87 */ | |
| 88 public void incrementSelectionEdits(int section) { | |
| 89 assert section < SECTION_MAX; | |
| 90 nativeIncrementSelectionEdits(mJourneyLoggerAndroid, section); | |
| 91 } | |
| 92 | |
| 93 /** | |
| 94 * Increments the number of selection adds for the specified section. | |
| 95 * | |
| 96 * @param section The section for which to log. | |
| 97 */ | |
| 98 public void incrementSelectionAdds(int section) { | |
| 99 assert section < SECTION_MAX; | |
| 100 nativeIncrementSelectionAdds(mJourneyLoggerAndroid, section); | |
| 101 } | |
| 102 | |
| 103 /** | |
| 104 * Records the fact that the merchant called CanMakePayment and records it's return value. | |
| 105 * | |
| 106 * @param value The return value of the CanMakePayment call. | |
| 107 */ | |
| 108 public void setCanMakePaymentValue(boolean value) { | |
| 109 nativeSetCanMakePaymentValue(mJourneyLoggerAndroid, value); | |
| 110 } | |
| 111 | |
| 112 /** | |
| 113 * Records the fact that the Payment Request was shown to the user. | |
| 114 */ | |
| 115 public void setShowCalled() { | |
| 116 nativeSetShowCalled(mJourneyLoggerAndroid); | |
| 117 } | |
| 118 | |
| 119 /* | |
| 120 * Records the histograms for all the sections that were requested by the me rchant and for the | |
| 121 * usage of the CanMakePayment method and its effect on the transaction. Thi s method should be | |
| 122 * called when the payment request has either been completed or aborted. | |
| 123 * | |
| 124 * @param submissionType A string indicating the way the payment request was concluded. | |
| 125 */ | |
| 126 public void recordJourneyStatsHistograms(String submissionType) { | |
| 127 nativeRecordJourneyStatsHistograms(mJourneyLoggerAndroid, submissionType ); | |
| 128 } | |
| 129 | |
| 130 private native long nativeInitJourneyLoggerAndroid(); | |
| 131 private native void nativeDestroy(long nativeJourneyLoggerAndroid); | |
| 132 private native void nativeSetNumberOfSuggestionsShown( | |
| 133 long nativeJourneyLoggerAndroid, int section, int number); | |
| 134 private native void nativeIncrementSelectionChanges( | |
| 135 long nativeJourneyLoggerAndroid, int section); | |
| 136 private native void nativeIncrementSelectionEdits(long nativeJourneyLoggerAn droid, int section); | |
| 137 private native void nativeIncrementSelectionAdds(long nativeJourneyLoggerAnd roid, int section); | |
| 138 private native void nativeSetCanMakePaymentValue( | |
| 139 long nativeJourneyLoggerAndroid, boolean value); | |
| 140 private native void nativeSetShowCalled(long nativeJourneyLoggerAndroid); | |
| 141 private native void nativeRecordJourneyStatsHistograms( | |
| 142 long nativeJourneyLoggerAndroid, String submissionType); | |
| 143 } | |
| OLD | NEW |