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

Unified Diff: chrome/browser/win/jumplist.cc

Issue 2831433003: Time out jumplist update for very slow or busy OS (Closed)
Patch Set: Mark retired metrics obsolete in histograms.xml Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/win/OWNERS ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist.cc
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc
index 461c5a4a45b5371c7c64ff66d79060b35a5c7bdd..7642498752ea436cdfdff3b3c6f6186e4da70ab9 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -20,6 +20,7 @@
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
+#include "base/timer/elapsed_timer.h"
#include "base/trace_event/trace_event.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
@@ -64,7 +65,12 @@ using JumpListData = JumpList::JumpListData;
namespace {
// Delay jumplist updates to allow collapsing of redundant update requests.
-const int kDelayForJumplistUpdateInMS = 3500;
+constexpr base::TimeDelta kDelayForJumplistUpdateInMS =
grt (UTC plus 2) 2017/04/21 10:11:25 remove "InMS" since this is a TimeDelta (as i prop
chengx 2017/04/21 18:51:20 Done.
+ base::TimeDelta::FromMilliseconds(3500);
+
+// Timeout jumplist updates for users with extremely slow OS.
+constexpr base::TimeDelta kTimeOutForJumplistUpdateInMS =
+ base::TimeDelta::FromMilliseconds(500);
// Append the common switches to each shell link.
void AppendCommonSwitches(ShellLinkItem* shell_link) {
@@ -188,10 +194,18 @@ bool UpdateJumpList(const wchar_t* app_id,
if (!JumpListUpdater::IsEnabled())
return true;
+ // Records the time cost of starting a JumpListUpdater.
+ base::ElapsedTimer begin_update_timer;
+
JumpListUpdater jumplist_updater(app_id);
if (!jumplist_updater.BeginUpdate())
return false;
+ // Stops jumplist update if JumpListUpdater's start times out, as it's very
+ // likely the following update steps will also take a long time.
+ if (begin_update_timer.Elapsed() >= kTimeOutForJumplistUpdateInMS)
+ return false;
+
// We allocate 60% of the given JumpList slots to "most-visited" items
// and 40% to "recently-closed" items, respectively.
// Nevertheless, if there are not so many items in |recently_closed_pages|,
@@ -218,22 +232,13 @@ bool UpdateJumpList(const wchar_t* app_id,
// links should be updated anyway, as it doesn't involve disk IO. In this
// case, Chrome's icon will be used for the new links.
- if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) {
- // TODO(chengx): Remove this UMA metric after fixing http://crbug.com/40407.
- UMA_HISTOGRAM_COUNTS_100(
- "WinJumplist.CreateIconFilesCount",
- most_visited_pages.size() + recently_closed_pages.size());
+ bool is_dir_existed_and_empty =
grt (UTC plus 2) 2017/04/21 10:11:25 is_dir_existed_and_empty -> should_create_icons
chengx 2017/04/21 18:51:20 Done.
+ base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir);
- // Create icon files for shortcuts in the "Most Visited" category.
+ // Create icon files for shortcuts in the "Most Visited" category.
+ if (is_dir_existed_and_empty)
CreateIconFiles(icon_dir, most_visited_pages, most_visited_items);
- // Create icon files for shortcuts in the "Recently Closed" category.
- CreateIconFiles(icon_dir, recently_closed_pages, recently_closed_items);
- }
-
- // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
- SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration");
-
// Update the "Most Visited" category of the JumpList if it exists.
// This update request is applied into the JumpList when we commit this
// transaction.
@@ -243,6 +248,10 @@ bool UpdateJumpList(const wchar_t* app_id,
return false;
}
+ // Create icon files for shortcuts in the "Recently Closed" category.
+ if (is_dir_existed_and_empty)
+ CreateIconFiles(icon_dir, recently_closed_pages, recently_closed_items);
+
// Update the "Recently Closed" category of the JumpList.
if (!jumplist_updater.AddCustomCategory(
l10n_util::GetStringUTF16(IDS_RECENTLY_CLOSED),
@@ -595,9 +604,7 @@ void JumpList::PostRunUpdate() {
if (timer_.IsRunning()) {
timer_.Reset();
} else {
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kDelayForJumplistUpdateInMS),
- this,
+ timer_.Start(FROM_HERE, kDelayForJumplistUpdateInMS, this,
&JumpList::DeferredRunUpdate);
}
}
« no previous file with comments | « chrome/browser/win/OWNERS ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698