diff options
author | mef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 08:37:48 +0000 |
---|---|---|
committer | mef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 08:37:48 +0000 |
commit | 749fadd21aec1956873b3f8de5602874c7a52dc6 (patch) | |
tree | f276b17bab9f9b689ac11fbe78364070bb2c0332 | |
parent | 0ee52ae1c62435fcc90d71fda333fd49431b1525 (diff) | |
download | chromium_src-749fadd21aec1956873b3f8de5602874c7a52dc6.zip chromium_src-749fadd21aec1956873b3f8de5602874c7a52dc6.tar.gz chromium_src-749fadd21aec1956873b3f8de5602874c7a52dc6.tar.bz2 |
Don't request missing favicon on every page request.
Mark Favicon as 'Unable to Download' if server returns HTTP status 404 and
don't try to download it again until user closes the browser or clicks 'Shift-Reload'
(RELOAD_IGNORING_CACHE).
Firefox 20 and IE 10 don't request missing favicon.ico on every page request.
Propagated HTTP Status Code from MultiResolutionImageResourceFetcher all
the way up to FaviconTabHelper, which required extension of 3 interfaces.
BUG=39402
TEST=FaviconHandlerTest.UnableToDownloadFavicon
Reviewers:
sky@chromium.org - Overall CL, chrome/browser/*, content/browser/*
palmer@chromium.org - content/common/image_messages.h
joi@chromium.org - content/public/browser/web_contents.h
jamesr@chromium.org - content/renderer/*, webkit/glue/*
mnaganov@chromium.org - android_webview/browser/icon_helper.*
Review URL: https://chromiumcodereview.appspot.com/14322023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200194 0039d316-1c4b-4281-b951-d872f2087c98
24 files changed, 175 insertions, 17 deletions
diff --git a/android_webview/browser/icon_helper.cc b/android_webview/browser/icon_helper.cc index 13091f2..7f6c4fb 100644 --- a/android_webview/browser/icon_helper.cc +++ b/android_webview/browser/icon_helper.cc @@ -30,7 +30,7 @@ void IconHelper::SetListener(Listener* listener) { } void IconHelper::DownloadFaviconCallback( - int id, const GURL& image_url, int requested_size, + int id, int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (bitmaps.size() == 0) { diff --git a/android_webview/browser/icon_helper.h b/android_webview/browser/icon_helper.h index e684cdf..390ac39 100644 --- a/android_webview/browser/icon_helper.h +++ b/android_webview/browser/icon_helper.h @@ -37,8 +37,9 @@ class IconHelper : public content::WebContentsObserver { virtual void DidUpdateFaviconURL(int32 page_id, const std::vector<content::FaviconURL>& candidates) OVERRIDE; - void DownloadFaviconCallback(int id, const GURL& image_url, - int requested_size, const std::vector<SkBitmap>& bitmaps); + void DownloadFaviconCallback(int id, int http_status_code, + const GURL& image_url, int requested_size, + const std::vector<SkBitmap>& bitmaps); private: Listener* listener_; diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc index 251aee5..ff4db52 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -4,6 +4,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/favicon/favicon_handler.h" +#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "content/public/browser/favicon_status.h" @@ -352,6 +353,14 @@ class FaviconHandlerTest : public ChromeRenderViewHostTestHarness { ChromeRenderViewHostTestHarness::SetUp(); } + virtual void TearDown() OVERRIDE { + Profile* profile = Profile::FromBrowserContext( + web_contents()->GetBrowserContext()); + FaviconServiceFactory::GetInstance()->SetTestingFactory( + profile, NULL); + ChromeRenderViewHostTestHarness::TearDown(); + } + private: DISALLOW_COPY_AND_ASSIGN(FaviconHandlerTest); }; @@ -1020,4 +1029,79 @@ TEST_F(FaviconHandlerTest, FirstFavicon) { handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width()); } +static ProfileKeyedService* BuildFaviconService( + content::BrowserContext* profile) { + return new FaviconService(NULL); +} + +// Test that Favicon is not requested repeatedly during the same session if +// server returns HTTP 404 status. +TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { + const GURL missing_icon_url("http://www.google.com/favicon.ico"); + const GURL another_icon_url("http://www.youtube.com/favicon.ico"); + + Profile* profile = Profile::FromBrowserContext( + web_contents()->GetBrowserContext()); + + FaviconServiceFactory::GetInstance()->SetTestingFactory( + profile, BuildFaviconService); + FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( + profile, Profile::IMPLICIT_ACCESS); + + FaviconTabHelper::CreateForWebContents(web_contents()); + FaviconTabHelper* favicon_tab_helper = + FaviconTabHelper::FromWebContents(web_contents()); + + std::vector<SkBitmap> empty_icons; + int download_id = 0; + + // Try to download missing icon. + download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); + EXPECT_NE(0, download_id); + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); + + // Report download failure with HTTP 503 status. + favicon_tab_helper->DidDownloadFavicon(download_id, 503, missing_icon_url, + 0, empty_icons); + // Icon is not marked as UnableToDownload as HTTP status is not 404. + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); + + // Try to download again. + download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); + EXPECT_NE(0, download_id); + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); + + // Report download failure with HTTP 404 status. + favicon_tab_helper->DidDownloadFavicon(download_id, 404, missing_icon_url, + 0, empty_icons); + // Icon is marked as UnableToDownload. + EXPECT_TRUE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); + + // Try to download again. + download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); + // Download is not started and Icon is still marked as UnableToDownload. + EXPECT_EQ(0, download_id); + EXPECT_TRUE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); + + // Try to download another icon. + download_id = favicon_tab_helper->StartDownload(another_icon_url, 0); + // Download is started as another icon URL is not same as missing_icon_url. + EXPECT_NE(0, download_id); + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(another_icon_url)); + + // Clear the list of missing icons. + favicon_service->ClearUnableToDownloadFavicons(); + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(another_icon_url)); + + // Try to download again. + download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); + EXPECT_NE(0, download_id); + // Report download success with HTTP 200 status. + favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, + 0, empty_icons); + // Icon is not marked as UnableToDownload as HTTP status is not 404. + EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); +} + } // namespace. diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc index 1c3a9a8b..1c9b8ff 100644 --- a/chrome/browser/favicon/favicon_service.cc +++ b/chrome/browser/favicon/favicon_service.cc @@ -4,6 +4,7 @@ #include "chrome/browser/favicon/favicon_service.h" +#include "base/hash.h" #include "base/message_loop/message_loop_proxy.h" #include "chrome/browser/favicon/favicon_util.h" #include "chrome/browser/favicon/imported_favicon_usage.h" @@ -260,6 +261,20 @@ void FaviconService::SetFavicons( history_service_->SetFavicons(page_url, icon_type, favicon_bitmap_data); } +void FaviconService::UnableToDownloadFavicon(const GURL& icon_url) { + MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); + missing_favicon_urls_.insert(url_hash); +} + +bool FaviconService::WasUnableToDownloadFavicon(const GURL& icon_url) const { + MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); + return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); +} + +void FaviconService::ClearUnableToDownloadFavicons() { + missing_favicon_urls_.clear(); +} + FaviconService::~FaviconService() {} CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( @@ -354,3 +369,4 @@ void FaviconService::RunFaviconRawCallbackWithBitmapResults( &resized_bitmap_data); callback.Run(bitmap_result); } + diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h index 156de34..bc49082 100644 --- a/chrome/browser/favicon/favicon_service.h +++ b/chrome/browser/favicon/favicon_service.h @@ -8,6 +8,7 @@ #include <vector> #include "base/callback.h" +#include "base/hash_tables.h" #include "base/memory/ref_counted.h" #include "chrome/browser/common/cancelable_request.h" #include "chrome/browser/history/history_types.h" @@ -224,7 +225,14 @@ class FaviconService : public CancelableRequestProvider, history::IconType icon_type, const gfx::Image& image); + // Avoid repeated requests to download missing favicon. + void UnableToDownloadFavicon(const GURL& icon_url); + bool WasUnableToDownloadFavicon(const GURL& icon_url) const; + void ClearUnableToDownloadFavicons(); + private: + typedef uint32 MissingFaviconURLHash; + base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; HistoryService* history_service_; // Helper function for GetFaviconImageForURL(), GetRawFaviconForURL() and diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc index 768e950..754c6e8 100644 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ b/chrome/browser/favicon/favicon_tab_helper.cc @@ -135,6 +135,13 @@ NavigationEntry* FaviconTabHelper::GetActiveEntry() { } int FaviconTabHelper::StartDownload(const GURL& url, int image_size) { + FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( + profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); + if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) { + DVLOG(1) << "Skip Failed FavIcon: " << url; + return 0; + } + return web_contents()->DownloadImage( url, true, @@ -157,8 +164,11 @@ void FaviconTabHelper::NavigateToPendingEntry( !profile_->IsOffTheRecord()) { FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( profile_, Profile::IMPLICIT_ACCESS); - if (favicon_service) + if (favicon_service) { favicon_service->SetFaviconOutOfDateForPage(url); + if (reload_type == NavigationController::RELOAD_IGNORING_CACHE) + favicon_service->ClearUnableToDownloadFavicons(); + } } } @@ -179,9 +189,19 @@ void FaviconTabHelper::DidUpdateFaviconURL( void FaviconTabHelper::DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { + + if (bitmaps.empty() && http_status_code == 404) { + DVLOG(1) << "Failed to Download Favicon:" << image_url; + FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( + profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); + if (favicon_service) + favicon_service->UnableToDownloadFavicon(image_url); + } + favicon_handler_->OnDidDownloadFavicon( id, image_url, requested_size, bitmaps); if (touch_icon_handler_.get()) { diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h index de41009..b0f17a2 100644 --- a/chrome/browser/favicon/favicon_tab_helper.h +++ b/chrome/browser/favicon/favicon_tab_helper.h @@ -72,6 +72,14 @@ class FaviconTabHelper : public content::WebContentsObserver, virtual int StartDownload(const GURL& url, int image_size) OVERRIDE; virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; + // Favicon download callback. + void DidDownloadFavicon( + int id, + int http_status_code, + const GURL& image_url, + int requested_size, + const std::vector<SkBitmap>& bitmaps); + private: explicit FaviconTabHelper(content::WebContents* web_contents); friend class content::WebContentsUserData<FaviconTabHelper>; @@ -84,13 +92,6 @@ class FaviconTabHelper : public content::WebContentsObserver, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) OVERRIDE; - // Favicon download callback. - void DidDownloadFavicon( - int id, - const GURL& image_url, - int requested_size, - const std::vector<SkBitmap>& bitmaps); - Profile* profile_; bool should_fetch_icons_; diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc index 671c35e..7be0783 100644 --- a/chrome/browser/notifications/message_center_notification_manager.cc +++ b/chrome/browser/notifications/message_center_notification_manager.cc @@ -379,6 +379,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloadByKey( void MessageCenterNotificationManager::ImageDownloads::DownloadComplete( const SetImageCallback& callback, int download_id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h index 2bd7a6f..b4510db 100644 --- a/chrome/browser/notifications/message_center_notification_manager.h +++ b/chrome/browser/notifications/message_center_notification_manager.h @@ -91,6 +91,7 @@ class MessageCenterNotificationManager // FaviconHelper callback. void DownloadComplete(const SetImageCallback& callback, int download_id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); diff --git a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc index 0c9e14c..051e468 100644 --- a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc +++ b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc @@ -47,6 +47,7 @@ class FaviconBitmapHandler : public content::WebContentsObserver { private: void DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); @@ -121,6 +122,7 @@ bool FaviconBitmapHandler::HasPendingDownloads() const { void FaviconBitmapHandler::DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc index f167e74..a601f45 100644 --- a/chrome/browser/ui/extensions/shell_window.cc +++ b/chrome/browser/ui/extensions/shell_window.cc @@ -422,6 +422,7 @@ void ShellWindow::OnImageLoaded(const gfx::Image& image) { } void ShellWindow::DidDownloadFavicon(int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { diff --git a/chrome/browser/ui/extensions/shell_window.h b/chrome/browser/ui/extensions/shell_window.h index 05b06ab..fa3813d 100644 --- a/chrome/browser/ui/extensions/shell_window.h +++ b/chrome/browser/ui/extensions/shell_window.h @@ -268,6 +268,7 @@ class ShellWindow : public content::NotificationObserver, // Callback from web_contents()->DownloadFavicon. void DidDownloadFavicon(int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); diff --git a/chrome/browser/ui/metro_pin_tab_helper_win.cc b/chrome/browser/ui/metro_pin_tab_helper_win.cc index 13507c3..a06b792 100644 --- a/chrome/browser/ui/metro_pin_tab_helper_win.cc +++ b/chrome/browser/ui/metro_pin_tab_helper_win.cc @@ -428,6 +428,7 @@ void MetroPinTabHelper::DidUpdateFaviconURL( void MetroPinTabHelper::DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { diff --git a/chrome/browser/ui/metro_pin_tab_helper_win.h b/chrome/browser/ui/metro_pin_tab_helper_win.h index 7a60705..c67fdd2 100644 --- a/chrome/browser/ui/metro_pin_tab_helper_win.h +++ b/chrome/browser/ui/metro_pin_tab_helper_win.h @@ -43,6 +43,7 @@ class MetroPinTabHelper // Favicon download callback. void DidDownloadFavicon(int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); diff --git a/chrome/browser/ui/views/create_application_shortcut_view.cc b/chrome/browser/ui/views/create_application_shortcut_view.cc index 3f4feb8..33acbd2 100644 --- a/chrome/browser/ui/views/create_application_shortcut_view.cc +++ b/chrome/browser/ui/views/create_application_shortcut_view.cc @@ -476,6 +476,7 @@ void CreateUrlApplicationShortcutView::FetchIcon() { void CreateUrlApplicationShortcutView::DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { diff --git a/chrome/browser/ui/views/create_application_shortcut_view.h b/chrome/browser/ui/views/create_application_shortcut_view.h index 45de8d8..df5af4f 100644 --- a/chrome/browser/ui/views/create_application_shortcut_view.h +++ b/chrome/browser/ui/views/create_application_shortcut_view.h @@ -99,6 +99,7 @@ class CreateUrlApplicationShortcutView : public CreateApplicationShortcutView { // Favicon download callback. void DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc index 4788e33..fd4a9da 100644 --- a/chrome/browser/ui/web_applications/web_app_ui.cc +++ b/chrome/browser/ui/web_applications/web_app_ui.cc @@ -89,6 +89,7 @@ class UpdateShortcutWorker : public content::NotificationObserver { // Favicon download callback. void DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); @@ -192,6 +193,7 @@ void UpdateShortcutWorker::DownloadIcon() { void UpdateShortcutWorker::DidDownloadFavicon( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 47a984c..b712143 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -2397,6 +2397,7 @@ void WebContentsImpl::OnBrowserPluginMessage(const IPC::Message& message) { void WebContentsImpl::OnDidDownloadImage( int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps) { @@ -2407,7 +2408,7 @@ void WebContentsImpl::OnDidDownloadImage( return; } if (!iter->second.is_null()) { - iter->second.Run(id, image_url, requested_size, bitmaps); + iter->second.Run(id, http_status_code, image_url, requested_size, bitmaps); } image_download_map_.erase(id); } diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index a7a408b..3cca074 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -589,6 +589,7 @@ class CONTENT_EXPORT WebContentsImpl const base::FilePath& plugin_path); void OnBrowserPluginMessage(const IPC::Message& message); void OnDidDownloadImage(int id, + int http_status_code, const GURL& image_url, int requested_size, const std::vector<SkBitmap>& bitmaps); diff --git a/content/common/image_messages.h b/content/common/image_messages.h index 78d7cff..2a7ebb8 100644 --- a/content/common/image_messages.h +++ b/content/common/image_messages.h @@ -25,8 +25,9 @@ IPC_MESSAGE_ROUTED4(ImageMsg_DownloadImage, // Messages sent from the renderer to the browser. -IPC_MESSAGE_ROUTED4(ImageHostMsg_DidDownloadImage, +IPC_MESSAGE_ROUTED5(ImageHostMsg_DidDownloadImage, int /* Identifier of the request */, + int /* HTTP response status */, GURL /* URL of the image */, int /* Preferred image size passed to ImageMsg_DownloadImage */, diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 8a3d038..a5403bf 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -408,6 +408,7 @@ class WebContents : public PageNavigator, virtual bool HasOpener() const = 0; typedef base::Callback<void(int, /* id */ + int, /* HTTP status code */ const GURL&, /* image_url */ int, /* requested_size */ const std::vector<SkBitmap>& /* bitmaps*/)> diff --git a/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc b/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc index 33235c1..f3c79b3 100644 --- a/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc +++ b/content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc @@ -25,6 +25,7 @@ MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher( const Callback& callback) : callback_(callback), id_(id), + http_status_code_(0), image_url_(image_url) { fetcher_.reset(new ResourceFetcher( image_url, frame, target_type, @@ -41,10 +42,13 @@ void MultiResolutionImageResourceFetcher::OnURLFetchComplete( const WebURLResponse& response, const std::string& data) { std::vector<SkBitmap> bitmaps; - if (!response.isNull() && response.httpStatusCode() == 200) { - // Request succeeded, try to convert it to an image. - bitmaps = webkit_glue::ImageDecoder::DecodeAll( - reinterpret_cast<const unsigned char*>(data.data()), data.size()); + if (!response.isNull()) { + http_status_code_ = response.httpStatusCode(); + if (http_status_code_ == 200) { + // Request succeeded, try to convert it to an image. + bitmaps = webkit_glue::ImageDecoder::DecodeAll( + reinterpret_cast<const unsigned char*>(data.data()), data.size()); + } } // else case: // If we get here, it means no image from server or couldn't decode the // response as an image. The delegate will see an empty vector. diff --git a/content/renderer/fetchers/multi_resolution_image_resource_fetcher.h b/content/renderer/fetchers/multi_resolution_image_resource_fetcher.h index 925eed2..3e7c326 100644 --- a/content/renderer/fetchers/multi_resolution_image_resource_fetcher.h +++ b/content/renderer/fetchers/multi_resolution_image_resource_fetcher.h @@ -37,6 +37,9 @@ class MultiResolutionImageResourceFetcher{ // Unique identifier for the request. int id() const { return id_; } + // HTTP status code upon fetch completion. + int http_status_code() const { return http_status_code_; } + private: // ResourceFetcher::Callback. Decodes the image and invokes callback_. void OnURLFetchComplete(const WebKit::WebURLResponse& response, @@ -47,6 +50,9 @@ class MultiResolutionImageResourceFetcher{ // Unique identifier for the request. const int id_; + // HTTP status code upon fetch completion. + int http_status_code_; + // URL of the image. const GURL image_url_; diff --git a/content/renderer/image_loading_helper.cc b/content/renderer/image_loading_helper.cc index 5f936a41f3..3b1b1e1 100644 --- a/content/renderer/image_loading_helper.cc +++ b/content/renderer/image_loading_helper.cc @@ -53,6 +53,7 @@ void ImageLoadingHelper::OnDownloadImage(int id, Send(new ImageHostMsg_DidDownloadImage(routing_id(), id, + 0, image_url, image_size, result_images)); @@ -84,6 +85,7 @@ void ImageLoadingHelper::DidDownloadImage( // Notify requester of image download status. Send(new ImageHostMsg_DidDownloadImage(routing_id(), fetcher->id(), + fetcher->http_status_code(), fetcher->image_url(), requested_size, images)); |