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

Side by Side Diff: components/payments/content/android/java/src/org/chromium/components/payments/JourneyLogger.java

Issue 2750103005: [Payments] Move journey logger to native. (Closed)
Patch Set: Nits Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
please use gerrit instead 2017/03/24 16:31:46 Either run "git cl upload --similarity=10" to make
sebsg 2017/03/24 18:37:46 Nice it worked! Thanks!
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 // Note: The constants should always be in sync with those in the journey_lo gger.h file.
15 // The index of the different sections of a Payment Request. Used to record journey stats.
16 public static final int SECTION_CONTACT_INFO = 0;
17 public static final int SECTION_CREDIT_CARDS = 1;
18 public static final int SECTION_SHIPPING_ADDRESS = 2;
19 public static final int SECTION_MAX = 3;
20
21 // For the CanMakePayment histograms.
22 public static final int CAN_MAKE_PAYMENT_USED = 0;
23 public static final int CAN_MAKE_PAYMENT_NOT_USED = 1;
24 public static final int CAN_MAKE_PAYMENT_USE_MAX = 2;
25
26 // Used to log different parameters' effect on whether the transaction was c ompleted.
27 public static final int COMPLETION_STATUS_COMPLETED = 0;
28 public static final int COMPLETION_STATUS_ABORTED = 1;
29 public static final int COMPLETION_STATUS_MAX = 2;
30
31 // Used to mesure the impact of the CanMakePayment return value on whether t he Payment Request
32 // is shown to the user.
33 public static final int CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW = 0 ;
34 public static final int CMP_SHOW_DID_SHOW = 1 << 0;
35 public static final int CMP_SHOW_COULD_MAKE_PAYMENT = 1 << 1;
36 public static final int CMP_SHOW_MAX = 4;
37
38 // The minimum expected value of CustomCountHistograms is always set to 1. I t is still possible
39 // to log the value 0 to that type of histogram.
40 private static final int MIN_EXPECTED_SAMPLE = 1;
41 private static final int MAX_EXPECTED_SAMPLE = 49;
42 private static final int NUMBER_BUCKETS = 50;
43
44 /**
45 * Pointer to the native implementation.
46 */
47 private long mJourneyLoggerAndroid;
48
49 public JourneyLogger() {
50 // Note that this pointer could leak the native object. The called must call destroy() to
51 // ensure that the native object is destroyed.
52 mJourneyLoggerAndroid = nativeInitJourneyLoggerAndroid();
53 }
54
55 /** Will destroy the native object. This class shouldn't be used afterwards. */
56 public void destroy() {
57 if (mJourneyLoggerAndroid != 0) {
58 nativeDestroy(mJourneyLoggerAndroid);
59 mJourneyLoggerAndroid = 0;
60 }
61 }
62
63 /**
64 * Sets the number of suggestions shown for the specified section.
65 *
66 * @param section The section for which to log.
67 * @param number The number of suggestions.
68 */
69 public void setNumberOfSuggestionsShown(int section, int number) {
70 assert section < SECTION_MAX;
71 nativeSetNumberOfSuggestionsShown(mJourneyLoggerAndroid, section, number );
72 }
73
74 /**
75 * Increments the number of selection changes for the specified section.
76 *
77 * @param section The section for which to log.
78 */
79 public void incrementSelectionChanges(int section) {
80 assert section < SECTION_MAX;
81 nativeIncrementSelectionChanges(mJourneyLoggerAndroid, section);
82 }
83
84 /**
85 * Increments the number of selection edits for the specified section.
86 *
87 * @param section The section for which to log.
88 */
89 public void incrementSelectionEdits(int section) {
90 assert section < SECTION_MAX;
91 nativeIncrementSelectionEdits(mJourneyLoggerAndroid, section);
92 }
93
94 /**
95 * Increments the number of selection adds for the specified section.
96 *
97 * @param section The section for which to log.
98 */
99 public void incrementSelectionAdds(int section) {
100 assert section < SECTION_MAX;
101 nativeIncrementSelectionAdds(mJourneyLoggerAndroid, section);
102 }
103
104 /**
105 * Records the fact that the merchant called CanMakePayment and records it's return value.
106 *
107 * @param value The return value of the CanMakePayment call.
108 */
109 public void setCanMakePaymentValue(boolean value) {
110 nativeSetCanMakePaymentValue(mJourneyLoggerAndroid, value);
111 }
112
113 /**
114 * Records the fact that the Payment Request was shown to the user.
115 */
116 public void setShowCalled() {
117 nativeSetShowCalled(mJourneyLoggerAndroid);
118 }
119
120 /*
121 * Records the histograms for all the sections that were requested by the me rchant and for the
122 * usage of the CanMakePayment method and its effect on the transaction. Thi s method should be
123 * called when the payment request has either been completed or aborted.
124 *
125 * @param submissionType A string indicating the way the payment request was concluded.
126 */
127 public void recordJourneyStatsHistograms(String submissionType) {
128 nativeRecordJourneyStatsHistograms(mJourneyLoggerAndroid, submissionType );
129 }
130
131 private native long nativeInitJourneyLoggerAndroid();
132 private native void nativeDestroy(long nativeJourneyLoggerAndroid);
133 private native void nativeSetNumberOfSuggestionsShown(
134 long nativeJourneyLoggerAndroid, int section, int number);
135 private native void nativeIncrementSelectionChanges(
136 long nativeJourneyLoggerAndroid, int section);
137 private native void nativeIncrementSelectionEdits(long nativeJourneyLoggerAn droid, int section);
138 private native void nativeIncrementSelectionAdds(long nativeJourneyLoggerAnd roid, int section);
139 private native void nativeSetCanMakePaymentValue(
140 long nativeJourneyLoggerAndroid, boolean value);
141 private native void nativeSetShowCalled(long nativeJourneyLoggerAndroid);
142 private native void nativeRecordJourneyStatsHistograms(
143 long nativeJourneyLoggerAndroid, String submissionType);
144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698