Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3797)

Unified Diff: chrome/browser/tab_contents/thumbnail_generator.cc

Issue 10911008: Avoid generating thumbnails while WebContents is destructed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/thumbnail_generator.cc
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index ab0d5f32358714e27951e0479291a16bfb2f6476..09ce31ac785b45f036c4a5c25e822216b662a5bf 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -483,8 +483,13 @@ SkBitmap ThumbnailGenerator::GetClippedBitmap(const SkBitmap& bitmap,
void ThumbnailGenerator::UpdateThumbnailIfNecessary(
WebContents* web_contents) {
- // Skip if a pending entry exists. WidgetHidden can be called while navigaing
- // pages and this is not a timing when thumbnails should be generated.
+ // Destroying a WebContents may trigger it to be hidden, prompting a snapshot
+ // which would be unwise to attempt <http://crbug.com/130097>. If the
+ // WebContents is in the middle of destruction, do not risk it.
+ if (web_contents->IsBeingDestroyed())
mazda 2012/08/30 17:19:18 How about the follwing code to deal with the case
Avi (use Gerrit) 2012/08/30 18:16:26 Is that in addition to this code or to replace it?
mazda 2012/08/30 19:39:22 I meant to replace it. But when NOTIFICATION_TAB_C
Avi (use Gerrit) 2012/08/30 19:44:16 Adding a temporary dependency to TabContents would
mazda 2012/08/30 20:39:39 Yes, http://crbug.com/130097 was caused by NOTIFIC
+ return;
+ // Skip if a pending entry exists. WidgetHidden can be called while navigating
+ // pages and this is not a time when thumbnails should be generated.
if (web_contents->GetController().GetPendingEntry())
return;
const GURL& url = web_contents->GetURL();
@@ -501,7 +506,6 @@ void ThumbnailGenerator::UpdateThumbnailIfNecessary(
void ThumbnailGenerator::UpdateThumbnail(
WebContents* web_contents, const SkBitmap& thumbnail,
const ClipResult& clip_result) {
-
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
history::TopSites* top_sites = profile->GetTopSites();
« no previous file with comments | « no previous file | chrome/browser/ui/tab_contents/tab_contents.cc » ('j') | chrome/browser/ui/tab_contents/tab_contents.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698