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

Unified Diff: chrome/browser/win/jumplist.cc

Issue 2896233003: Cancel the JumpList update if top 5 most visited URLs are unchanged (Closed)
Patch Set: Fix signed/unsigned int comparison build error 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist.cc
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc
index 7f8ecf1257bda62023d10ea3bf2b181b72fe7a6c..16bd831c2fd2364417b67bd1b24f8cf1376c8dfc 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -292,6 +292,31 @@ void JumpList::OnMostVisitedURLsAvailable(
{
JumpListData* data = &jumplist_data_->data;
base::AutoLock auto_lock(data->list_lock_);
+
+ bool need_update = false;
grt (UTC plus 2) 2017/05/24 07:22:12 i think it makes sense to make a helper function f
chengx 2017/05/24 23:44:14 I've added the helper function. I think it's bette
+
+ // If the number of the top sites going to be displayed is larger than the
grt (UTC plus 2) 2017/05/24 07:22:12 although it's unexpected, i think you also want to
chengx 2017/05/24 23:44:14 Done. You're right.
+ // current one, schedule an update.
+ size_t topsites_count_updated = std::min(urls.size(), kMostVisitedItems);
+ if (topsites_count_updated > data->most_visited_pages_.size())
+ need_update = true;
+
+ // Cancel this jumplist update if the top |kMostVisitedItems| most visited
+ // urls are unchanged.
+ if (!need_update) {
grt (UTC plus 2) 2017/05/24 07:22:12 how about something like this: #include <algorith
chengx 2017/05/24 23:44:14 Done. This is really impressive!
+ size_t i = 0;
+ for (ShellLinkItemList::const_iterator
+ iter = data->most_visited_pages_.begin();
+ iter != data->most_visited_pages_.end(); ++iter, ++i) {
+ if ((*iter)->url() != urls[i].url.spec()) {
+ need_update = true;
+ break;
+ }
+ }
+ }
+ if (!need_update)
+ return;
+
data->most_visited_pages_.clear();
for (size_t i = 0; i < urls.size() && i < kMostVisitedItems; i++) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698