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

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: undo last upload Created 7 years 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/sync/profile_sync_service.h ('k') | chrome/browser/sync/sessions2/sessions_sync_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ed1e4177e5945afe3923cdc3ca6ea212ab0aa9ac..cc9fdd2d4e950731d98ea363842de7ad13119be8 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -365,12 +365,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())
@@ -381,13 +377,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)) {
@@ -1069,15 +1068,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();
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/sessions2/sessions_sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698