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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchUma.java

Issue 2798123002: Remove crushed sprite resource and layer (Closed)
Patch Set: Rebase and fix my nits Created 3 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.util.Pair; 7 import android.util.Pair;
8 8
9 import org.chromium.base.metrics.RecordHistogram; 9 import org.chromium.base.metrics.RecordHistogram;
10 import org.chromium.base.metrics.RecordUserAction; 10 import org.chromium.base.metrics.RecordUserAction;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Constants used to log UMA "enum" histograms with details about whether se arch results 164 // Constants used to log UMA "enum" histograms with details about whether se arch results
165 // were seen, and what the original triggering gesture was. 165 // were seen, and what the original triggering gesture was.
166 private static final int PROMO_ENABLED_FROM_TAP = 0; 166 private static final int PROMO_ENABLED_FROM_TAP = 0;
167 private static final int PROMO_DISABLED_FROM_TAP = 1; 167 private static final int PROMO_DISABLED_FROM_TAP = 1;
168 private static final int PROMO_UNDECIDED_FROM_TAP = 2; 168 private static final int PROMO_UNDECIDED_FROM_TAP = 2;
169 private static final int PROMO_ENABLED_FROM_LONG_PRESS = 3; 169 private static final int PROMO_ENABLED_FROM_LONG_PRESS = 3;
170 private static final int PROMO_DISABLED_FROM_LONG_PRESS = 4; 170 private static final int PROMO_DISABLED_FROM_LONG_PRESS = 4;
171 private static final int PROMO_UNDECIDED_FROM_LONG_PRESS = 5; 171 private static final int PROMO_UNDECIDED_FROM_LONG_PRESS = 5;
172 private static final int PROMO_BY_GESTURE_BOUNDARY = 6; 172 private static final int PROMO_BY_GESTURE_BOUNDARY = 6;
173 173
174 // Constants used to log UMA "enum" histograms with summary counts for SERP loading times.
175 private static final int PREFETCHED_PARIALLY_LOADED = 0;
176 private static final int PREFETCHED_FULLY_LOADED = 1;
177 private static final int NOT_PREFETCHED = 2;
178 private static final int PREFETCH_BOUNDARY = 3;
179
180 // Constants used to log UMA "enum" histograms for HTTP / HTTPS. 174 // Constants used to log UMA "enum" histograms for HTTP / HTTPS.
181 private static final int PROTOCOL_IS_HTTP = 0; 175 private static final int PROTOCOL_IS_HTTP = 0;
182 private static final int PROTOCOL_NOT_HTTP = 1; 176 private static final int PROTOCOL_NOT_HTTP = 1;
183 private static final int PROTOCOL_BOUNDARY = 2; 177 private static final int PROTOCOL_BOUNDARY = 2;
184 178
185 // Constants used to log UMA "enum" histograms for single / multi-word. 179 // Constants used to log UMA "enum" histograms for single / multi-word.
186 private static final int RESOLVED_SINGLE_WORD = 0; 180 private static final int RESOLVED_SINGLE_WORD = 0;
187 private static final int RESOLVED_MULTI_WORD = 1; 181 private static final int RESOLVED_MULTI_WORD = 1;
188 private static final int RESOLVED_BOUNDARY = 2; 182 private static final int RESOLVED_BOUNDARY = 2;
189 183
190 // Constants used to log UMA "enum" histograms for partially / fully loaded.
191 private static final int PARTIALLY_LOADED = 0;
192 private static final int FULLY_LOADED = 1;
193 private static final int LOADED_BOUNDARY = 2;
194
195 // Constants used to log UMA "enum" histograms for triggering the Translate Onebox. 184 // Constants used to log UMA "enum" histograms for triggering the Translate Onebox.
196 private static final int DID_FORCE_TRANSLATE = 0; 185 private static final int DID_FORCE_TRANSLATE = 0;
197 private static final int WOULD_FORCE_TRANSLATE = 1; 186 private static final int WOULD_FORCE_TRANSLATE = 1;
198 private static final int FORCE_TRANSLATE_BOUNDARY = 2; 187 private static final int FORCE_TRANSLATE_BOUNDARY = 2;
199 188
200 // Constants used to log UMA "enum" histograms with details about whether th e search
201 // provider sprite icon was animated, whether search results were seen and t he triggering
202 // gesture. All new values should be inserted right before ICON_SPRITE_BOUND ARY.
203 private static final int ICON_SPRITE_ANIMATED_RESULTS_SEEN_FROM_TAP = 0;
204 private static final int ICON_SPRITE_ANIMATED_RESULTS_NOT_SEEN_FROM_TAP = 1;
205 private static final int ICON_SPRITE_NOT_ANIMATED_RESULTS_SEEN_FROM_TAP = 2;
206 private static final int ICON_SPRITE_NOT_ANIMATED_RESULTS_NOT_SEEN_FROM_TAP = 3;
207 private static final int ICON_SPRITE_ANIMATED_RESULTS_SEEN_FROM_LONG_PRESS = 4;
208 private static final int ICON_SPRITE_ANIMATED_RESULTS_NOT_SEEN_FROM_LONG_PRE SS = 5;
209 private static final int ICON_SPRITE_NOT_ANIMATED_RESULTS_SEEN_FROM_LONG_PRE SS = 6;
210 private static final int ICON_SPRITE_NOT_ANIMATED_RESULTS_NOT_SEEN_FROM_LONG _PRESS = 7;
211 private static final int ICON_SPRITE_BOUNDARY = 8;
212
213 // Constants used to log UMA "enum" histograms for Quick Answers. 189 // Constants used to log UMA "enum" histograms for Quick Answers.
214 private static final int QUICK_ANSWER_ACTIVATED_WAS_AN_ANSWER_SEEN = 0; 190 private static final int QUICK_ANSWER_ACTIVATED_WAS_AN_ANSWER_SEEN = 0;
215 private static final int QUICK_ANSWER_ACTIVATED_WAS_AN_ANSWER_NOT_SEEN = 1; 191 private static final int QUICK_ANSWER_ACTIVATED_WAS_AN_ANSWER_NOT_SEEN = 1;
216 private static final int QUICK_ANSWER_ACTIVATED_NOT_AN_ANSWER_SEEN = 2; 192 private static final int QUICK_ANSWER_ACTIVATED_NOT_AN_ANSWER_SEEN = 2;
217 private static final int QUICK_ANSWER_ACTIVATED_NOT_AN_ANSWER_NOT_SEEN = 3; 193 private static final int QUICK_ANSWER_ACTIVATED_NOT_AN_ANSWER_NOT_SEEN = 3;
218 private static final int QUICK_ANSWER_NOT_ACTIVATED_SEEN = 4; 194 private static final int QUICK_ANSWER_NOT_ACTIVATED_SEEN = 4;
219 private static final int QUICK_ANSWER_NOT_ACTIVATED_NOT_SEEN = 5; 195 private static final int QUICK_ANSWER_NOT_ACTIVATED_NOT_SEEN = 5;
220 private static final int QUICK_ANSWER_SEEN_BOUNDARY = 6; 196 private static final int QUICK_ANSWER_SEEN_BOUNDARY = 6;
221 197
222 // Constants for "Bar Overlap" with triggering gesture, and whether the resu lts were seen. 198 // Constants for "Bar Overlap" with triggering gesture, and whether the resu lts were seen.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 StateChangeKey other = (StateChangeKey) obj; 237 StateChangeKey other = (StateChangeKey) obj;
262 return mState.equals(other.mState) && mReason.equals(other.mReason); 238 return mState.equals(other.mState) && mReason.equals(other.mReason);
263 } 239 }
264 240
265 @Override 241 @Override
266 public int hashCode() { 242 public int hashCode() {
267 return mHashCode; 243 return mHashCode;
268 } 244 }
269 } 245 }
270 246
271 static class IconSpriteAnimationKey {
272 final boolean mWasIconSpriteAnimated;
273 final boolean mWasPanelSeen;
274 final boolean mWasTap;
275 final int mHashCode;
276
277 IconSpriteAnimationKey(boolean wasIconSpriteAnimated, boolean wasPanelSe en,
278 boolean wasTap) {
279 mWasIconSpriteAnimated = wasIconSpriteAnimated;
280 mWasPanelSeen = wasPanelSeen;
281 mWasTap = wasTap;
282
283 // HashCode logic generated by Eclipse.
284 final int prime = 31;
285 int result = 1;
286 result = prime * result + (mWasIconSpriteAnimated ? 1231 : 1237);
287 result = prime * result + (mWasPanelSeen ? 1231 : 1237);
288 result = prime * result + (mWasTap ? 1231 : 1237);
289 mHashCode = result;
290 }
291
292 @Override
293 public boolean equals(Object obj) {
294 if (!(obj instanceof IconSpriteAnimationKey)) {
295 return false;
296 }
297 if (obj == this) {
298 return true;
299 }
300 IconSpriteAnimationKey other = (IconSpriteAnimationKey) obj;
301 return other.mWasIconSpriteAnimated == mWasIconSpriteAnimated
302 && other.mWasPanelSeen == mWasPanelSeen
303 && other.mWasTap == mWasTap;
304 }
305
306 @Override
307 public int hashCode() {
308 return mHashCode;
309 }
310 }
311
312 // TODO(donnd): switch from using Maps to some method that does not require creation of a key. 247 // TODO(donnd): switch from using Maps to some method that does not require creation of a key.
313 248
314 // Entry code map: first entry into CLOSED. 249 // Entry code map: first entry into CLOSED.
315 private static final Map<StateChangeKey, Integer> ENTER_CLOSED_STATE_CHANGE_ CODES; 250 private static final Map<StateChangeKey, Integer> ENTER_CLOSED_STATE_CHANGE_ CODES;
316 static { 251 static {
317 Map<StateChangeKey, Integer> codes = new HashMap<StateChangeKey, Integer >(); 252 Map<StateChangeKey, Integer> codes = new HashMap<StateChangeKey, Integer >();
318 codes.put(new StateChangeKey(PanelState.PEEKED, StateChangeReason.BACK_P RESS), 253 codes.put(new StateChangeKey(PanelState.PEEKED, StateChangeReason.BACK_P RESS),
319 ENTER_CLOSED_FROM_PEEKED_BACK_PRESS); 254 ENTER_CLOSED_FROM_PEEKED_BACK_PRESS);
320 codes.put(new StateChangeKey(PanelState.PEEKED, StateChangeReason.BASE_P AGE_SCROLL), 255 codes.put(new StateChangeKey(PanelState.PEEKED, StateChangeReason.BASE_P AGE_SCROLL),
321 ENTER_CLOSED_FROM_PEEKED_BASE_PAGE_SCROLL); 256 ENTER_CLOSED_FROM_PEEKED_BASE_PAGE_SCROLL);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 PROMO_UNDECIDED_FROM_TAP); 449 PROMO_UNDECIDED_FROM_TAP);
515 codes.put(new Pair<Integer, Boolean>(PREFERENCE_ENABLED, LONG_PRESS), 450 codes.put(new Pair<Integer, Boolean>(PREFERENCE_ENABLED, LONG_PRESS),
516 PROMO_ENABLED_FROM_LONG_PRESS); 451 PROMO_ENABLED_FROM_LONG_PRESS);
517 codes.put(new Pair<Integer, Boolean>(PREFERENCE_DISABLED, LONG_PRESS), 452 codes.put(new Pair<Integer, Boolean>(PREFERENCE_DISABLED, LONG_PRESS),
518 PROMO_DISABLED_FROM_LONG_PRESS); 453 PROMO_DISABLED_FROM_LONG_PRESS);
519 codes.put(new Pair<Integer, Boolean>(PREFERENCE_UNINITIALIZED, LONG_PRES S), 454 codes.put(new Pair<Integer, Boolean>(PREFERENCE_UNINITIALIZED, LONG_PRES S),
520 PROMO_UNDECIDED_FROM_LONG_PRESS); 455 PROMO_UNDECIDED_FROM_LONG_PRESS);
521 PROMO_BY_GESTURE_CODES = Collections.unmodifiableMap(codes); 456 PROMO_BY_GESTURE_CODES = Collections.unmodifiableMap(codes);
522 } 457 }
523 458
524 // Icon sprite animation code mapped: logged when ending a contextual search .
525 private static final Map<IconSpriteAnimationKey, Integer> ICON_SPRITE_ANIMAT ION_CODES;
526 static {
527 Map<IconSpriteAnimationKey, Integer> codes = new HashMap<IconSpriteAnima tionKey, Integer>();
528 codes.put(new IconSpriteAnimationKey(true, true, true),
529 ICON_SPRITE_ANIMATED_RESULTS_SEEN_FROM_TAP);
530 codes.put(new IconSpriteAnimationKey(true, false, true),
531 ICON_SPRITE_ANIMATED_RESULTS_NOT_SEEN_FROM_TAP);
532 codes.put(new IconSpriteAnimationKey(false, true, true),
533 ICON_SPRITE_NOT_ANIMATED_RESULTS_SEEN_FROM_TAP);
534 codes.put(new IconSpriteAnimationKey(false, false, true),
535 ICON_SPRITE_NOT_ANIMATED_RESULTS_NOT_SEEN_FROM_TAP);
536 codes.put(new IconSpriteAnimationKey(true, true, false),
537 ICON_SPRITE_ANIMATED_RESULTS_SEEN_FROM_LONG_PRESS);
538 codes.put(new IconSpriteAnimationKey(true, false, false),
539 ICON_SPRITE_ANIMATED_RESULTS_NOT_SEEN_FROM_LONG_PRESS);
540 codes.put(new IconSpriteAnimationKey(false, true, false),
541 ICON_SPRITE_NOT_ANIMATED_RESULTS_SEEN_FROM_LONG_PRESS);
542 codes.put(new IconSpriteAnimationKey(false, false, false),
543 ICON_SPRITE_NOT_ANIMATED_RESULTS_NOT_SEEN_FROM_LONG_PRESS);
544 ICON_SPRITE_ANIMATION_CODES = Collections.unmodifiableMap(codes);
545 }
546
547 /** 459 /**
548 * Logs the state of the Contextual Search preference. This function should be called if the 460 * Logs the state of the Contextual Search preference. This function should be called if the
549 * Contextual Search feature is active, and will track the different prefere nce settings 461 * Contextual Search feature is active, and will track the different prefere nce settings
550 * (disabled, enabled or uninitialized). Calling more than once is fine. 462 * (disabled, enabled or uninitialized). Calling more than once is fine.
551 */ 463 */
552 public static void logPreferenceState() { 464 public static void logPreferenceState() {
553 RecordHistogram.recordEnumeratedHistogram("Search.ContextualSearchPrefer enceState", 465 RecordHistogram.recordEnumeratedHistogram("Search.ContextualSearchPrefer enceState",
554 getPreferenceValue(), PREFERENCE_HISTOGRAM_BOUNDARY); 466 getPreferenceValue(), PREFERENCE_HISTOGRAM_BOUNDARY);
555 } 467 }
556 468
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 : RESULTS_NOT_SEEN_SUPPRESSION_HEURSTIC_NOT_SATISFIED; 857 : RESULTS_NOT_SEEN_SUPPRESSION_HEURSTIC_NOT_SATISFIED;
946 } 858 }
947 859
948 RecordHistogram.recordEnumeratedHistogram( 860 RecordHistogram.recordEnumeratedHistogram(
949 "Search.ContextualSearchTapSuppressionSeen.AnyHeuristicSatisfied ", 861 "Search.ContextualSearchTapSuppressionSeen.AnyHeuristicSatisfied ",
950 code, 862 code,
951 RESULTS_SEEN_SUPPRESSION_BOUNDARY); 863 RESULTS_SEEN_SUPPRESSION_BOUNDARY);
952 } 864 }
953 865
954 /** 866 /**
955 * Logs whether search results were seen, whether the search provider icon s prite was animated
956 * when the panel first appeared, and the triggering gesture.
957 * @param wasIconSpriteAnimated Whether the search provider icon sprite was animated when the
958 * the panel first appeared.
959 * @param wasPanelSeen Whether the panel was seen.
960 * @param wasTap Whether the gesture that originally caused the panel to sho w was a Tap.
961 */
962 public static void logIconSpriteAnimated(boolean wasIconSpriteAnimated, bool ean wasPanelSeen,
963 boolean wasTap) {
964 RecordHistogram.recordEnumeratedHistogram("Search.ContextualSearchIconSp riteAnimated",
965 ICON_SPRITE_ANIMATION_CODES.get(new IconSpriteAnimationKey(wasIc onSpriteAnimated,
966 wasPanelSeen, wasTap)),
967 ICON_SPRITE_BOUNDARY);
968 }
969
970 /**
971 * Logs whether a selection is valid. 867 * Logs whether a selection is valid.
972 * @param isSelectionValid Whether the selection is valid. 868 * @param isSelectionValid Whether the selection is valid.
973 */ 869 */
974 public static void logSelectionIsValid(boolean isSelectionValid) { 870 public static void logSelectionIsValid(boolean isSelectionValid) {
975 RecordHistogram.recordEnumeratedHistogram("Search.ContextualSearchSelect ionValid", 871 RecordHistogram.recordEnumeratedHistogram("Search.ContextualSearchSelect ionValid",
976 isSelectionValid ? SELECTION_VALID : SELECTION_INVALID, SELECTIO N_BOUNDARY); 872 isSelectionValid ? SELECTION_VALID : SELECTION_INVALID, SELECTIO N_BOUNDARY);
977 } 873 }
978 874
979 /** 875 /**
980 * Logs whether a normal priority search request failed. 876 * Logs whether a normal priority search request failed.
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 return "Event"; 1356 return "Event";
1461 case QuickActionCategory.PHONE: 1357 case QuickActionCategory.PHONE:
1462 return "Phone"; 1358 return "Phone";
1463 case QuickActionCategory.WEBSITE: 1359 case QuickActionCategory.WEBSITE:
1464 return "Website"; 1360 return "Website";
1465 default: 1361 default:
1466 return "None"; 1362 return "None";
1467 } 1363 }
1468 } 1364 }
1469 } 1365 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698