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

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

Issue 2882183002: Thumbnails: Add some perf UMA (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_tab_helper.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a60fd56073a0620a8ad744aa6d319d39906591d1..8abfda8859d3150783c4127474e9d685bb720a39 100644
--- a/chrome/browser/thumbnails/thumbnail_tab_helper.cc
+++ b/chrome/browser/thumbnails/thumbnail_tab_helper.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/thumbnails/thumbnail_tab_helper.h"
#include "base/feature_list.h"
-#include "build/build_config.h"
+#include "base/metrics/histogram_macros.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/thumbnails/thumbnail_service.h"
#include "chrome/browser/thumbnails/thumbnail_service_factory.h"
@@ -18,7 +18,6 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
-#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/scrollbar_size.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(ThumbnailTabHelper);
@@ -48,7 +47,7 @@ using content::WebContents;
using thumbnails::ThumbnailingContext;
using thumbnails::ThumbnailingAlgorithm;
-ThumbnailTabHelper::ThumbnailTabHelper(content::WebContents* contents)
jochen (gone - plz use gerrit) 2017/05/16 11:15:17 using content::Something should be the exception,
Marc Treib 2017/05/16 11:48:37 Done. (For all three "using content::"s)
+ThumbnailTabHelper::ThumbnailTabHelper(WebContents* contents)
: content::WebContentsObserver(contents),
capture_on_load_finished_(base::FeatureList::IsEnabled(
features::kCaptureThumbnailOnLoadFinished)),
@@ -63,8 +62,7 @@ ThumbnailTabHelper::ThumbnailTabHelper(content::WebContents* contents)
content::Source<WebContents>(contents));
}
-ThumbnailTabHelper::~ThumbnailTabHelper() {
-}
+ThumbnailTabHelper::~ThumbnailTabHelper() = default;
void ThumbnailTabHelper::Observe(int type,
const content::NotificationSource& source,
@@ -121,12 +119,14 @@ void ThumbnailTabHelper::UpdateThumbnailIfNecessary() {
// 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() || web_contents()->IsBeingDestroyed())
+ if (!web_contents() || web_contents()->IsBeingDestroyed()) {
jochen (gone - plz use gerrit) 2017/05/16 11:15:17 why this change? if (single line) single line;
Marc Treib 2017/05/16 11:48:37 For local consistency, since there are a few other
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())
+ if (web_contents()->GetController().GetPendingEntry()) {
return;
+ }
const GURL& url = web_contents()->GetURL();
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
@@ -181,6 +181,7 @@ void ThumbnailTabHelper::AsyncProcessThumbnail(
scale_factor,
&copy_rect,
&thumbnailing_context_->requested_copy_size);
+ copy_from_surface_start_time_ = base::TimeTicks::Now();
view->CopyFromSurface(copy_rect, thumbnailing_context_->requested_copy_size,
base::Bind(&ThumbnailTabHelper::ProcessCapturedBitmap,
weak_factory_.GetWeakPtr(), algorithm),
@@ -191,9 +192,14 @@ void ThumbnailTabHelper::ProcessCapturedBitmap(
scoped_refptr<ThumbnailingAlgorithm> algorithm,
const SkBitmap& bitmap,
content::ReadbackResponse response) {
+ base::TimeDelta copy_from_surface_time =
+ base::TimeTicks::Now() - copy_from_surface_start_time_;
+ UMA_HISTOGRAM_TIMES("Thumbnails.CopyFromSurfaceTime", copy_from_surface_time);
+
if (response == content::READBACK_SUCCESS) {
// On success, we must be on the UI thread.
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ process_bitmap_start_time_ = base::TimeTicks::Now();
algorithm->ProcessBitmap(thumbnailing_context_,
base::Bind(&ThumbnailTabHelper::UpdateThumbnail,
weak_factory_.GetWeakPtr()),
@@ -209,14 +215,13 @@ void ThumbnailTabHelper::ProcessCapturedBitmap(
}
}
-void ThumbnailTabHelper::CleanUpFromThumbnailGeneration() {
Marc Treib 2017/05/15 10:16:48 Moved to match the order in the header.
- // Make a note that thumbnail generation is complete.
- thumbnailing_context_ = nullptr;
-}
-
void ThumbnailTabHelper::UpdateThumbnail(const ThumbnailingContext& context,
const SkBitmap& thumbnail) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ base::TimeDelta process_bitmap_time =
+ base::TimeTicks::Now() - process_bitmap_start_time_;
+ UMA_HISTOGRAM_TIMES("Thumbnails.ProcessBitmapTime", process_bitmap_time);
+
// Feed the constructed thumbnail to the thumbnail service.
gfx::Image image = gfx::Image::CreateFrom1xBitmap(thumbnail);
context.service->SetPageThumbnail(context, image);
@@ -226,6 +231,11 @@ void ThumbnailTabHelper::UpdateThumbnail(const ThumbnailingContext& context,
CleanUpFromThumbnailGeneration();
}
+void ThumbnailTabHelper::CleanUpFromThumbnailGeneration() {
+ // Make a note that thumbnail generation is complete.
+ thumbnailing_context_ = nullptr;
+}
+
void ThumbnailTabHelper::RenderViewHostCreated(RenderViewHost* renderer) {
// NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED is really a new
// RenderView, not RenderViewHost, and there is no good way to get
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_tab_helper.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698