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

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

Issue 2915863002: Photo Picker dialog: Add UMA statistics. (Closed)
Patch Set: Address feedback from Theresa Created 3 years, 7 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/PickerCategoryView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java
index 24bdc226e65f2ba107dbd0408fd2e8f48bb92f06..79c81fa6cb4655501ee0dee7f55ae9934d6a97b9 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java
@@ -19,7 +19,9 @@ import android.widget.Button;
import android.widget.RelativeLayout;
import org.chromium.base.VisibleForTesting;
+import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
import org.chromium.ui.PhotoPickerListener;
@@ -35,7 +37,14 @@ import java.util.List;
public class PickerCategoryView extends RelativeLayout
implements FileEnumWorkerTask.FilesEnumeratedCallback, RecyclerView.RecyclerListener,
DecoderServiceHost.ServiceReadyCallback, View.OnClickListener {
- private static final int KILOBYTE = 1024;
+ // Note: these values must match the PhotoPickerDialogAction enum values in histograms.xml.
+ // Only add new values at the end, right before ACTIONS. We depend on these specific values in
+ // UMA histograms.
+ private static final int ACTION_CANCEL = 0;
+ private static final int ACTION_PHOTO_PICKED = 1;
+ private static final int ACTION_NEW_PHOTO = 2;
+ private static final int ACTION_BROWSE = 3;
+ private static final int ACTION_BOUNDARY = 4;
// The dialog that owns us.
private PhotoPickerDialog mDialog;
@@ -145,7 +154,8 @@ public class PickerCategoryView extends RelativeLayout
mSpacingDecoration = new GridSpacingItemDecoration(mColumns, mPadding);
mRecyclerView.addItemDecoration(mSpacingDecoration);
- final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / KILOBYTE);
+ final int maxMemory =
+ (int) (Runtime.getRuntime().maxMemory() / DownloadUtils.BYTES_PER_KILOBYTE);
final int cacheSizeLarge = maxMemory / 2; // 1/2 of the available memory.
final int cacheSizeSmall = maxMemory / 8; // 1/8th of the available memory.
mLowResBitmaps = new LruCache<String, Bitmap>(cacheSizeSmall);
@@ -195,6 +205,7 @@ public class PickerCategoryView extends RelativeLayout
mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
+ recordFinalUmaStats(ACTION_CANCEL);
mListener.onPickerUserAction(PhotoPickerListener.Action.CANCEL, null);
}
});
@@ -232,8 +243,10 @@ public class PickerCategoryView extends RelativeLayout
@Override
public void onClick(View view) {
if (view.getId() == R.id.done) {
+ recordFinalUmaStats(ACTION_PHOTO_PICKED);
notifyPhotosSelected();
} else {
+ recordFinalUmaStats(ACTION_CANCEL);
mListener.onPickerUserAction(PhotoPickerListener.Action.CANCEL, null);
}
@@ -284,6 +297,7 @@ public class PickerCategoryView extends RelativeLayout
* Notifies the listener that the user selected to launch the gallery.
*/
public void showGallery() {
+ recordFinalUmaStats(ACTION_BROWSE);
mListener.onPickerUserAction(PhotoPickerListener.Action.LAUNCH_GALLERY, null);
}
@@ -291,6 +305,7 @@ public class PickerCategoryView extends RelativeLayout
* Notifies the listener that the user selected to launch the camera intent.
*/
public void showCamera() {
+ recordFinalUmaStats(ACTION_NEW_PHOTO);
mListener.onPickerUserAction(PhotoPickerListener.Action.LAUNCH_CAMERA, null);
}
@@ -383,6 +398,19 @@ public class PickerCategoryView extends RelativeLayout
}
}
+ /**
+ * Record UMA statistics (what action was taken in the dialog and other performance stats.
Theresa 2017/06/01 15:58:04 nit: the ( parenthesis is missing a closing parent
+ * @param action The action the user took in the dialog.
+ */
+ private void recordFinalUmaStats(int action) {
+ RecordHistogram.recordEnumeratedHistogram(
+ "Android.PhotoPicker.DialogAction", action, ACTION_BOUNDARY);
+ RecordHistogram.recordCountHistogram(
+ "Android.PhotoPicker.DecodeRequests", mPickerAdapter.getDecodeRequestCount());
+ RecordHistogram.recordCountHistogram(
+ "Android.PhotoPicker.CacheHits", mPickerAdapter.getCacheHitCount());
+ }
+
/** Sets a list of files to use as data for the dialog. For testing use only. */
@VisibleForTesting
public static void setTestFiles(List<PickerBitmap> testFiles) {

Powered by Google App Engine
This is Rietveld 408576698