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

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

Issue 2848763002: Re-enable UMA metric WinJumplist.CreateIconFilesCount (Closed)
Patch Set: Address comments 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 222 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 number of icons created per JumpList update.
grt (UTC plus 2) 2017/05/01 08:44:38 nit: // Record the desired number of icons to cr
chengx 2017/05/01 18:08:22 Done.
244 int icons_to_create = 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_to_create +=
267 std::min(most_visited_pages.size(), most_visited_items);
262 } 268 }
263 } 269 }
264 270
265 if (recently_closed_pages_have_updates) { 271 if (recently_closed_pages_have_updates) {
266 // Delete the content in JumpListIconsRecentClosed folder and log the 272 // Delete the content in JumpListIconsRecentClosed folder and log the
267 // results to UMA. 273 // results to UMA.
268 base::FilePath icon_dir_recent_closed = icon_dir.DirName().Append( 274 base::FilePath icon_dir_recent_closed = icon_dir.DirName().Append(
269 icon_dir.BaseName().value() + FILE_PATH_LITERAL("RecentClosed")); 275 icon_dir.BaseName().value() + FILE_PATH_LITERAL("RecentClosed"));
270 276
271 DeleteDirectoryContentAndLogResults(icon_dir_recent_closed, 277 DeleteDirectoryContentAndLogResults(icon_dir_recent_closed,
272 kFileDeleteLimit); 278 kFileDeleteLimit);
273 279
274 if (base::DirectoryExists(icon_dir_recent_closed) && 280 if (base::DirectoryExists(icon_dir_recent_closed) &&
275 base::IsDirectoryEmpty(icon_dir_recent_closed)) { 281 base::IsDirectoryEmpty(icon_dir_recent_closed)) {
276 // Create icon files for shortcuts in the "Recently Closed" category. 282 // Create icon files for shortcuts in the "Recently Closed" category.
277 CreateIconFiles(icon_dir_recent_closed, recently_closed_pages, 283 CreateIconFiles(icon_dir_recent_closed, recently_closed_pages,
278 recently_closed_items); 284 recently_closed_items);
285
286 icons_to_create +=
287 std::min(recently_closed_pages.size(), recently_closed_items);
279 } 288 }
280 } 289 }
281 290
282 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407. 291 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
292 UMA_HISTOGRAM_COUNTS_100("WinJumplist.CreateIconFilesCount", icons_to_create);
293
294 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
283 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration"); 295 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration");
284 296
285 // Update the "Most Visited" category of the JumpList if it exists. 297 // Update the "Most Visited" category of the JumpList if it exists.
286 // This update request is applied into the JumpList when we commit this 298 // This update request is applied into the JumpList when we commit this
287 // transaction. 299 // transaction.
288 if (!jumplist_updater.AddCustomCategory( 300 if (!jumplist_updater.AddCustomCategory(
289 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED), 301 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED),
290 most_visited_pages, most_visited_items)) { 302 most_visited_pages, most_visited_items)) {
291 return false; 303 return false;
292 } 304 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 713 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
702 } 714 }
703 715
704 void JumpList::TopSitesChanged(history::TopSites* top_sites, 716 void JumpList::TopSitesChanged(history::TopSites* top_sites,
705 ChangeReason change_reason) { 717 ChangeReason change_reason) {
706 top_sites->GetMostVisitedURLs( 718 top_sites->GetMostVisitedURLs(
707 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 719 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
708 weak_ptr_factory_.GetWeakPtr()), 720 weak_ptr_factory_.GetWeakPtr()),
709 false); 721 false);
710 } 722 }
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