| Index: chrome/browser/thumbnails/thumbnail_tab_helper.cc
|
| diff --git a/chrome/browser/thumbnails/thumbnail_tab_helper.cc b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
|
| index f8322e76f9a2d9573939dea942a32fe342b8bffb..c26fd5febe4dbb083576383c474ae1a90ec35269 100644
|
| --- a/chrome/browser/thumbnails/thumbnail_tab_helper.cc
|
| +++ b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
|
| @@ -66,6 +66,13 @@ void ProcessCapturedBitmap(scoped_refptr<ThumbnailingContext> context,
|
| scoped_refptr<ThumbnailingAlgorithm> algorithm,
|
| const SkBitmap& bitmap,
|
| content::ReadbackResponse response) {
|
| + // Was the web contents destroyed before the thumbnail could be generated?
|
| + if (!context->web_contents())
|
| + return;
|
| +
|
| + // Balance the IncrementCapturerCount() from UpdateThumbnailIfNecessary().
|
| + context->web_contents()->DecrementCapturerCount();
|
| +
|
| if (response != content::READBACK_SUCCESS)
|
| return;
|
|
|
| @@ -76,11 +83,11 @@ void ProcessCapturedBitmap(scoped_refptr<ThumbnailingContext> context,
|
| algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap);
|
| }
|
|
|
| -void AsyncProcessThumbnail(content::WebContents* web_contents,
|
| - scoped_refptr<ThumbnailingContext> context,
|
| +void AsyncProcessThumbnail(scoped_refptr<ThumbnailingContext> context,
|
| scoped_refptr<ThumbnailingAlgorithm> algorithm) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| - RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost();
|
| + RenderWidgetHost* render_widget_host =
|
| + context->web_contents()->GetRenderViewHost();
|
| content::RenderWidgetHostView* view = render_widget_host->GetView();
|
| if (!view)
|
| return;
|
| @@ -196,12 +203,14 @@ void ThumbnailTabHelper::UpdateThumbnailIfNecessary(
|
| return;
|
| }
|
|
|
| + web_contents->IncrementCapturerCount(gfx::Size());
|
| +
|
| scoped_refptr<thumbnails::ThumbnailingAlgorithm> algorithm(
|
| thumbnail_service->GetThumbnailingAlgorithm());
|
|
|
| scoped_refptr<ThumbnailingContext> context(new ThumbnailingContext(
|
| web_contents, thumbnail_service.get(), load_interrupted_));
|
| - AsyncProcessThumbnail(web_contents, context, algorithm);
|
| + AsyncProcessThumbnail(context, algorithm);
|
| }
|
|
|
| void ThumbnailTabHelper::RenderViewHostCreated(
|
|
|