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

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

Issue 2907513002: [Code cleaning] Change hard-coded constants to predefined constant variables in JumpList (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 | no next file » | 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 "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 using content::BrowserThread; 54 using content::BrowserThread;
55 using JumpListData = JumpList::JumpListData; 55 using JumpListData = JumpList::JumpListData;
56 56
57 namespace { 57 namespace {
58 58
59 // The default maximum number of items to display in JumpList is 10. 59 // The default maximum number of items to display in JumpList is 10.
60 // https://msdn.microsoft.com/library/windows/desktop/dd378398.aspx 60 // https://msdn.microsoft.com/library/windows/desktop/dd378398.aspx
61 // The "Most visited" and "Recently closed" category titles always take 2 slots. 61 // The "Most visited" and "Recently closed" category titles always take 2 slots.
62 // For the remaining 8 slots, we allocate 5 slots to "most-visited" items and 3 62 // For the remaining 8 slots, we allocate 5 slots to "most-visited" items and 3
63 // slots to"recently-closed" items, respectively. 63 // slots to "recently-closed" items, respectively.
64 constexpr size_t kMostVisitedItems = 5; 64 constexpr size_t kMostVisitedItems = 5;
65 constexpr size_t kRecentlyClosedItems = 3; 65 constexpr size_t kRecentlyClosedItems = 3;
66 66
67 // The number of updates to skip to alleviate the machine when a previous update 67 // The number of updates to skip to alleviate the machine when a previous update
68 // was too slow. 68 // was too slow.
69 constexpr int kUpdatesToSkipUnderHeavyLoad = 10; 69 constexpr int kUpdatesToSkipUnderHeavyLoad = 10;
70 70
71 // The delay before updating the JumpList to prevent update storms. 71 // The delay before updating the JumpList to prevent update storms.
72 constexpr base::TimeDelta kDelayForJumplistUpdate = 72 constexpr base::TimeDelta kDelayForJumplistUpdate =
73 base::TimeDelta::FromMilliseconds(3500); 73 base::TimeDelta::FromMilliseconds(3500);
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 679
680 return icons_created; 680 return icons_created;
681 } 681 }
682 682
683 int JumpList::UpdateIconFiles(const base::FilePath& icon_dir, 683 int JumpList::UpdateIconFiles(const base::FilePath& icon_dir,
684 const ShellLinkItemList& page_list, 684 const ShellLinkItemList& page_list,
685 size_t slot_limit, 685 size_t slot_limit,
686 JumpListCategory category) { 686 JumpListCategory category) {
687 int icons_created = 0; 687 int icons_created = 0;
688 688
689 // Maximum number of icon files that each JumpList icon folder may hold. 689 // Maximum number of icon files that each JumpList icon folder may hold, which
690 size_t icon_limit = (category == JumpListCategory::kMostVisited) ? 10 : 6; 690 // is set to 2 times the normal amount.
691 size_t icon_limit =
692 2 * ((category == JumpListCategory::kMostVisited) ? kMostVisitedItems
693 : kRecentlyClosedItems);
691 694
692 // Clear the JumpList icon folder at |icon_dir| and the cache when 695 // Clear the JumpList icon folder at |icon_dir| and the cache when
693 // 1) "Most visited" category updates for the 1st time after Chrome is 696 // 1) "Most visited" category updates for the 1st time after Chrome is
694 // launched. This actually happens right after Chrome is launched. 697 // launched. This actually happens right after Chrome is launched.
695 // 2) "Recently closed" category updates for the 1st time after Chrome is 698 // 2) "Recently closed" category updates for the 1st time after Chrome is
696 // launched. 699 // launched.
697 // 3) The number of icons in |icon_dir| has exceeded the limit. 700 // 3) The number of icons in |icon_dir| has exceeded the limit.
698 if ((category == JumpListCategory::kMostVisited && 701 if ((category == JumpListCategory::kMostVisited &&
699 most_visited_icons_.empty()) || 702 most_visited_icons_.empty()) ||
700 (category == JumpListCategory::kRecentlyClosed && 703 (category == JumpListCategory::kRecentlyClosed &&
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 app_id, profile_dir, local_most_visited_pages, 859 app_id, profile_dir, local_most_visited_pages,
857 local_recently_closed_pages, most_visited_pages_have_updates, 860 local_recently_closed_pages, most_visited_pages_have_updates,
858 recently_closed_pages_have_updates, incognito_availability)) { 861 recently_closed_pages_have_updates, incognito_availability)) {
859 base::AutoLock auto_lock(data->list_lock_); 862 base::AutoLock auto_lock(data->list_lock_);
860 if (most_visited_pages_have_updates) 863 if (most_visited_pages_have_updates)
861 data->most_visited_pages_have_updates_ = true; 864 data->most_visited_pages_have_updates_ = true;
862 if (recently_closed_pages_have_updates) 865 if (recently_closed_pages_have_updates)
863 data->recently_closed_pages_have_updates_ = true; 866 data->recently_closed_pages_have_updates_ = true;
864 } 867 }
865 } 868 }
OLDNEW
« 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