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

Unified Diff: chrome/browser/thumbnails/thumbnail_tab_helper.cc

Issue 1443723002: Revert of Fix NTP thumbnail generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/thumbnails/thumbnail_tab_helper.cc
diff --git a/chrome/browser/thumbnails/thumbnail_tab_helper.cc b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
index ec042d834a94f649e4270a9c7d8c92028e7d7c9d..33deccef2db8b3a0be2667623b50669651dd47f8 100644
--- a/chrome/browser/thumbnails/thumbnail_tab_helper.cc
+++ b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
@@ -58,22 +58,15 @@
void UpdateThumbnail(const ThumbnailingContext& context,
const SkBitmap& thumbnail) {
gfx::Image image = gfx::Image::CreateFrom1xBitmap(thumbnail);
- context.service()->SetPageThumbnail(context, image);
- DVLOG(1) << "Thumbnail taken for " << context.GetURL() << ": "
- << context.score().ToString();
+ context.service->SetPageThumbnail(context, image);
+ DVLOG(1) << "Thumbnail taken for " << context.url << ": "
+ << context.score.ToString();
}
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;
@@ -84,11 +77,12 @@
algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap);
}
-void AsyncProcessThumbnail(scoped_refptr<ThumbnailingContext> context,
+void AsyncProcessThumbnail(content::WebContents* web_contents,
+ scoped_refptr<ThumbnailingContext> context,
scoped_refptr<ThumbnailingAlgorithm> algorithm) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
RenderWidgetHost* render_widget_host =
- context->web_contents()->GetRenderViewHost()->GetWidget();
+ web_contents->GetRenderViewHost()->GetWidget();
content::RenderWidgetHostView* view = render_widget_host->GetView();
if (!view)
return;
@@ -108,16 +102,14 @@
ui::ScaleFactor scale_factor =
ui::GetSupportedScaleFactor(
ui::GetScaleFactorForNativeView(view->GetNativeView()));
- gfx::Size requested_copy_size;
- context->set_clip_result(algorithm->GetCanvasCopyInfo(
+ context->clip_result = algorithm->GetCanvasCopyInfo(
copy_rect.size(),
scale_factor,
&copy_rect,
- &requested_copy_size));
- context->set_requested_copy_size(requested_copy_size);
+ &context->requested_copy_size);
render_widget_host->CopyFromBackingStore(
copy_rect,
- requested_copy_size,
+ context->requested_copy_size,
base::Bind(&ProcessCapturedBitmap, context, algorithm),
kN32_SkColorType);
}
@@ -204,14 +196,12 @@
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(context, algorithm);
+ AsyncProcessThumbnail(web_contents, context, algorithm);
}
void ThumbnailTabHelper::RenderViewHostCreated(
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_service_impl.cc ('k') | chrome/browser/thumbnails/thumbnailing_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698