Chromium Code Reviews| Index: chrome/browser/win/jumplist.h |
| diff --git a/chrome/browser/win/jumplist.h b/chrome/browser/win/jumplist.h |
| index da68edb72389eae8bb66f5815718e52dede17143..106273f0c013d38d0ece1aae40cec22914b7bf70 100644 |
| --- a/chrome/browser/win/jumplist.h |
| +++ b/chrome/browser/win/jumplist.h |
| @@ -68,8 +68,11 @@ class JumpList : public sessions::TabRestoreServiceObserver, |
| void Shutdown() override; |
| private: |
| + enum class JumpListVersion { kCurrent, kNext, kShared }; |
|
grt (UTC plus 2)
2017/06/21 10:57:29
// Indicates whether a JumpList icon file is used
chengx
2017/06/22 22:45:06
I've removed this enum class as it's no longer nee
|
| + |
| using UrlAndLinkItem = std::pair<std::string, scoped_refptr<ShellLinkItem>>; |
| using URLIconCache = base::flat_map<std::string, base::FilePath>; |
|
grt (UTC plus 2)
2017/06/21 10:57:29
rather than introducing another container to hold
chengx
2017/06/22 22:45:06
Done. After a second thought, I think using the or
|
| + using IconAssociation = base::flat_map<base::FilePath, JumpListVersion>; |
| // Holds results of the RunUpdateJumpList run. |
| struct UpdateResults { |
| @@ -80,13 +83,26 @@ class JumpList : public sessions::TabRestoreServiceObserver, |
| // Holding a copy of most_visited_icons_ initially, it's updated by the |
| // JumpList update run. If the update run succeeds, it overwrites |
| // most_visited_icons_. |
| - URLIconCache most_visited_icons_in_update; |
| + URLIconCache most_visited_icons; |
| - // icon file paths of the recently closed links, indexed by tab url. |
| + // Icon file paths of the recently closed links, indexed by tab url. |
| // Holding a copy of recently_closed_icons_ initially, it's updated by the |
| // JumpList update run. If the update run succeeds, it overwrites |
| // recently_closed_icons_. |
| - URLIconCache recently_closed_icons_in_update; |
| + URLIconCache recently_closed_icons; |
| + |
| + // The association of icon files in most visited category with the JumpList |
| + // versions, defined in enum JumpListVersion. Holding a copy of |
| + // most_visited_icon_assoc_ initially, it's updated by the JumpList update |
| + // run. If the update run succeeds, it overwrites most_visited_icon_assoc_. |
| + IconAssociation most_visited_icon_assoc; |
| + |
| + // The association of icon files in recently closed category with the |
| + // JumpList versions, defined in enum JumpListVersion. Holding a copy of |
| + // recently_closed_icon_assoc_ initially, it's updated by the JumpList |
| + // update run. If the update run succeeds, it overwrites |
| + // recently_closed_icon_assoc_. |
| + IconAssociation recently_closed_icon_assoc; |
| // A flag indicating if a JumpList update run is successful. |
| bool update_success = false; |
| @@ -163,8 +179,11 @@ class JumpList : public sessions::TabRestoreServiceObserver, |
| // Callback for RunUpdateJumpList that notifies when it finishes running. |
| // Updates certain JumpList member variables and/or triggers a new JumpList |
| - // update based on |update_results|. |
| - void OnRunUpdateCompletion(std::unique_ptr<UpdateResults> update_results); |
| + // update based on |update_results|, the flags |most_visited_should_update| |
| + // and |recently_closed_should_update|. |
| + void OnRunUpdateCompletion(std::unique_ptr<UpdateResults> update_results, |
| + bool most_visited_should_update, |
| + bool recently_closed_should_update); |
| // Cancels a pending JumpList update. |
| void CancelPendingUpdate(); |
| @@ -175,7 +194,7 @@ class JumpList : public sessions::TabRestoreServiceObserver, |
| void Terminate(); |
| // Updates the application JumpList, which consists of 1) create new icon |
| - // files; 2) delete obsolete icon files; 3) notify the OS. |
| + // files; 2) notify the OS; 2) delete obsolete icon files. |
| // Note that any timeout error along the way results in the old JumpList being |
| // left as-is, while any non-timeout error results in the old JumpList being |
| // left as-is, but without icon files. |
| @@ -184,32 +203,57 @@ class JumpList : public sessions::TabRestoreServiceObserver, |
| const base::FilePath& profile_dir, |
| const ShellLinkItemList& most_visited_pages, |
| const ShellLinkItemList& recently_closed_pages, |
| - bool most_visited_pages_have_updates, |
| - bool recently_closed_pages_have_updates, |
| + bool most_visited_should_update, |
| + bool recently_closed_should_update, |
| IncognitoModePrefs::Availability incognito_availability, |
| UpdateResults* update_results); |
| // Updates icon files for |page_list| in |icon_dir|, which consists of |
| - // 1) creating at most |slot_limit| new icons which are not in |icon_cache|; |
| - // 2) deleting old icons which are not in |icon_cache|. |
| - // Returns the number of new icon files created. |
| - static int UpdateIconFiles(const base::FilePath& icon_dir, |
| - const ShellLinkItemList& page_list, |
| - size_t slot_limit, |
| - URLIconCache* icon_cache); |
| + // 1) If certain safe conditions are not met, clean the folder at |icon_dir|. |
| + // If folder cleaning fails, skip step 2. Besides, clear |icon_assoc|, |
| + // |icon_cur| and |icon_next|. |
| + // 2) Create at most |max_items| icon files which are not in |icon_cur| for |
| + // the asynchrounously loaded icons stored in |item_list|. |icon_assoc| and |
| + // |icon_next| are updated based on the reusable icons in |icon_cur| and the |
| + // newly created icons. Returns the number of new icon files created. |
| + static int SafeCreateIconFiles(const base::FilePath& icon_dir, |
| + const ShellLinkItemList& page_list, |
| + size_t slot_limit, |
| + IconAssociation* icon_assoc, |
| + URLIconCache* icon_cur, |
| + URLIconCache* icon_next); |
| // In |icon_dir|, creates at most |max_items| icon files which are not in |
| - // |icon_cache| for the asynchrounously loaded icons stored in |item_list|. |
| - // |icon_cache| is also updated for newly created icons. |
| - // Returns the number of new icon files created. |
| + // |icon_cur| for the asynchrounously loaded icons stored in |item_list|. |
| + // |icon_assoc| and |icon_next| are updated based on the reusable icons in |
| + // |icon_cur| and the newly created icons. Returns the number of new icon |
| + // files created. |
| static int CreateIconFiles(const base::FilePath& icon_dir, |
| const ShellLinkItemList& item_list, |
| size_t max_items, |
| - URLIconCache* icon_cache); |
| - |
| - // Deletes icon files in |icon_dir| which are not in |icon_cache| anymore. |
| + IconAssociation* icon_assoc, |
| + URLIconCache* icon_cur, |
| + URLIconCache* icon_next); |
| + |
| + // Deletes icon files which are associated with JumpList |version|, based on |
| + // the JumpList version and icon association information stored in |
| + // |update_results|. Icons in |most_visited_icon_dir| are processed if |
| + // |most_visited_should_update| is true. Icons in |recently_closed_icon_dir| |
| + // are processed if |recently_closed_should_update| is true. |
| + static void DeleteIconFilesUnified( |
| + bool most_visited_should_update, |
| + bool recently_closed_should_update, |
| + const base::FilePath& most_visited_icon_dir, |
| + const base::FilePath& recently_closed_icon_dir, |
| + UpdateResults* update_results, |
| + JumpListVersion version); |
| + |
| + // Deletes icon files in |icon_dir| which are associated with JumpList |
| + // |version|, based on the |icon_assoc| which records the association of |
| + // icons and JumpList versions. |
| static void DeleteIconFiles(const base::FilePath& icon_dir, |
| - URLIconCache* icon_cache); |
| + IconAssociation* icon_assoc, |
| + JumpListVersion version); |
| // Tracks FaviconService tasks. |
| base::CancelableTaskTracker cancelable_task_tracker_; |
| @@ -241,6 +285,14 @@ class JumpList : public sessions::TabRestoreServiceObserver, |
| // The icon file paths of the recently closed links, indexed by tab url. |
| URLIconCache recently_closed_icons_; |
| + // The association of icon files in most visited category with the JumpList |
| + // versions, defined in enum JumpListVersion. |
| + IconAssociation most_visited_icon_assoc_; |
| + |
| + // The association of icon files in recently closed category with the JumpList |
| + // versions, defined in enum JumpListVersion. |
| + IconAssociation recently_closed_icon_assoc_; |
| + |
| // A flag indicating if TopSites service has notifications. |
| bool top_sites_has_pending_notification_ = false; |