Commit 2051aedb authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

[CIF] Consolidate UMA client names into CachedImageFetcher

Change-Id: Ie28c6659ff11b1f2137ffc53323b4569d5283965
Reviewed-on: https://chromium-review.googlesource.com/c/1487197Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635630}
parent 7c2651c6
...@@ -35,7 +35,6 @@ import java.util.List; ...@@ -35,7 +35,6 @@ import java.util.List;
* Provides image loading and other host-specific asset fetches for Feed. * Provides image loading and other host-specific asset fetches for Feed.
*/ */
public class FeedImageLoader implements ImageLoaderApi { public class FeedImageLoader implements ImageLoaderApi {
private static final String CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME = "Feed";
private static final String ASSET_PREFIX = "asset://"; private static final String ASSET_PREFIX = "asset://";
private static final String OVERLAY_IMAGE_PREFIX = "overlay-image://"; private static final String OVERLAY_IMAGE_PREFIX = "overlay-image://";
private static final String OVERLAY_IMAGE_URL_PARAM = "url"; private static final String OVERLAY_IMAGE_URL_PARAM = "url";
...@@ -170,7 +169,7 @@ public class FeedImageLoader implements ImageLoaderApi { ...@@ -170,7 +169,7 @@ public class FeedImageLoader implements ImageLoaderApi {
@VisibleForTesting @VisibleForTesting
protected void fetchImage(String url, int width, int height, Callback<Bitmap> callback) { protected void fetchImage(String url, int width, int height, Callback<Bitmap> callback) {
mCachedImageFetcher.fetchImage( mCachedImageFetcher.fetchImage(
url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, width, height, callback); url, CachedImageFetcher.FEED_UMA_CLIENT_NAME, width, height, callback);
} }
@VisibleForTesting @VisibleForTesting
......
...@@ -48,8 +48,6 @@ import java.util.Set; ...@@ -48,8 +48,6 @@ import java.util.Set;
class AssistantDetailsViewBinder class AssistantDetailsViewBinder
implements PropertyModelChangeProcessor.ViewBinder<AssistantDetailsModel, implements PropertyModelChangeProcessor.ViewBinder<AssistantDetailsModel,
AssistantDetailsViewBinder.ViewHolder, PropertyKey> { AssistantDetailsViewBinder.ViewHolder, PropertyKey> {
private static final String CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME = "AssistantDetails";
private static final int IMAGE_BORDER_RADIUS = 4; private static final int IMAGE_BORDER_RADIUS = 4;
private static final int PULSING_DURATION_MS = 1_000; private static final int PULSING_DURATION_MS = 1_000;
private static final String DETAILS_TIME_FORMAT = "H:mma"; private static final String DETAILS_TIME_FORMAT = "H:mma";
...@@ -144,8 +142,8 @@ class AssistantDetailsViewBinder ...@@ -144,8 +142,8 @@ class AssistantDetailsViewBinder
// Download image and then set it in the model. // Download image and then set it in the model.
if (!details.getImageUrl().isEmpty()) { if (!details.getImageUrl().isEmpty()) {
CachedImageFetcher.getInstance().fetchImage( CachedImageFetcher.getInstance().fetchImage(details.getImageUrl(),
details.getImageUrl(), CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, image -> { CachedImageFetcher.ASSISTANT_DETAILS_UMA_CLIENT_NAME, image -> {
if (image != null) { if (image != null) {
viewHolder.mImageView.setImageDrawable(getRoundedImage(image)); viewHolder.mImageView.setImageDrawable(getRoundedImage(image));
} }
......
...@@ -14,6 +14,11 @@ import org.chromium.base.ThreadUtils; ...@@ -14,6 +14,11 @@ import org.chromium.base.ThreadUtils;
* will need to be changed when supporting multi-profile. * will need to be changed when supporting multi-profile.
*/ */
public interface CachedImageFetcher { public interface CachedImageFetcher {
// All UMA client names collected here to prevent duplicates.
public static final String ASSISTANT_DETAILS_UMA_CLIENT_NAME = "AssistantDetails";
public static final String CONTEXTUAL_SUGGESTIONS_UMA_CLIENT_NAME = "ContextualSuggestions";
public static final String FEED_UMA_CLIENT_NAME = "Feed";
static CachedImageFetcher getInstance() { static CachedImageFetcher getInstance() {
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
return CachedImageFetcherImpl.getInstance(); return CachedImageFetcherImpl.getInstance();
......
...@@ -22,8 +22,6 @@ import org.chromium.content_public.browser.WebContents; ...@@ -22,8 +22,6 @@ import org.chromium.content_public.browser.WebContents;
*/ */
class ContextualSuggestionsSourceImpl class ContextualSuggestionsSourceImpl
extends EmptySuggestionsSource implements ContextualSuggestionsSource { extends EmptySuggestionsSource implements ContextualSuggestionsSource {
private static final String CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME = "ContextualSuggestions";
private ContextualSuggestionsBridge mBridge; private ContextualSuggestionsBridge mBridge;
private CachedImageFetcher mCachedImageFetcher; private CachedImageFetcher mCachedImageFetcher;
...@@ -46,7 +44,8 @@ class ContextualSuggestionsSourceImpl ...@@ -46,7 +44,8 @@ class ContextualSuggestionsSourceImpl
@Override @Override
public void fetchSuggestionImage(SnippetArticle suggestion, Callback<Bitmap> callback) { public void fetchSuggestionImage(SnippetArticle suggestion, Callback<Bitmap> callback) {
String url = mBridge.getImageUrl(suggestion); String url = mBridge.getImageUrl(suggestion);
mCachedImageFetcher.fetchImage(url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, callback); mCachedImageFetcher.fetchImage(
url, CachedImageFetcher.CONTEXTUAL_SUGGESTIONS_UMA_CLIENT_NAME, callback);
} }
@Override @Override
...@@ -58,7 +57,8 @@ class ContextualSuggestionsSourceImpl ...@@ -58,7 +57,8 @@ class ContextualSuggestionsSourceImpl
return; return;
} }
mCachedImageFetcher.fetchImage(url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, callback); mCachedImageFetcher.fetchImage(
url, CachedImageFetcher.CONTEXTUAL_SUGGESTIONS_UMA_CLIENT_NAME, callback);
} }
@Override @Override
...@@ -70,8 +70,9 @@ class ContextualSuggestionsSourceImpl ...@@ -70,8 +70,9 @@ class ContextualSuggestionsSourceImpl
return; return;
} }
mCachedImageFetcher.fetchImage( mCachedImageFetcher.fetchImage(url,
url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, desiredSizePx, desiredSizePx, callback); CachedImageFetcher.CONTEXTUAL_SUGGESTIONS_UMA_CLIENT_NAME, desiredSizePx,
desiredSizePx, callback);
} }
@Override @Override
......
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