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

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

Issue 1450083002: Revert "Fix NTP thumbnail generation" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove thumbnailing context unittest. 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 20d6cf054241dbc42c9c972bae9a42d83a399c1e..b9a57b31e1b03a4c2703e47a397c071c55491afc 100644
--- a/chrome/browser/thumbnails/thumbnail_tab_helper.cc
+++ b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
@@ -58,22 +58,15 @@ namespace {
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 @@ void ProcessCapturedBitmap(scoped_refptr<ThumbnailingContext> context,
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 @@ void AsyncProcessThumbnail(scoped_refptr<ThumbnailingContext> context,
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);
}
@@ -203,14 +195,12 @@ 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(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