Chromium Code Reviews| Index: chrome/browser/win/jumplist.cc |
| diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc |
| index 7ebb5eab0553e7be09175a4f82c941bac03e2de6..d5aeb2a04cbf90d08425d83706a638e6234710c5 100644 |
| --- a/chrome/browser/win/jumplist.cc |
| +++ b/chrome/browser/win/jumplist.cc |
| @@ -76,10 +76,10 @@ constexpr base::TimeDelta kDelayForJumplistUpdate = |
| constexpr base::TimeDelta kTimeOutForJumplistBeginUpdate = |
| base::TimeDelta::FromMilliseconds(500); |
| -// The maximum allowed time for updating both "most visited" and "recently |
| -// closed" categories via JumpListUpdater::AddCustomCategory. |
| +// The maximum allowed time for adding most visited pages custom category via |
| +// JumpListUpdater::AddCustomCategory. |
| constexpr base::TimeDelta kTimeOutForAddCustomCategory = |
| - base::TimeDelta::FromMilliseconds(500); |
| + base::TimeDelta::FromMilliseconds(300); |
| // The maximum allowed time for JumpListUpdater::CommitUpdate. |
| constexpr base::TimeDelta kTimeOutForJumplistCommitUpdate = |
| @@ -120,9 +120,10 @@ bool CreateIconFile(const gfx::ImageSkia& image_skia, |
| std::vector<float> supported_scales = image_skia.GetSupportedScales(); |
| for (auto& scale : supported_scales) { |
| gfx::ImageSkiaRep image_skia_rep = image_skia.GetRepresentation(scale); |
| - if (!image_skia_rep.is_null()) |
| + if (!image_skia_rep.is_null()) { |
| image_family.Add( |
| gfx::Image::CreateFrom1xBitmap(image_skia_rep.sk_bitmap())); |
| + } |
| } |
| } |
| @@ -704,17 +705,19 @@ void JumpList::CreateNewJumpListAndNotifyOS( |
| base::ElapsedTimer begin_update_timer; |
| - if (!jumplist_updater.BeginUpdate()) |
| - return; |
| + bool begin_success = jumplist_updater.BeginUpdate(); |
| - // Discard this JumpList update if JumpListUpdater::BeginUpdate takes longer |
| - // than the maximum allowed time, as it's very likely the following update |
| - // steps will also take a long time. |
| + // If JumpListUpdater::BeginUpdate takes longer than the maximum allowed time, |
| + // abort the current update as it's very likely the following steps will also |
| + // take a long time, and skip the next |kUpdatesToSkipUnderHeavyLoad| updates. |
| if (begin_update_timer.Elapsed() >= kTimeOutForJumplistBeginUpdate) { |
| update_transaction->update_timeout = true; |
| return; |
| } |
| + if (!begin_success) |
| + return; |
| + |
| // Record the desired number of icons created in this JumpList update. |
| int icons_created = 0; |
| @@ -747,12 +750,30 @@ void JumpList::CreateNewJumpListAndNotifyOS( |
| // Update the "Most Visited" category of the JumpList if it exists. |
| // This update request is applied into the JumpList when we commit this |
| // transaction. |
| - if (!jumplist_updater.AddCustomCategory( |
| - l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED), |
| - most_visited_pages, kMostVisitedItems)) { |
| + bool add_category_success = jumplist_updater.AddCustomCategory( |
| + l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED), most_visited_pages, |
| + kMostVisitedItems); |
| + |
| + // If AddCustomCategory takes longer than the maximum allowed time, abort the |
| + // current update and skip the next |kUpdatesToSkipUnderHeavyLoad| updates. |
| + // |
| + // We only time adding custom category for most visited pages because |
| + // 1. If processing the first category times out or fails, there is no need to |
|
grt (UTC plus 2)
2017/07/03 06:24:15
i understand why it makes sense to consider this a
chengx
2017/07/09 23:08:49
To answer your question, I landed crrev/2964873002
|
| + // process the second category. In this case, we are not able to time both |
| + // categories. Then we need to select one category from the two. |
| + // 2. Most visited category is selected because it always has 5 items, while |
|
grt (UTC plus 2)
2017/07/03 06:24:15
why doesn't a newish user have fewer than 5?
to v
chengx
2017/07/09 23:08:49
It does have fewer than 5 items. Then it should ta
|
| + // the number of items in recently closed category varies from 1 to 3. This |
| + // means the runtime of AddCustomCategory API should be fixed for most |
| + // visited category, but not for recently closed category. So a fixed |
| + // timeout threshold is only valid for most visited category. |
| + if (add_custom_category_timer.Elapsed() >= kTimeOutForAddCustomCategory) { |
| + update_transaction->update_timeout = true; |
| return; |
| } |
| + if (!add_category_success) |
| + return; |
| + |
| // Update the "Recently Closed" category of the JumpList. |
| if (!jumplist_updater.AddCustomCategory( |
| l10n_util::GetStringUTF16(IDS_RECENTLY_CLOSED), recently_closed_pages, |
| @@ -760,13 +781,6 @@ void JumpList::CreateNewJumpListAndNotifyOS( |
| return; |
| } |
| - // If AddCustomCategory takes longer than the maximum allowed time, abort the |
| - // current update and skip the next |kUpdatesToSkipUnderHeavyLoad| updates. |
| - if (add_custom_category_timer.Elapsed() >= kTimeOutForAddCustomCategory) { |
| - update_transaction->update_timeout = true; |
| - return; |
| - } |
| - |
| // Update the "Tasks" category of the JumpList. |
| if (!UpdateTaskCategory(&jumplist_updater, incognito_availability)) |
| return; |