Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 | 746 |
| 747 // Update the "Most Visited" category of the JumpList if it exists. | 747 // Update the "Most Visited" category of the JumpList if it exists. |
| 748 // This update request is applied into the JumpList when we commit this | 748 // This update request is applied into the JumpList when we commit this |
| 749 // transaction. | 749 // transaction. |
| 750 if (!jumplist_updater.AddCustomCategory( | 750 if (!jumplist_updater.AddCustomCategory( |
| 751 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED), | 751 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED), |
| 752 most_visited_pages, kMostVisitedItems)) { | 752 most_visited_pages, kMostVisitedItems)) { |
| 753 return; | 753 return; |
| 754 } | 754 } |
| 755 | 755 |
| 756 base::TimeDelta most_visited_category_time = | |
| 757 add_custom_category_timer.Elapsed(); | |
| 758 | |
| 756 // Update the "Recently Closed" category of the JumpList. | 759 // Update the "Recently Closed" category of the JumpList. |
| 757 if (!jumplist_updater.AddCustomCategory( | 760 if (!jumplist_updater.AddCustomCategory( |
| 758 l10n_util::GetStringUTF16(IDS_RECENTLY_CLOSED), recently_closed_pages, | 761 l10n_util::GetStringUTF16(IDS_RECENTLY_CLOSED), recently_closed_pages, |
| 759 kRecentlyClosedItems)) { | 762 kRecentlyClosedItems)) { |
| 760 return; | 763 return; |
| 761 } | 764 } |
| 762 | 765 |
| 766 base::TimeDelta add_category_total_time = add_custom_category_timer.Elapsed(); | |
| 767 | |
| 768 double most_visited_over_recently_closed = | |
| 769 most_visited_category_time.InMillisecondsF() / | |
| 770 (add_category_total_time - most_visited_category_time).InMillisecondsF(); | |
|
Ilya Sherman
2017/07/04 03:41:19
nit: Mebbe move this into the if-stmt?
chengx
2017/07/04 06:02:16
Done.
| |
| 771 | |
| 772 if (recently_closed_pages.size() == kRecentlyClosedItems && | |
| 773 most_visited_pages.size() == kMostVisitedItems) { | |
| 774 // TODO(chengx): Remove the UMA histogram after fixing crbug/736530. | |
| 775 UMA_HISTOGRAM_COUNTS_100("WinJumplist.AddCategoryTimeComparison", | |
| 776 (int)(most_visited_over_recently_closed * 10)); | |
|
Ilya Sherman
2017/07/04 03:41:19
Why are you multiplying by 10? It's not clear to
chengx
2017/07/04 06:02:16
The ration is typically between 1 and 10. I multip
| |
| 777 } | |
| 778 | |
| 763 // If AddCustomCategory takes longer than the maximum allowed time, abort the | 779 // If AddCustomCategory takes longer than the maximum allowed time, abort the |
| 764 // current update and skip the next |kUpdatesToSkipUnderHeavyLoad| updates. | 780 // current update and skip the next |kUpdatesToSkipUnderHeavyLoad| updates. |
| 765 if (add_custom_category_timer.Elapsed() >= kTimeOutForAddCustomCategory) { | 781 if (add_category_total_time >= kTimeOutForAddCustomCategory) { |
| 766 update_transaction->update_timeout = true; | 782 update_transaction->update_timeout = true; |
| 767 return; | 783 return; |
| 768 } | 784 } |
| 769 | 785 |
| 770 // Update the "Tasks" category of the JumpList. | 786 // Update the "Tasks" category of the JumpList. |
| 771 if (!UpdateTaskCategory(&jumplist_updater, incognito_availability)) | 787 if (!UpdateTaskCategory(&jumplist_updater, incognito_availability)) |
| 772 return; | 788 return; |
| 773 | 789 |
| 774 base::ElapsedTimer commit_update_timer; | 790 base::ElapsedTimer commit_update_timer; |
| 775 | 791 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 const URLIconCache& icons_cache) { | 879 const URLIconCache& icons_cache) { |
| 864 // Put all cached icon file paths into a set. | 880 // Put all cached icon file paths into a set. |
| 865 base::flat_set<base::FilePath> cached_files; | 881 base::flat_set<base::FilePath> cached_files; |
| 866 cached_files.reserve(icons_cache.size()); | 882 cached_files.reserve(icons_cache.size()); |
| 867 | 883 |
| 868 for (const auto& url_path_pair : icons_cache) | 884 for (const auto& url_path_pair : icons_cache) |
| 869 cached_files.insert(url_path_pair.second); | 885 cached_files.insert(url_path_pair.second); |
| 870 | 886 |
| 871 DeleteNonCachedFiles(icon_dir, cached_files); | 887 DeleteNonCachedFiles(icon_dir, cached_files); |
| 872 } | 888 } |
| OLD | NEW |