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

Unified Diff: chrome/browser/jumplist_win.cc

Issue 965503002: Filter out redundant jumplist updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed from ui to browser category Created 5 years, 6 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/jumplist_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « chrome/browser/jumplist_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698