Index: chrome/browser/jumplist_win.cc |
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc |
index f1e8a879b115547292fa55884733de91cb83c669..9f83cf981d04cd7f301494d4a93555079b503a18 100644 |
--- a/chrome/browser/jumplist_win.cc |
+++ b/chrome/browser/jumplist_win.cc |
@@ -46,6 +46,10 @@ using content::BrowserThread; |
namespace { |
+// Delay jumplist update tasks to allow collapsing of redundant |
+// update requests. |
gab
2015/06/03 19:03:50
Looks like "update" fits on previous line.
brucedawson
2015/06/04 17:11:59
Done.
|
+const int kDelayForJumplistUpdateInMS = 3500; |
+ |
// Append the common switches to each shell link. |
void AppendCommonSwitches(ShellLinkItem* shell_link) { |
const char* kSwitchNames[] = { switches::kUserDataDir }; |
@@ -440,6 +444,21 @@ void JumpList::OnIncognitoAvailabilityChanged() { |
} |
void JumpList::PostRunUpdate() { |
+ |
gab
2015/06/03 19:03:50
No empty line.
brucedawson
2015/06/04 17:11:59
Done.
|
+ // Initialize the one-shot timer to update the jumplists in a while. |
+ // If there is already a request queued then cancel it and post the new |
+ // request. This ensures that JumpListUpdates won't happen until there has |
+ // been a brief quiet period, thus avoiding update storms. |
+ if (timer_.IsRunning()) |
gab
2015/06/03 19:03:50
{}s everywhere since the else's body is multiline.
brucedawson
2015/06/04 17:11:59
Done.
|
+ timer_.Reset(); |
+ else |
+ timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromMilliseconds(kDelayForJumplistUpdateInMS), |
+ this, |
+ &JumpList::DeferredRunUpdate); |
+} |
+ |
+void JumpList::DeferredRunUpdate() { |
// Check if incognito windows (or normal windows) are disabled by policy. |
IncognitoModePrefs::Availability incognito_availability = |
profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) |