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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerAdapter.java

Issue 2915863002: Photo Picker dialog: Add UMA statistics. (Closed)
Patch Set: Address feedback from Mark Created 3 years, 6 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/photo_picker/PickerAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerAdapter.java
index c2c43e705d8b377054c2cb3ec45d15f843fd9643..c1548b15a0aa71b44a8ea18c195ebbb08f5f3a76 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerAdapter.java
@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.photo_picker;
+import android.support.annotation.IntDef;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
@@ -12,13 +13,32 @@ import android.view.ViewGroup;
import org.chromium.chrome.R;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* A data adapter for the Photo Picker.
*/
public class PickerAdapter extends Adapter<ViewHolder> {
+ // The possible types of actions required during decoding.
+ @IntDef({NO_ACTION, FROM_CACHE, DECODE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface DecodeActions {}
+ public static final int NO_ACTION = 0; // Gallery/Camera tile: No action.
+ public static final int FROM_CACHE = 1; // Image already decoded.
+ public static final int DECODE = 2; // Image needed to be decoded.
+
// The category view to use to show the images.
private PickerCategoryView mCategoryView;
+ // How many times the (high-res) cache was useful.
+ @DecodeActions
+ private int mCacheHits;
+
+ // How many times a decoding was requested.
+ @DecodeActions
+ private int mDecodeRequests;
+
/**
* The PickerAdapter constructor.
* @param categoryView The category view to use to show the images.
@@ -42,7 +62,12 @@ public class PickerAdapter extends Adapter<ViewHolder> {
public void onBindViewHolder(ViewHolder holder, int position) {
if (holder instanceof PickerBitmapViewHolder) {
PickerBitmapViewHolder myHolder = (PickerBitmapViewHolder) holder;
- myHolder.displayItem(mCategoryView, position);
+ int result = myHolder.displayItem(mCategoryView, position);
+ if (result == FROM_CACHE) {
+ mCacheHits++;
+ } else if (result == DECODE) {
+ mDecodeRequests++;
+ }
}
}
@@ -50,4 +75,14 @@ public class PickerAdapter extends Adapter<ViewHolder> {
public int getItemCount() {
return mCategoryView.getPickerBitmaps().size();
}
+
+ /** Returns the number of times the cache supplied a bitmap. */
+ public int getCacheHitCount() {
+ return mCacheHits;
+ }
+
+ /** Returns the number of decode requests (cache-misses). */
+ public int getDecodeRequestCount() {
+ return mDecodeRequests;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698