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

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

Issue 2816113002: Fix to not create jumplist icon files that aren't used by shell (Closed)
Patch Set: Update UMA histogram function's position to make it more accurate Created 3 years, 8 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 96fe9d399775c45b81e874a9ee812f7519dd513d..06f28709f7b67eb2120e17e425e11c6f8da9b0ab 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -120,12 +120,13 @@ bool CreateIconFile(const gfx::ImageSkia& image_skia,
// Helper method for RunUpdate to create icon files for the asynchrounously
// loaded icons.
void CreateIconFiles(const base::FilePath& icon_dir,
- const ShellLinkItemList& item_list) {
+ const ShellLinkItemList& item_list,
+ size_t max_items) {
// TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.CreateIconFilesDuration");
for (ShellLinkItemList::const_iterator item = item_list.begin();
- item != item_list.end(); ++item) {
+ item != item_list.end() && max_items > 0; ++item, --max_items) {
base::FilePath icon_path;
if (CreateIconFile((*item)->icon_image(), icon_dir, &icon_path))
(*item)->set_icon(icon_path.value(), 0);
@@ -177,12 +178,10 @@ bool UpdateTaskCategory(
// Updates the application JumpList.
bool UpdateJumpList(const wchar_t* app_id,
+ const base::FilePath& icon_dir,
const ShellLinkItemList& most_visited_pages,
const ShellLinkItemList& recently_closed_pages,
IncognitoModePrefs::Availability incognito_availability) {
- // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
- SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration");
-
// JumpList is implemented only on Windows 7 or later.
// So, we should return now when this function is called on earlier versions
// of Windows.
@@ -209,6 +208,27 @@ bool UpdateJumpList(const wchar_t* app_id,
recently_closed_items = recently_closed_pages.size();
}
+ // If JumpListIcons directory doesn't exist (we have tried to create it
+ // already) or is not empty, skip updating the jumplist icons. The jumplist
+ // links should be updated anyway, as it doesn't involve disk IO. In this
+ // case, Chrome's icon will be used for the new links.
+
+ if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) {
+ // TODO(chengx): Remove this UMA metric after fixing http://crbug.com/40407.
+ UMA_HISTOGRAM_COUNTS_100(
+ "WinJumplist.CreateIconFilesCount",
+ most_visited_pages.size() + recently_closed_pages.size());
+
+ // Create icon files for shortcuts in the "Most Visited" category.
+ CreateIconFiles(icon_dir, most_visited_pages, most_visited_items);
+
+ // Create icon files for shortcuts in the "Recently Closed" category.
+ CreateIconFiles(icon_dir, recently_closed_pages, recently_closed_items);
+ }
+
+ // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
+ SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration");
gab 2017/04/18 19:21:11 This changed the timing of this histogram without
chengx 2017/04/18 19:31:47 I am now heavily using version filters (thanks for
+
// Update the "Most Visited" category of the JumpList if it exists.
// This update request is applied into the JumpList when we commit this
// transaction.
@@ -257,28 +277,10 @@ void RunUpdateJumpList(IncognitoModePrefs::Availability incognito_availability,
local_recently_closed_pages = data->recently_closed_pages_;
}
- // If JumpListIcons directory doesn't exist or is not empty, skip updating the
- // jumplist icons. The jumplist links should be updated anyway, as it doesn't
- // involve disk IO.
- if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) {
- // TODO(chengx): Remove the UMA histogram after fixing
- // http://crbug.com/40407.
- UMA_HISTOGRAM_COUNTS_100(
- "WinJumplist.CreateIconFilesCount",
- local_most_visited_pages.size() + local_recently_closed_pages.size());
-
- // Create icon files for shortcuts in the "Most Visited" category.
- CreateIconFiles(icon_dir, local_most_visited_pages);
-
- // Create icon files for shortcuts in the "Recently Closed"
- // category.
- CreateIconFiles(icon_dir, local_recently_closed_pages);
- }
-
// Create a new JumpList and replace the current JumpList with it. The
// jumplist links are updated anyway, while the jumplist icons may not as
// mentioned above.
- UpdateJumpList(app_id.c_str(), local_most_visited_pages,
+ UpdateJumpList(app_id.c_str(), icon_dir, local_most_visited_pages,
local_recently_closed_pages, incognito_availability);
}
« 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