Commit 4903ce53 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Rename function names in LargeIconService.

This CL renames 2 functions LargeIconService. This is a prerequisite
work for adding
LargeIconService::GetLargeIconRawBitmapOrFallbackStyleForIconUrl in
this CL(http://crrev/c/1384366).

Bug: 903617,910525
Change-Id: Id46811309646955fd2b8888d829f94918e5b910a
Reviewed-on: https://chromium-review.googlesource.com/c/1429959
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625771}
parent 033bb3ba
...@@ -259,7 +259,7 @@ void PartnerBookmarksReader::GetFaviconFromCacheOrServer( ...@@ -259,7 +259,7 @@ void PartnerBookmarksReader::GetFaviconFromCacheOrServer(
bool from_server, bool from_server,
int desired_favicon_size_px, int desired_favicon_size_px,
FaviconFetchedCallback callback) { FaviconFetchedCallback callback) {
GetLargeIconService()->GetLargeIconOrFallbackStyle( GetLargeIconService()->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
page_url, kPartnerBookmarksMinimumFaviconSizePx, desired_favicon_size_px, page_url, kPartnerBookmarksMinimumFaviconSizePx, desired_favicon_size_px,
base::Bind(&PartnerBookmarksReader::OnGetFaviconFromCacheFinished, base::Bind(&PartnerBookmarksReader::OnGetFaviconFromCacheFinished,
base::Unretained(this), page_url, base::Unretained(this), page_url,
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
#include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
using base::android::AttachCurrentThread;
using base::android::ConvertJavaStringToUTF16;
using base::android::JavaParamRef; using base::android::JavaParamRef;
using base::android::JavaRef; using base::android::JavaRef;
using base::android::ScopedJavaGlobalRef; using base::android::ScopedJavaGlobalRef;
using base::android::ScopedJavaLocalRef; using base::android::ScopedJavaLocalRef;
using base::android::AttachCurrentThread;
using base::android::ConvertJavaStringToUTF16;
namespace { namespace {
...@@ -40,8 +40,7 @@ void OnLargeIconAvailable(const JavaRef<jobject>& j_callback, ...@@ -40,8 +40,7 @@ void OnLargeIconAvailable(const JavaRef<jobject>& j_callback,
ScopedJavaLocalRef<jobject> j_bitmap; ScopedJavaLocalRef<jobject> j_bitmap;
if (result.bitmap.is_valid()) { if (result.bitmap.is_valid()) {
gfx::PNGCodec::Decode(result.bitmap.bitmap_data->front(), gfx::PNGCodec::Decode(result.bitmap.bitmap_data->front(),
result.bitmap.bitmap_data->size(), result.bitmap.bitmap_data->size(), &bitmap);
&bitmap);
if (!bitmap.isNull()) if (!bitmap.isNull())
j_bitmap = gfx::ConvertToJavaBitmap(&bitmap); j_bitmap = gfx::ConvertToJavaBitmap(&bitmap);
} }
...@@ -62,11 +61,9 @@ static jlong JNI_LargeIconBridge_Init(JNIEnv* env) { ...@@ -62,11 +61,9 @@ static jlong JNI_LargeIconBridge_Init(JNIEnv* env) {
return reinterpret_cast<intptr_t>(new LargeIconBridge()); return reinterpret_cast<intptr_t>(new LargeIconBridge());
} }
LargeIconBridge::LargeIconBridge() { LargeIconBridge::LargeIconBridge() {}
}
LargeIconBridge::~LargeIconBridge() { LargeIconBridge::~LargeIconBridge() {}
}
void LargeIconBridge::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { void LargeIconBridge::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
delete this; delete this;
...@@ -91,12 +88,11 @@ jboolean LargeIconBridge::GetLargeIconForURL( ...@@ -91,12 +88,11 @@ jboolean LargeIconBridge::GetLargeIconForURL(
favicon_base::LargeIconCallback callback_runner = base::Bind( favicon_base::LargeIconCallback callback_runner = base::Bind(
&OnLargeIconAvailable, ScopedJavaGlobalRef<jobject>(env, j_callback)); &OnLargeIconAvailable, ScopedJavaGlobalRef<jobject>(env, j_callback));
large_icon_service->GetLargeIconOrFallbackStyle( // Use desired_size = 0 for getting the icon from the cache (so that
GURL(ConvertJavaStringToUTF16(env, j_page_url)), // the icon is not poorly rescaled by LargeIconService).
min_source_size_px, large_icon_service->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
0, // Do not resize. GURL(ConvertJavaStringToUTF16(env, j_page_url)), min_source_size_px,
callback_runner, /*desired_size_in_pixel=*/0, callback_runner, &cancelable_task_tracker_);
&cancelable_task_tracker_);
return true; return true;
} }
...@@ -105,7 +105,7 @@ void InternalAppResult::UpdateContinueReadingFavicon( ...@@ -105,7 +105,7 @@ void InternalAppResult::UpdateContinueReadingFavicon(
// Desired size of the icon. If not available, a smaller one will be used. // Desired size of the icon. If not available, a smaller one will be used.
constexpr int min_source_size_in_pixel = 16; constexpr int min_source_size_in_pixel = 16;
constexpr int desired_size_in_pixel = 32; constexpr int desired_size_in_pixel = 32;
large_icon_service_->GetLargeIconImageOrFallbackStyle( large_icon_service_->GetLargeIconImageOrFallbackStyleForPageUrl(
url_for_continuous_reading_, min_source_size_in_pixel, url_for_continuous_reading_, min_source_size_in_pixel,
desired_size_in_pixel, desired_size_in_pixel,
base::BindRepeating(&InternalAppResult::OnGetFaviconFromCacheFinished, base::BindRepeating(&InternalAppResult::OnGetFaviconFromCacheFinished,
......
...@@ -40,8 +40,8 @@ class LargeIconService : public KeyedService { ...@@ -40,8 +40,8 @@ class LargeIconService : public KeyedService {
// - Returns the default fallback icon style. // - Returns the default fallback icon style.
// For cases 4 and 5, this function returns the style of the fallback icon // For cases 4 and 5, this function returns the style of the fallback icon
// instead of rendering an icon so clients can render the icon themselves. // instead of rendering an icon so clients can render the icon themselves.
// TODO(crbug.com/903617): Rename to GetLargeIconRawBitmapOrFallbackStyle. virtual base::CancelableTaskTracker::TaskId
virtual base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
...@@ -50,7 +50,8 @@ class LargeIconService : public KeyedService { ...@@ -50,7 +50,8 @@ class LargeIconService : public KeyedService {
// Behaves the same as GetLargeIconOrFallbackStyle(), only returns the large // Behaves the same as GetLargeIconOrFallbackStyle(), only returns the large
// icon (if available) decoded. // icon (if available) decoded.
virtual base::CancelableTaskTracker::TaskId GetLargeIconImageOrFallbackStyle( virtual base::CancelableTaskTracker::TaskId
GetLargeIconImageOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
......
...@@ -466,7 +466,7 @@ LargeIconServiceImpl::LargeIconServiceImpl( ...@@ -466,7 +466,7 @@ LargeIconServiceImpl::LargeIconServiceImpl(
LargeIconServiceImpl::~LargeIconServiceImpl() {} LargeIconServiceImpl::~LargeIconServiceImpl() {}
base::CancelableTaskTracker::TaskId base::CancelableTaskTracker::TaskId
LargeIconServiceImpl::GetLargeIconOrFallbackStyle( LargeIconServiceImpl::GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
...@@ -478,7 +478,7 @@ LargeIconServiceImpl::GetLargeIconOrFallbackStyle( ...@@ -478,7 +478,7 @@ LargeIconServiceImpl::GetLargeIconOrFallbackStyle(
} }
base::CancelableTaskTracker::TaskId base::CancelableTaskTracker::TaskId
LargeIconServiceImpl::GetLargeIconImageOrFallbackStyle( LargeIconServiceImpl::GetLargeIconImageOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
......
...@@ -36,13 +36,15 @@ class LargeIconServiceImpl : public LargeIconService { ...@@ -36,13 +36,15 @@ class LargeIconServiceImpl : public LargeIconService {
~LargeIconServiceImpl() override; ~LargeIconServiceImpl() override;
// LargeIconService Implementation. // LargeIconService Implementation.
base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( base::CancelableTaskTracker::TaskId
GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
const favicon_base::LargeIconCallback& callback, const favicon_base::LargeIconCallback& callback,
base::CancelableTaskTracker* tracker) override; base::CancelableTaskTracker* tracker) override;
base::CancelableTaskTracker::TaskId GetLargeIconImageOrFallbackStyle( base::CancelableTaskTracker::TaskId
GetLargeIconImageOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
......
...@@ -521,14 +521,14 @@ class LargeIconServiceGetterTest : public LargeIconServiceTest, ...@@ -521,14 +521,14 @@ class LargeIconServiceGetterTest : public LargeIconServiceTest,
int desired_size_in_pixel) { int desired_size_in_pixel) {
// Switch over testing two analogous functions based on the bool param. // Switch over testing two analogous functions based on the bool param.
if (GetParam()) { if (GetParam()) {
large_icon_service_.GetLargeIconOrFallbackStyle( large_icon_service_.GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
page_url, min_source_size_in_pixel, desired_size_in_pixel, page_url, min_source_size_in_pixel, desired_size_in_pixel,
base::BindRepeating( base::BindRepeating(
&LargeIconServiceGetterTest::RawBitmapResultCallback, &LargeIconServiceGetterTest::RawBitmapResultCallback,
base::Unretained(this)), base::Unretained(this)),
&cancelable_task_tracker_); &cancelable_task_tracker_);
} else { } else {
large_icon_service_.GetLargeIconImageOrFallbackStyle( large_icon_service_.GetLargeIconImageOrFallbackStyleForPageUrl(
page_url, min_source_size_in_pixel, desired_size_in_pixel, page_url, min_source_size_in_pixel, desired_size_in_pixel,
base::BindRepeating(&LargeIconServiceGetterTest::ImageResultCallback, base::BindRepeating(&LargeIconServiceGetterTest::ImageResultCallback,
base::Unretained(this)), base::Unretained(this)),
......
...@@ -231,7 +231,7 @@ void ContentSuggestionsService::GetFaviconFromCache( ...@@ -231,7 +231,7 @@ void ContentSuggestionsService::GetFaviconFromCache(
// Use desired_size = 0 for getting the icon from the cache (so that the icon // Use desired_size = 0 for getting the icon from the cache (so that the icon
// is not poorly rescaled by LargeIconService). // is not poorly rescaled by LargeIconService).
large_icon_service_->GetLargeIconImageOrFallbackStyle( large_icon_service_->GetLargeIconImageOrFallbackStyleForPageUrl(
publisher_url, minimum_size_in_pixel, /*desired_size_in_pixel=*/0, publisher_url, minimum_size_in_pixel, /*desired_size_in_pixel=*/0,
base::Bind(&ContentSuggestionsService::OnGetFaviconFromCacheFinished, base::Bind(&ContentSuggestionsService::OnGetFaviconFromCacheFinished,
base::Unretained(this), publisher_url, minimum_size_in_pixel, base::Unretained(this), publisher_url, minimum_size_in_pixel,
......
...@@ -216,7 +216,7 @@ void IconCacherImpl::StartFetchMostLikely(const GURL& page_url, ...@@ -216,7 +216,7 @@ void IconCacherImpl::StartFetchMostLikely(const GURL& page_url,
// Desired size 0 means that we do not want the service to resize the image // Desired size 0 means that we do not want the service to resize the image
// (as we will not use it anyway). // (as we will not use it anyway).
large_icon_service_->GetLargeIconOrFallbackStyle( large_icon_service_->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
page_url, GetMinimumFetchingSizeForChromeSuggestionsFaviconsFromServer(), page_url, GetMinimumFetchingSizeForChromeSuggestionsFaviconsFromServer(),
/*desired_size_in_pixel=*/0, /*desired_size_in_pixel=*/0,
base::Bind(&IconCacherImpl::OnGetLargeIconOrFallbackStyleFinished, base::Bind(&IconCacherImpl::OnGetLargeIconOrFallbackStyleFinished,
......
...@@ -238,7 +238,7 @@ UIImage* GetFallbackImageWithStringAndColor(NSString* string, ...@@ -238,7 +238,7 @@ UIImage* GetFallbackImageWithStringAndColor(NSString* string,
}; };
base::CancelableTaskTracker::TaskId taskID = base::CancelableTaskTracker::TaskId taskID =
_largeIconService->GetLargeIconOrFallbackStyle( _largeIconService->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
URL, kMinIconSize * [UIScreen mainScreen].scale, URL, kMinIconSize * [UIScreen mainScreen].scale,
kIconSize * [UIScreen mainScreen].scale, kIconSize * [UIScreen mainScreen].scale,
base::BindRepeating(faviconBlock), &_largeIconTaskTracker); base::BindRepeating(faviconBlock), &_largeIconTaskTracker);
......
...@@ -140,7 +140,7 @@ FaviconAttributes* FaviconLoader::FaviconForUrl( ...@@ -140,7 +140,7 @@ FaviconAttributes* FaviconLoader::FaviconForUrl(
CGFloat favicon_size_in_pixels = [UIScreen mainScreen].scale * size; CGFloat favicon_size_in_pixels = [UIScreen mainScreen].scale * size;
CGFloat min_favicon_size = [UIScreen mainScreen].scale * min_size; CGFloat min_favicon_size = [UIScreen mainScreen].scale * min_size;
DCHECK(large_icon_service_); DCHECK(large_icon_service_);
large_icon_service_->GetLargeIconOrFallbackStyle( large_icon_service_->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
block_url, min_favicon_size, favicon_size_in_pixels, block_url, min_favicon_size, favicon_size_in_pixels,
base::BindRepeating(favicon_block), &cancelable_task_tracker_); base::BindRepeating(favicon_block), &cancelable_task_tracker_);
......
...@@ -36,7 +36,8 @@ class FakeLargeIconService : public favicon::LargeIconServiceImpl { ...@@ -36,7 +36,8 @@ class FakeLargeIconService : public favicon::LargeIconServiceImpl {
FakeLargeIconService() FakeLargeIconService()
: favicon::LargeIconServiceImpl(/*favicon_service=*/nullptr, : favicon::LargeIconServiceImpl(/*favicon_service=*/nullptr,
/*image_fetcher=*/nullptr) {} /*image_fetcher=*/nullptr) {}
base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( base::CancelableTaskTracker::TaskId
GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
const GURL& page_url, const GURL& page_url,
int min_source_size_in_pixel, int min_source_size_in_pixel,
int desired_size_in_pixel, int desired_size_in_pixel,
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
// Always call LargeIconService in case the favicon was updated. // Always call LargeIconService in case the favicon was updated.
CGFloat faviconSize = [UIScreen mainScreen].scale * self.faviconSize; CGFloat faviconSize = [UIScreen mainScreen].scale * self.faviconSize;
CGFloat minFaviconSize = [UIScreen mainScreen].scale * self.minSize; CGFloat minFaviconSize = [UIScreen mainScreen].scale * self.minSize;
self.largeIconService->GetLargeIconOrFallbackStyle( self.largeIconService->GetLargeIconRawBitmapOrFallbackStyleForPageUrl(
URL, minFaviconSize, faviconSize, URL, minFaviconSize, faviconSize,
base::BindRepeating(faviconBlockSaveToCache), &_faviconTaskTracker); base::BindRepeating(faviconBlockSaveToCache), &_faviconTaskTracker);
} }
......
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