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

Unified Diff: chrome/browser/ui/views/download/download_item_view_md.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_md.cc
diff --git a/chrome/browser/ui/views/download/download_item_view_md.cc b/chrome/browser/ui/views/download/download_item_view_md.cc
index 1fbd1304bc0bf058f54d7b44eed775fc87507d40..1ed2c606a8f339b05dd3e9d506c432b83b7bcfc4 100644
--- a/chrome/browser/ui/views/download/download_item_view_md.cc
+++ b/chrome/browser/ui/views/download/download_item_view_md.cc
@@ -205,10 +205,10 @@ void DownloadItemViewMd::StartDownloadProgress() {
if (progress_timer_.IsRunning())
return;
progress_start_time_ = base::TimeTicks::Now();
- progress_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(DownloadShelf::kProgressRateMs),
- base::Bind(&DownloadItemViewMd::SchedulePaint, base::Unretained(this)));
+ progress_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
+ DownloadShelf::kProgressRateMs),
+ base::Bind(&DownloadItemViewMd::ProgressTimerFired,
+ base::Unretained(this)));
}
void DownloadItemViewMd::StopDownloadProgress() {
@@ -257,6 +257,7 @@ void DownloadItemViewMd::OnDownloadUpdated(DownloadItem* download_item) {
case DownloadItem::IN_PROGRESS:
download()->IsPaused() ? StopDownloadProgress()
: StartDownloadProgress();
+ SchedulePaint();
LoadIconIfItemPathChanged();
break;
case DownloadItem::INTERRUPTED:
@@ -300,11 +301,6 @@ void DownloadItemViewMd::OnDownloadUpdated(DownloadItem* download_item) {
}
UpdateAccessibleName();
-
- // We use the parent's (DownloadShelfView's) SchedulePaint, since there
- // are spaces between each DownloadItemViewMd that the parent is responsible
- // for painting.
- shelf_->SchedulePaint();
}
void DownloadItemViewMd::OnDownloadDestroyed(DownloadItem* download) {
@@ -1075,6 +1071,13 @@ void DownloadItemViewMd::AnimateStateTransition(
}
}
+void DownloadItemViewMd::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();
+}
+
SkColor DownloadItemViewMd::GetTextColor() {
return GetTextColorForThemeProvider(GetThemeProvider());
}

Powered by Google App Engine
This is Rietveld 408576698