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;
* Provides image loading and other host-specific asset fetches for Feed.
*/
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 OVERLAY_IMAGE_PREFIX = "overlay-image://";
private static final String OVERLAY_IMAGE_URL_PARAM = "url";
......@@ -170,7 +169,7 @@ public class FeedImageLoader implements ImageLoaderApi {
@VisibleForTesting
protected void fetchImage(String url, int width, int height, Callback<Bitmap> callback) {
mCachedImageFetcher.fetchImage(
url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, width, height, callback);
url, CachedImageFetcher.FEED_UMA_CLIENT_NAME, width, height, callback);
}
@VisibleForTesting
......
......@@ -48,8 +48,6 @@ import java.util.Set;
class AssistantDetailsViewBinder
implements PropertyModelChangeProcessor.ViewBinder<AssistantDetailsModel,
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 PULSING_DURATION_MS = 1_000;
private static final String DETAILS_TIME_FORMAT = "H:mma";
......@@ -144,8 +142,8 @@ class AssistantDetailsViewBinder
// Download image and then set it in the model.
if (!details.getImageUrl().isEmpty()) {
CachedImageFetcher.getInstance().fetchImage(
details.getImageUrl(), CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, image -> {
CachedImageFetcher.getInstance().fetchImage(details.getImageUrl(),
CachedImageFetcher.ASSISTANT_DETAILS_UMA_CLIENT_NAME, image -> {
if (image != null) {
viewHolder.mImageView.setImageDrawable(getRoundedImage(image));
}
......
......@@ -14,6 +14,11 @@ import org.chromium.base.ThreadUtils;
* will need to be changed when supporting multi-profile.
*/
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() {
ThreadUtils.assertOnUiThread();
return CachedImageFetcherImpl.getInstance();
......
......@@ -22,8 +22,6 @@ import org.chromium.content_public.browser.WebContents;
*/
class ContextualSuggestionsSourceImpl
extends EmptySuggestionsSource implements ContextualSuggestionsSource {
private static final String CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME = "ContextualSuggestions";
private ContextualSuggestionsBridge mBridge;
private CachedImageFetcher mCachedImageFetcher;
......@@ -46,7 +44,8 @@ class ContextualSuggestionsSourceImpl
@Override
public void fetchSuggestionImage(SnippetArticle suggestion, Callback<Bitmap> callback) {
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
......@@ -58,7 +57,8 @@ class ContextualSuggestionsSourceImpl
return;
}
mCachedImageFetcher.fetchImage(url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, callback);
mCachedImageFetcher.fetchImage(
url, CachedImageFetcher.CONTEXTUAL_SUGGESTIONS_UMA_CLIENT_NAME, callback);
}
@Override
......@@ -70,8 +70,9 @@ class ContextualSuggestionsSourceImpl
return;
}
mCachedImageFetcher.fetchImage(
url, CACHED_IMAGE_FETCHER_UMA_CLIENT_NAME, desiredSizePx, desiredSizePx, callback);
mCachedImageFetcher.fetchImage(url,
CachedImageFetcher.CONTEXTUAL_SUGGESTIONS_UMA_CLIENT_NAME, desiredSizePx,
desiredSizePx, callback);
}
@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