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

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: . Created 5 years 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 7df05cfb42edf62d50b806b82006e19b4442e62d..e5fb1fddf98338ce3a1ef6b5f4453a5d87b0ab1e 100644
--- a/chrome/browser/ui/views/download/download_item_view_md.cc
+++ b/chrome/browser/ui/views/download/download_item_view_md.cc
@@ -199,21 +199,16 @@ DownloadItemViewMd::~DownloadItemViewMd() {
// Progress animation handlers.
void DownloadItemViewMd::StartDownloadProgress() {
- if (progress_timer_.IsRunning())
+ if (progress_start_time_ != base::TimeTicks())
return;
progress_start_time_ = base::TimeTicks::Now();
- progress_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(DownloadShelf::kProgressRateMs),
- base::Bind(&DownloadItemViewMd::SchedulePaint, base::Unretained(this)));
}
void DownloadItemViewMd::StopDownloadProgress() {
- if (!progress_timer_.IsRunning())
+ if (progress_start_time_ == base::TimeTicks())
return;
previous_progress_elapsed_ += base::TimeTicks::Now() - progress_start_time_;
progress_start_time_ = base::TimeTicks();
- progress_timer_.Stop();
}
// static
@@ -254,6 +249,7 @@ void DownloadItemViewMd::OnDownloadUpdated(DownloadItem* download_item) {
case DownloadItem::IN_PROGRESS:
download()->IsPaused() ? StopDownloadProgress()
: StartDownloadProgress();
+ SchedulePaint();
LoadIconIfItemPathChanged();
break;
case DownloadItem::INTERRUPTED:
@@ -297,11 +293,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) {

Powered by Google App Engine
This is Rietveld 408576698