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

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

Issue 2859193005: Cache JumpList icons to avoid unnecessary creation and deletion (Closed)
Patch Set: 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') | chrome/browser/win/jumplist.cc » ('J')
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 c4b6c857584430198509a89a08b224963d7fb3e0..125cd533a8e5a915ae5caecf0ea96eaf1f95eafd 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"
@@ -32,6 +33,8 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+enum JumpListCategory { MOST_VISITED = 0, RECENTLY_CLOSED };
grt (UTC plus 2) 2017/05/11 20:29:13 nit: Chromium no longer deviates from the Google s
grt (UTC plus 2) 2017/05/11 20:29:13 move this type into the "private:" section of the
grt (UTC plus 2) 2017/05/11 20:29:13 nit: "enum class"
chengx 2017/05/12 01:04:24 Done with moving to private section of the class.
chengx 2017/05/12 01:04:24 Done with changing names to kLikeAConstant alike.
chengx 2017/05/12 01:04:24 Done. Using "enum class" now.
+
namespace base {
class SingleThreadTaskRunner;
class SequencedTaskRunner;
@@ -179,17 +182,23 @@ class JumpList : public sessions::TabRestoreServiceObserver,
// after requests storms have subsided.
void DeferredTabRestoreServiceChanged();
+ // Deletes icon files 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 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 +225,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.
@@ -236,6 +245,11 @@ class JumpList : public sessions::TabRestoreServiceObserver,
// Holds data that can be accessed from multiple threads.
scoped_refptr<base::RefCountedData<JumpListData>> jumplist_data_;
+ // Cache of the mappings from JumpList items' URLs to icon file paths for
+ // "Most visited" and "Recently closed" categories, respectively.
+ base::flat_map<std::string, base::FilePath> most_visited_map_;
+ base::flat_map<std::string, base::FilePath> recently_closed_map_;
+
// 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') | chrome/browser/win/jumplist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698