Commit 49f84636 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Photo Picker: Re-enable a couple of UMAs for photo decoding

and close requests that fail properly.

Bug: 895776, 656015
Change-Id: I90b7d323071a38e84275b4f7ad5c96fa97a72e7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1690876
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675595}
parent 38ebcf25
...@@ -294,23 +294,28 @@ public class DecoderServiceHost ...@@ -294,23 +294,28 @@ public class DecoderServiceHost
// make sure the code runs on the UI thread, since further down the callchain the code will // make sure the code runs on the UI thread, since further down the callchain the code will
// end up creating UI objects. // end up creating UI objects.
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
String filePath = "";
List<Bitmap> bitmaps = null;
String videoDuration = null;
long decodeTime = -1;
try { try {
// Read the reply back from the service. // Read the reply back from the service.
String filePath = payload.getString(DecoderService.KEY_FILE_PATH); filePath = payload.getString(DecoderService.KEY_FILE_PATH);
Boolean success = payload.getBoolean(DecoderService.KEY_SUCCESS); Boolean success = payload.getBoolean(DecoderService.KEY_SUCCESS);
Bitmap bitmap = success Bitmap bitmap = success
? (Bitmap) payload.getParcelable(DecoderService.KEY_IMAGE_BITMAP) ? (Bitmap) payload.getParcelable(DecoderService.KEY_IMAGE_BITMAP)
: null; : null;
long decodeTime = payload.getLong(DecoderService.KEY_DECODE_TIME); decodeTime = payload.getLong(DecoderService.KEY_DECODE_TIME);
mSuccessfulDecodes++; mSuccessfulDecodes++;
List<Bitmap> bitmaps = new ArrayList<>(1); bitmaps = new ArrayList<>(1);
bitmaps.add(bitmap); bitmaps.add(bitmap);
closeRequest(
filePath, /*isVideo=*/false, bitmaps, /*videoDuration=*/null, decodeTime);
} catch (RuntimeException e) { } catch (RuntimeException e) {
mFailedDecodesRuntime++; mFailedDecodesRuntime++;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
mFailedDecodesMemory++; mFailedDecodesMemory++;
} finally {
closeRequest(
filePath, /*isVideo=*/false, bitmaps, /*videoDuration=*/null, decodeTime);
} }
}); });
} }
...@@ -320,6 +325,7 @@ public class DecoderServiceHost ...@@ -320,6 +325,7 @@ public class DecoderServiceHost
* decoding process back to the client, and takes care of house-keeping chores regarding * decoding process back to the client, and takes care of house-keeping chores regarding
* the request queue). * the request queue).
* @param filePath The path to the image that was just decoded. * @param filePath The path to the image that was just decoded.
* @param isVideo True if the request was for video decoding.
* @param bitmaps The resulting decoded bitmaps, or null if decoding fails. * @param bitmaps The resulting decoded bitmaps, or null if decoding fails.
* @param decodeTime The length of time it took to decode the bitmap. * @param decodeTime The length of time it took to decode the bitmap.
*/ */
...@@ -334,7 +340,7 @@ public class DecoderServiceHost ...@@ -334,7 +340,7 @@ public class DecoderServiceHost
params.mCallback.imagesDecodedCallback(filePath, isVideo, bitmaps, videoDuration); params.mCallback.imagesDecodedCallback(filePath, isVideo, bitmaps, videoDuration);
// TODO(finnur): Add UMA for videos. // TODO(finnur): Add UMA for videos.
if (isVideo && decodeTime != -1 && bitmaps.get(0) != null) { if (!isVideo && decodeTime != -1 && bitmaps != null && bitmaps.get(0) != null) {
RecordHistogram.recordTimesHistogram( RecordHistogram.recordTimesHistogram(
"Android.PhotoPicker.ImageDecodeTime", decodeTime); "Android.PhotoPicker.ImageDecodeTime", decodeTime);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment