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

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

Issue 2859193005: Cache JumpList icons to avoid unnecessary creation and deletion (Closed)
Patch Set: Fix nits. 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 | chrome/browser/win/jumplist.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist.h
diff --git a/chrome/browser/win/jumplist.h b/chrome/browser/win/jumplist.h
index f85400e2a9cf2cb84fc659dbac83d1fe733d9365..a174654b1e94de9cfb0181d182849b510a17d3c7 100644
--- a/chrome/browser/win/jumplist.h
+++ b/chrome/browser/win/jumplist.h
@@ -12,6 +12,7 @@
#include <string>
#include <utility>
+#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -128,6 +129,8 @@ class JumpList : public sessions::TabRestoreServiceObserver,
explicit JumpList(Profile* profile); // Use JumpListFactory instead
~JumpList() override;
+ enum class JumpListCategory { kMostVisited, kRecentlyClosed };
+
// Adds a new ShellLinkItem for |tab| to |data| provided that doing so will
// not exceed |max_items|.
bool AddTab(const sessions::TabRestoreService::Tab& tab,
@@ -179,17 +182,24 @@ class JumpList : public sessions::TabRestoreServiceObserver,
// after requests storms have subsided.
void DeferredTabRestoreServiceChanged();
- // Creates at most |max_items| icon files in |icon_dir| for the
+ // Deletes icon files of |category| in |icon_dir| which are not in the cache
+ // anymore.
+ void DeleteIconFiles(const base::FilePath& icon_dir,
+ JumpListCategory category);
+
+ // Creates at most |max_items| icon files of |category| in |icon_dir| for the
// asynchrounously loaded icons stored in |item_list|.
void CreateIconFiles(const base::FilePath& icon_dir,
const ShellLinkItemList& item_list,
- size_t max_items);
+ size_t max_items,
+ JumpListCategory category);
// Updates icon files in |icon_dir|, which includes deleting old icons and
// creating at most |slot_limit| new icons for |page_list|.
void UpdateIconFiles(const base::FilePath& icon_dir,
const ShellLinkItemList& page_list,
- size_t slot_limit);
+ size_t slot_limit,
+ JumpListCategory category);
// Updates the jumplist, once all the data has been fetched. This method calls
// UpdateJumpList() to do most of the work.
@@ -216,7 +226,7 @@ class JumpList : public sessions::TabRestoreServiceObserver,
// Tracks FaviconService tasks.
base::CancelableTaskTracker cancelable_task_tracker_;
- // The Profile object is used to listen for events
+ // The Profile object is used to listen for events.
Profile* profile_;
// Lives on the UI thread.
@@ -240,6 +250,12 @@ class JumpList : public sessions::TabRestoreServiceObserver,
// Holds data that can be accessed from multiple threads.
scoped_refptr<base::RefCountedData<JumpListData>> jumplist_data_;
+ // The icon file paths of the most visited links and the recently closed links
+ // in the current jumplist, indexed by tab url, respectively.
+ // They may only be accessed on update_jumplist_task_runner_.
+ base::flat_map<std::string, base::FilePath> most_visited_icons_;
+ base::flat_map<std::string, base::FilePath> recently_closed_icons_;
+
// Id of last favicon task. It's used to cancel current task if a new one
// comes in before it finishes.
base::CancelableTaskTracker::TaskId task_id_;
« no previous file with comments | « no previous file | chrome/browser/win/jumplist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698