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

Unified Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 1538773002: Reduce CPU usage of download shelf UI. (both MD and pre-MD shelves) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no change for indeterminate size dls Created 4 years, 11 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/ui/views/download/download_item_view.cc
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index 20778df043687457b2187fcd773e99ac1786020b..121834e8d472a9ef6a2fe2d208852da6549a2cc8 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -241,10 +241,10 @@ void DownloadItemView::StartDownloadProgress() {
if (progress_timer_.IsRunning())
return;
progress_start_time_ = base::TimeTicks::Now();
- progress_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(DownloadShelf::kProgressRateMs),
- base::Bind(&DownloadItemView::SchedulePaint, base::Unretained(this)));
+ progress_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
+ DownloadShelf::kProgressRateMs),
+ base::Bind(&DownloadItemView::ProgressTimerFired,
+ base::Unretained(this)));
}
void DownloadItemView::StopDownloadProgress() {
@@ -286,6 +286,7 @@ void DownloadItemView::OnDownloadUpdated(DownloadItem* download_item) {
case DownloadItem::IN_PROGRESS:
download()->IsPaused() ?
StopDownloadProgress() : StartDownloadProgress();
+ SchedulePaint();
LoadIconIfItemPathChanged();
break;
case DownloadItem::INTERRUPTED:
@@ -329,11 +330,6 @@ void DownloadItemView::OnDownloadUpdated(DownloadItem* download_item) {
}
UpdateAccessibleName();
-
- // We use the parent's (DownloadShelfView's) SchedulePaint, since there
- // are spaces between each DownloadItemView that the parent is responsible
- // for painting.
- shelf_->SchedulePaint();
}
void DownloadItemView::OnDownloadDestroyed(DownloadItem* download) {
@@ -1398,3 +1394,10 @@ void DownloadItemView::AnimateStateTransition(State from, State to,
animation->Reset((to == HOT) ? 1.0 : 0.0);
}
}
+
+void DownloadItemView::ProgressTimerFired() {
+ // Only repaint for the indeterminate size case. Otherwise, we'll repaint only
+ // when there's an update notified via OnDownloadUpdated().
+ if (model_.PercentComplete() < 0)
+ SchedulePaint();
Evan Stade 2016/01/06 19:34:10 I reverted the change for indeterminate size downl
asanka 2016/01/06 19:44:28 Understood. I agree that we aren't conveying 30fps
+}
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.h ('k') | chrome/browser/ui/views/download/download_item_view_md.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698