summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:36:15 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:36:15 +0000
commitc3ee6f79c78d6fcb470262afc140aad614b8624c (patch)
tree0762cffde5da89c466a61b412840f02ada620383 /chrome
parent6d227373602b058ec53c56656ac3ccd4ea7549c4 (diff)
downloadchromium_src-c3ee6f79c78d6fcb470262afc140aad614b8624c.zip
chromium_src-c3ee6f79c78d6fcb470262afc140aad614b8624c.tar.gz
chromium_src-c3ee6f79c78d6fcb470262afc140aad614b8624c.tar.bz2
Fix a bug generating thumbnails. We would only use a stashed thumbnail when it
hadn't expired (5 seconds), even if there was no backing store. We now use the stashed one no matter what if there is no backing store to create a new one. Review URL: http://codereview.chromium.org/147087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/browser/tab_contents/thumbnail_generator.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index efc06ff..9f80c57 100755
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -191,19 +191,26 @@ void ThumbnailGenerator::StartThumbnailing() {
SkBitmap ThumbnailGenerator::GetThumbnailForRenderer(
RenderWidgetHost* renderer) const {
- // Return a cached one if we have it and it's still valid. This will only be
- // valid when there used to be a backing store, but there isn't now.
WidgetThumbnail* wt = GetDataForHost(renderer);
+
+ BackingStore* backing_store = renderer->GetBackingStore(false);
+ if (!backing_store) {
+ // When we have no backing store, there's no choice in what to use. We
+ // have to return either the existing thumbnail or the empty one if there
+ // isn't a saved one.
+ return wt->thumbnail;
+ }
+
+ // Now that we have a backing store, we have a choice to use it to make
+ // a new thumbnail, or use a previously stashed one if we have it.
+ //
+ // Return the previously-computed one if we have it and it hasn't expired.
if (!wt->thumbnail.isNull() &&
(no_timeout_ ||
base::TimeTicks::Now() -
base::TimeDelta::FromMilliseconds(kVisibilitySlopMS) < wt->last_shown))
return wt->thumbnail;
- BackingStore* backing_store = renderer->GetBackingStore(false);
- if (!backing_store)
- return SkBitmap();
-
// Save this thumbnail in case we need to use it again soon. It will be
// invalidated on the next paint.
wt->thumbnail = GetThumbnailForBackingStore(backing_store);