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

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

Issue 2965973002: Remove delay for the first JumpList top site sync in one session (Closed)
Patch Set: Created 3 years, 5 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/jumplist.h ('k') | no next file » | 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 7ebb5eab0553e7be09175a4f82c941bac03e2de6..d6d5596bcfb398b568ccb39fbb82b380bb72ae52 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -275,8 +275,13 @@ void JumpList::TopSitesChanged(history::TopSites* top_sites,
// If we have a pending favicon request, cancel it here as it's out of date.
CancelPendingUpdate();
- // Initialize the one-shot timer to update the JumpList in a while.
- InitializeTimerForUpdate();
+ // When the first tab is closed in one session, it doesn't trigger an update
+ // but a TopSites sync. This sync will trigger an update for both mostly
+ // visited and recently closed categories. We don't delay this TopSites sync.
+ if (has_topsites_sync)
+ InitializeTimerForUpdate();
+ else
+ ProcessNotifications();
}
void JumpList::TabRestoreServiceChanged(sessions::TabRestoreService* service) {
@@ -312,12 +317,13 @@ void JumpList::InitializeTimerForUpdate() {
timer_.Reset();
} else {
// base::Unretained is safe since |this| is guaranteed to outlive timer_.
- timer_.Start(FROM_HERE, kDelayForJumplistUpdate,
- base::Bind(&JumpList::OnDelayTimer, base::Unretained(this)));
+ timer_.Start(
+ FROM_HERE, kDelayForJumplistUpdate,
+ base::Bind(&JumpList::ProcessNotifications, base::Unretained(this)));
}
}
-void JumpList::OnDelayTimer() {
+void JumpList::ProcessNotifications() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!update_in_progress_);
@@ -330,6 +336,17 @@ void JumpList::OnDelayTimer() {
if (tab_restore_has_pending_notification_) {
tab_restore_has_pending_notification_ = false;
ProcessTabRestoreServiceNotification();
+
+ // Force a TopSite history sync when closing a first tab in one session.
+ if (!has_tab_closed_) {
+ has_tab_closed_ = true;
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesFactory::GetForProfile(profile_);
+ if (top_sites) {
+ top_sites->SyncWithHistory();
+ return;
+ }
+ }
}
// If TopSites has updates, retrieve the URLs asynchronously, and on its
@@ -354,6 +371,8 @@ void JumpList::ProcessTopSitesNotification() {
return;
}
+ has_topsites_sync = true;
+
scoped_refptr<history::TopSites> top_sites =
TopSitesFactory::GetForProfile(profile_);
if (top_sites) {
@@ -400,15 +419,6 @@ void JumpList::ProcessTabRestoreServiceNotification() {
}
recently_closed_should_update_ = true;
-
- // Force a TopSite history sync when closing a first tab in one session.
- if (!has_tab_closed_) {
- has_tab_closed_ = true;
- scoped_refptr<history::TopSites> top_sites =
- TopSitesFactory::GetForProfile(profile_);
- if (top_sites)
- top_sites->SyncWithHistory();
- }
}
void JumpList::OnMostVisitedURLsAvailable(
« no previous file with comments | « chrome/browser/win/jumplist.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698