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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 81923003: sync: add garbage collection to SessionsSyncManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index a090075a215c939d7009ce103fb62c35824d85d9..43d77205ee4509a827349748f3a09f5f7f9b5145 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -362,12 +362,8 @@ void ProfileSyncService::RegisterDataTypeController(
browser_sync::SessionModelAssociator*
ProfileSyncService::GetSessionModelAssociatorDeprecated() {
- if (data_type_controllers_.find(syncer::SESSIONS) ==
- data_type_controllers_.end() ||
- data_type_controllers_.find(syncer::SESSIONS)->second->state() !=
- DataTypeController::RUNNING) {
+ if (!IsSessionsDataTypeControllerRunning())
return NULL;
- }
// If we're using sessions V2, there's no model associator.
if (sessions_sync_manager_.get())
@@ -378,13 +374,16 @@ browser_sync::SessionModelAssociator*
syncer::SESSIONS)->second.get())->GetModelAssociator();
}
+bool ProfileSyncService::IsSessionsDataTypeControllerRunning() const {
+ return data_type_controllers_.find(syncer::SESSIONS) !=
+ data_type_controllers_.end() &&
+ data_type_controllers_.find(syncer::SESSIONS)->second->state() ==
+ DataTypeController::RUNNING;
+}
+
browser_sync::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() {
- if (data_type_controllers_.find(syncer::SESSIONS) ==
- data_type_controllers_.end() ||
- data_type_controllers_.find(syncer::SESSIONS)->second->state() !=
- DataTypeController::RUNNING) {
+ if (!IsSessionsDataTypeControllerRunning())
return NULL;
- }
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSyncSessionsV2)) {
@@ -1066,15 +1065,19 @@ void ProfileSyncService::OnBackendInitialized(
void ProfileSyncService::OnSyncCycleCompleted() {
UpdateLastSyncedTime();
- if (GetSessionModelAssociatorDeprecated()) {
+ if (IsSessionsDataTypeControllerRunning()) {
// Trigger garbage collection of old sessions now that we've downloaded
- // any new session data. TODO(zea): Have this be a notification the session
- // model associator listens too. Also consider somehow plumbing the current
- // server time as last reported by CheckServerReachable, so we don't have to
- // rely on the local clock, which may be off significantly.
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions,
- GetSessionModelAssociatorDeprecated()->AsWeakPtr()));
+ // any new session data.
+ if (sessions_sync_manager_) {
+ // Sessions V2.
+ base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+ &browser_sync::SessionsSyncManager::DoGarbageCollection,
+ base::AsWeakPtr(sessions_sync_manager_.get())));
+ } else {
+ base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+ &browser_sync::SessionModelAssociator::DeleteStaleSessions,
+ GetSessionModelAssociatorDeprecated()->AsWeakPtr()));
+ }
}
DVLOG(2) << "Notifying observers sync cycle completed";
NotifySyncCycleCompleted();

Powered by Google App Engine
This is Rietveld 408576698