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

Side by Side Diff: chrome/browser/win/jumplist.cc

Issue 2848763002: Re-enable UMA metric WinJumplist.CreateIconFilesCount (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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/win/jumplist.h" 5 #include "chrome/browser/win/jumplist.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 for (auto& scale : supported_scales) { 108 for (auto& scale : supported_scales) {
109 gfx::ImageSkiaRep image_skia_rep = image_skia.GetRepresentation(scale); 109 gfx::ImageSkiaRep image_skia_rep = image_skia.GetRepresentation(scale);
110 if (!image_skia_rep.is_null()) 110 if (!image_skia_rep.is_null())
111 image_family.Add( 111 image_family.Add(
112 gfx::Image::CreateFrom1xBitmap(image_skia_rep.sk_bitmap())); 112 gfx::Image::CreateFrom1xBitmap(image_skia_rep.sk_bitmap()));
113 } 113 }
114 } 114 }
115 115
116 if (!IconUtil::CreateIconFileFromImageFamily(image_family, path, 116 if (!IconUtil::CreateIconFileFromImageFamily(image_family, path,
117 IconUtil::NORMAL_WRITE)) 117 IconUtil::NORMAL_WRITE))
118 return false; 118 return false;
grt (UTC plus 2) 2017/04/28 07:17:00 this will leak the temp file. should you not delet
chengx 2017/04/28 18:12:40 Yes, it should be deleted here right away rather t
119 119
120 // Add this icon file to the list and return its absolute path. 120 // Add this icon file to the list and return its absolute path.
121 // The IShellLink::SetIcon() function needs the absolute path to an icon. 121 // The IShellLink::SetIcon() function needs the absolute path to an icon.
122 *icon_path = path; 122 *icon_path = path;
123 return true; 123 return true;
124 } 124 }
125 125
126 // Helper method for RunUpdate to create icon files for the asynchrounously 126 // Helper method for RunUpdate to create icon files for the asynchrounously
127 // loaded icons. 127 // loaded icons.
128 void CreateIconFiles(const base::FilePath& icon_dir, 128 void CreateIconFiles(const base::FilePath& icon_dir,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 --user_max_items_adjusted; 233 --user_max_items_adjusted;
234 234
235 size_t most_visited_items = 235 size_t most_visited_items =
236 MulDiv(user_max_items_adjusted, kMostVisited, kTotal); 236 MulDiv(user_max_items_adjusted, kMostVisited, kTotal);
237 size_t recently_closed_items = user_max_items_adjusted - most_visited_items; 237 size_t recently_closed_items = user_max_items_adjusted - most_visited_items;
238 if (recently_closed_pages.size() < recently_closed_items) { 238 if (recently_closed_pages.size() < recently_closed_items) {
239 most_visited_items += recently_closed_items - recently_closed_pages.size(); 239 most_visited_items += recently_closed_items - recently_closed_pages.size();
240 recently_closed_items = recently_closed_pages.size(); 240 recently_closed_items = recently_closed_pages.size();
241 } 241 }
242 242
243 // Record the amout of icons created per JumpList update.
grt (UTC plus 2) 2017/04/28 07:17:00 nit: amount -> number
chengx 2017/04/28 18:12:40 Done.
244 int icons_created = 0;
245
243 if (most_visited_pages_have_updates) { 246 if (most_visited_pages_have_updates) {
244 // Delete the content in JumpListIconsMostVisited folder and log the results 247 // Delete the content in JumpListIconsMostVisited folder and log the results
245 // to UMA. 248 // to UMA.
246 base::FilePath icon_dir_most_visited = icon_dir.DirName().Append( 249 base::FilePath icon_dir_most_visited = icon_dir.DirName().Append(
247 icon_dir.BaseName().value() + FILE_PATH_LITERAL("MostVisited")); 250 icon_dir.BaseName().value() + FILE_PATH_LITERAL("MostVisited"));
248 251
249 DeleteDirectoryContentAndLogResults(icon_dir_most_visited, 252 DeleteDirectoryContentAndLogResults(icon_dir_most_visited,
250 kFileDeleteLimit); 253 kFileDeleteLimit);
251 254
252 // If the directory doesn't exist (we have tried to create it in 255 // If the directory doesn't exist (we have tried to create it in
253 // DeleteDirectoryContentAndLogResults) or is not empty, skip updating the 256 // DeleteDirectoryContentAndLogResults) or is not empty, skip updating the
254 // jumplist icons. The jumplist links should be updated anyway, as it 257 // jumplist icons. The jumplist links should be updated anyway, as it
255 // doesn't involve disk IO. In this case, Chrome's icon will be used for the 258 // doesn't involve disk IO. In this case, Chrome's icon will be used for the
256 // new links. 259 // new links.
257 if (base::DirectoryExists(icon_dir_most_visited) && 260 if (base::DirectoryExists(icon_dir_most_visited) &&
258 base::IsDirectoryEmpty(icon_dir_most_visited)) { 261 base::IsDirectoryEmpty(icon_dir_most_visited)) {
259 // Create icon files for shortcuts in the "Most Visited" category. 262 // Create icon files for shortcuts in the "Most Visited" category.
260 CreateIconFiles(icon_dir_most_visited, most_visited_pages, 263 CreateIconFiles(icon_dir_most_visited, most_visited_pages,
261 most_visited_items); 264 most_visited_items);
265
266 icons_created += std::min(most_visited_pages.size(), most_visited_items);
grt (UTC plus 2) 2017/04/28 07:17:00 is the intention to report the number of files suc
chengx 2017/04/28 18:12:40 Actually, I only care about the number of icons th
262 } 267 }
263 } 268 }
264 269
265 if (recently_closed_pages_have_updates) { 270 if (recently_closed_pages_have_updates) {
266 // Delete the content in JumpListIconsRecentClosed folder and log the 271 // Delete the content in JumpListIconsRecentClosed folder and log the
267 // results to UMA. 272 // results to UMA.
268 base::FilePath icon_dir_recent_closed = icon_dir.DirName().Append( 273 base::FilePath icon_dir_recent_closed = icon_dir.DirName().Append(
269 icon_dir.BaseName().value() + FILE_PATH_LITERAL("RecentClosed")); 274 icon_dir.BaseName().value() + FILE_PATH_LITERAL("RecentClosed"));
270 275
271 DeleteDirectoryContentAndLogResults(icon_dir_recent_closed, 276 DeleteDirectoryContentAndLogResults(icon_dir_recent_closed,
272 kFileDeleteLimit); 277 kFileDeleteLimit);
273 278
274 if (base::DirectoryExists(icon_dir_recent_closed) && 279 if (base::DirectoryExists(icon_dir_recent_closed) &&
275 base::IsDirectoryEmpty(icon_dir_recent_closed)) { 280 base::IsDirectoryEmpty(icon_dir_recent_closed)) {
276 // Create icon files for shortcuts in the "Recently Closed" category. 281 // Create icon files for shortcuts in the "Recently Closed" category.
277 CreateIconFiles(icon_dir_recent_closed, recently_closed_pages, 282 CreateIconFiles(icon_dir_recent_closed, recently_closed_pages,
278 recently_closed_items); 283 recently_closed_items);
284
285 icons_created +=
286 std::min(recently_closed_pages.size(), recently_closed_items);
279 } 287 }
280 } 288 }
281 289
282 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407. 290 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
291 UMA_HISTOGRAM_COUNTS_100("WinJumplist.CreateIconFilesCount", icons_created);
292
293 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
283 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration"); 294 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration");
284 295
285 // Update the "Most Visited" category of the JumpList if it exists. 296 // Update the "Most Visited" category of the JumpList if it exists.
286 // This update request is applied into the JumpList when we commit this 297 // This update request is applied into the JumpList when we commit this
287 // transaction. 298 // transaction.
288 if (!jumplist_updater.AddCustomCategory( 299 if (!jumplist_updater.AddCustomCategory(
289 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED), 300 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED),
290 most_visited_pages, most_visited_items)) { 301 most_visited_pages, most_visited_items)) {
291 return false; 302 return false;
292 } 303 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 712 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
702 } 713 }
703 714
704 void JumpList::TopSitesChanged(history::TopSites* top_sites, 715 void JumpList::TopSitesChanged(history::TopSites* top_sites,
705 ChangeReason change_reason) { 716 ChangeReason change_reason) {
706 top_sites->GetMostVisitedURLs( 717 top_sites->GetMostVisitedURLs(
707 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 718 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
708 weak_ptr_factory_.GetWeakPtr()), 719 weak_ptr_factory_.GetWeakPtr()),
709 false); 720 false);
710 } 721 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698