Index: chrome/browser/jumplist_win.cc |
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc |
index f1e8a879b115547292fa55884733de91cb83c669..bed6653d6f79b919a736f456698aa8133528ba42 100644 |
--- a/chrome/browser/jumplist_win.cc |
+++ b/chrome/browser/jumplist_win.cc |
@@ -13,6 +13,7 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/threading/thread.h" |
+#include "base/trace_event/trace_event.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/favicon/favicon_service_factory.h" |
#include "chrome/browser/history/top_sites_factory.h" |
@@ -46,6 +47,9 @@ using content::BrowserThread; |
namespace { |
+// Delay jumplist updates to allow collapsing of redundant update requests. |
+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,23 @@ void JumpList::OnIncognitoAvailabilityChanged() { |
} |
void JumpList::PostRunUpdate() { |
+ TRACE_EVENT0("browser", "JumpList::PostRunUpdate"); |
+ // 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()) { |
+ timer_.Reset(); |
+ } else { |
+ timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromMilliseconds(kDelayForJumplistUpdateInMS), |
+ this, |
+ &JumpList::DeferredRunUpdate); |
+ } |
+} |
+ |
+void JumpList::DeferredRunUpdate() { |
+ TRACE_EVENT0("browser", "JumpList::DeferredRunUpdate"); |
// Check if incognito windows (or normal windows) are disabled by policy. |
IncognitoModePrefs::Availability incognito_availability = |
profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) |