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

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

Issue 2896233003: Cancel the JumpList update if top 5 most visited URLs are unchanged (Closed)
Patch Set: Add unittest 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
Index: chrome/browser/win/jumplist_update_util.cc
diff --git a/chrome/browser/win/jumplist_update_util.cc b/chrome/browser/win/jumplist_update_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da47fd0c700ca629178671b3bb35362b70021223
--- /dev/null
+++ b/chrome/browser/win/jumplist_update_util.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <algorithm>
+#include <iterator>
+
+#include "chrome/browser/win/jumplist_update_util.h"
grt (UTC plus 2) 2017/05/30 08:51:41 nit: move up above other includes (https://google.
chengx 2017/05/30 19:37:02 Done.
+
+bool MostVisitedItemsUnchanged(const ShellLinkItemList& items,
+ const history::MostVisitedURLList& urls,
+ size_t most_visited_items) {
grt (UTC plus 2) 2017/05/30 08:51:41 nit: max_item_count?
chengx 2017/05/30 19:37:02 Done.
+ // If the number of urls going to be displayed doesn't equal to the current
+ // one, the most visited items are considered to have changes.
+ // Otherwise, check if the current urls stored in |items| equal to the first
+ // |most_visited_items| urls in |urls| to determine if the most visited items
+ // are changed or not.
+
+ if (size_t(std::min(urls.size(), most_visited_items)) != items.size())
grt (UTC plus 2) 2017/05/30 08:51:41 urls.size() and most_visited_items are both size_t
chengx 2017/05/30 19:37:02 Yes, it should be removed.
+ return false;
+
+ return std::equal(std::begin(items), std::end(items), std::begin(urls),
+ [](const auto& item_ptr, const auto& most_visited_url) {
+ return item_ptr->url() == most_visited_url.url.spec();
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698