Commit 82b1a001 authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

Update icon timestamps in FaviconRequestHandler

An icon found during the first local lookup in FaviconRequestHandler
may originally come from the favicon server, so we need to update its
timestamp in the database, for eviction purposes.

Change-Id: I1fbeff5e9d1e0e5da45cac289d1e1bb7c5d6b2ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640647
Commit-Queue: Victor Vianna <victorvianna@google.com>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665854}
parent 9ecfcff2
...@@ -213,6 +213,8 @@ void FaviconRequestHandler::OnBitmapLocalDataAvailable( ...@@ -213,6 +213,8 @@ void FaviconRequestHandler::OnBitmapLocalDataAvailable(
// The icon comes from local storage now even though it may have been // The icon comes from local storage now even though it may have been
// originally retrieved from Google server. // originally retrieved from Google server.
RecordFaviconAvailabilityMetric(origin, FaviconAvailability::kLocal); RecordFaviconAvailabilityMetric(origin, FaviconAvailability::kLocal);
if (large_icon_service)
large_icon_service->TouchIconFromGoogleServer(bitmap_result.icon_url);
std::move(response_callback).Run(bitmap_result); std::move(response_callback).Run(bitmap_result);
return; return;
} }
...@@ -275,6 +277,8 @@ void FaviconRequestHandler::OnImageLocalDataAvailable( ...@@ -275,6 +277,8 @@ void FaviconRequestHandler::OnImageLocalDataAvailable(
// The icon comes from local storage now even though it may have been // The icon comes from local storage now even though it may have been
// originally retrieved from Google server. // originally retrieved from Google server.
RecordFaviconAvailabilityMetric(origin, FaviconAvailability::kLocal); RecordFaviconAvailabilityMetric(origin, FaviconAvailability::kLocal);
if (large_icon_service)
large_icon_service->TouchIconFromGoogleServer(image_result.icon_url);
std::move(response_callback).Run(image_result); std::move(response_callback).Run(image_result);
return; return;
} }
......
...@@ -28,6 +28,7 @@ using testing::_; ...@@ -28,6 +28,7 @@ using testing::_;
using testing::Invoke; using testing::Invoke;
const char kDummyPageUrl[] = "https://www.example.com"; const char kDummyPageUrl[] = "https://www.example.com";
const char kDummyIconUrl[] = "https://www.example.com/favicon16.png";
const int kDesiredSizeInPixel = 16; const int kDesiredSizeInPixel = 16;
// TODO(victorvianna): Add unit tests specific for mobile. // TODO(victorvianna): Add unit tests specific for mobile.
const FaviconRequestPlatform kDummyPlatform = FaviconRequestPlatform::kDesktop; const FaviconRequestPlatform kDummyPlatform = FaviconRequestPlatform::kDesktop;
...@@ -46,12 +47,14 @@ scoped_refptr<base::RefCountedBytes> CreateTestBitmapBytes() { ...@@ -46,12 +47,14 @@ scoped_refptr<base::RefCountedBytes> CreateTestBitmapBytes() {
favicon_base::FaviconRawBitmapResult CreateTestBitmapResult() { favicon_base::FaviconRawBitmapResult CreateTestBitmapResult() {
favicon_base::FaviconRawBitmapResult result; favicon_base::FaviconRawBitmapResult result;
result.bitmap_data = CreateTestBitmapBytes(); result.bitmap_data = CreateTestBitmapBytes();
result.icon_url = GURL(kDummyIconUrl);
return result; return result;
} }
favicon_base::FaviconImageResult CreateTestImageResult() { favicon_base::FaviconImageResult CreateTestImageResult() {
favicon_base::FaviconImageResult result; favicon_base::FaviconImageResult result;
result.image = gfx::Image::CreateFrom1xPNGBytes(CreateTestBitmapBytes()); result.image = gfx::Image::CreateFrom1xPNGBytes(CreateTestBitmapBytes());
result.icon_url = GURL(kDummyIconUrl);
return result; return result;
} }
...@@ -182,6 +185,8 @@ TEST_F(FaviconRequestHandlerTest, ShouldGetLocalBitmap) { ...@@ -182,6 +185,8 @@ TEST_F(FaviconRequestHandlerTest, ShouldGetLocalBitmap) {
std::move(callback).Run(CreateTestBitmapResult()); std::move(callback).Run(CreateTestBitmapResult());
return kDummyTaskId; return kDummyTaskId;
}); });
EXPECT_CALL(mock_large_icon_service_,
TouchIconFromGoogleServer(GURL(kDummyIconUrl)));
EXPECT_CALL(synced_favicon_getter_, Run(_)).Times(0); EXPECT_CALL(synced_favicon_getter_, Run(_)).Times(0);
favicon_base::FaviconRawBitmapResult result; favicon_base::FaviconRawBitmapResult result;
favicon_request_handler_.GetRawFaviconForPageURL( favicon_request_handler_.GetRawFaviconForPageURL(
...@@ -326,6 +331,8 @@ TEST_F(FaviconRequestHandlerTest, ShouldGetLocalImage) { ...@@ -326,6 +331,8 @@ TEST_F(FaviconRequestHandlerTest, ShouldGetLocalImage) {
std::move(callback).Run(CreateTestImageResult()); std::move(callback).Run(CreateTestImageResult());
return kDummyTaskId; return kDummyTaskId;
}); });
EXPECT_CALL(mock_large_icon_service_,
TouchIconFromGoogleServer(GURL(kDummyIconUrl)));
EXPECT_CALL(synced_favicon_getter_, Run(_)).Times(0); EXPECT_CALL(synced_favicon_getter_, Run(_)).Times(0);
favicon_base::FaviconImageResult result; favicon_base::FaviconImageResult result;
favicon_request_handler_.GetFaviconImageForPageURL( favicon_request_handler_.GetFaviconImageForPageURL(
......
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