diff options
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/engine/syncapi.cc | 2 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncapi.h | 11 | ||||
-rw-r--r-- | chrome/browser/sync/glue/sync_backend_host.cc | 23 | ||||
-rw-r--r-- | chrome/browser/sync/glue/sync_backend_host.h | 16 |
4 files changed, 44 insertions, 8 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index 433475c..e807d3d 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -1739,7 +1739,7 @@ void SyncManager::SyncInternal::HandleSyncerEvent(const SyncerEvent& event) { // whether we should sync again. if (event.what_happened == SyncerEvent::SYNC_CYCLE_ENDED) { if (!event.snapshot->has_more_to_sync) { - observer_->OnSyncCycleCompleted(); + observer_->OnSyncCycleCompleted(event.snapshot); } // TODO(chron): Consider changing this back to track has_more_to_sync diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h index ca1cc01..98aeeb9 100644 --- a/chrome/browser/sync/engine/syncapi.h +++ b/chrome/browser/sync/engine/syncapi.h @@ -53,6 +53,10 @@ namespace browser_sync { class ModelSafeWorkerRegistrar; + +namespace sessions { +struct SyncSessionSnapshot; +} } // Forward declarations of internal class types so that sync API objects @@ -564,10 +568,9 @@ class SyncManager { int change_count) = 0; // A round-trip sync-cycle took place and the syncer has resolved any - // conflicts that may have arisen. This is kept separate from - // OnStatusChanged as there isn't really any state update; it is plainly - // a notification of a state transition. - virtual void OnSyncCycleCompleted() = 0; + // conflicts that may have arisen. + virtual void OnSyncCycleCompleted( + const browser_sync::sessions::SyncSessionSnapshot* snapshot) = 0; // Called when user interaction may be required due to an auth problem. virtual void OnAuthError(const GoogleServiceAuthError& auth_error) = 0; diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index 51a8f86..ae3519d 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -13,6 +13,7 @@ #include "chrome/browser/sync/glue/history_model_worker.h" #include "chrome/browser/sync/glue/sync_backend_host.h" #include "chrome/browser/sync/glue/http_bridge.h" +#include "chrome/browser/sync/sessions/session_state.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "webkit/glue/webkit_glue.h" @@ -29,6 +30,8 @@ typedef GoogleServiceAuthError AuthError; namespace browser_sync { +using sessions::SyncSessionSnapshot; + SyncBackendHost::SyncBackendHost( SyncFrontend* frontend, Profile* profile, @@ -242,6 +245,10 @@ const GoogleServiceAuthError& SyncBackendHost::GetAuthError() const { return last_auth_error_; } +const SyncSessionSnapshot* SyncBackendHost::GetLastSessionSnapshot() const { + return last_snapshot_.get(); +} + void SyncBackendHost::GetWorkers(std::vector<ModelSafeWorker*>* out) { AutoLock lock(registrar_lock_); out->clear(); @@ -387,9 +394,21 @@ void SyncBackendHost::Core::OnChangesApplied( processor->ApplyChangesFromSyncModel(trans, changes, change_count); } -void SyncBackendHost::Core::OnSyncCycleCompleted() { +void SyncBackendHost::Core::OnSyncCycleCompleted( + const SyncSessionSnapshot* snapshot) { host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, - &Core::NotifyFrontend, SYNC_CYCLE_COMPLETED)); + &Core::HandleSyncCycleCompletedOnFrontendLoop, + new SyncSessionSnapshot(*snapshot))); +} + +void SyncBackendHost::Core::HandleSyncCycleCompletedOnFrontendLoop( + SyncSessionSnapshot* snapshot) { + if (!host_ || !host_->frontend_) + return; + DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); + + host_->last_snapshot_.reset(snapshot); + host_->frontend_->OnSyncCycleCompleted(); } void SyncBackendHost::Core::OnInitializationComplete() { diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h index 8edc7ba..e362d09 100644 --- a/chrome/browser/sync/glue/sync_backend_host.h +++ b/chrome/browser/sync/glue/sync_backend_host.h @@ -29,6 +29,10 @@ class Profile; namespace browser_sync { +namespace sessions { +struct SyncSessionSnapshot; +} + class ChangeProcessor; class DataTypeController; @@ -135,6 +139,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { Status GetDetailedStatus(); StatusSummary GetStatusSummary(); const GoogleServiceAuthError& GetAuthError() const; + const sessions::SyncSessionSnapshot* GetLastSessionSnapshot() const; const FilePath& sync_data_folder_path() const { return sync_data_folder_path_; @@ -191,7 +196,8 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { const sync_api::BaseTransaction* trans, const sync_api::SyncManager::ChangeRecord* changes, int change_count); - virtual void OnSyncCycleCompleted(); + virtual void OnSyncCycleCompleted( + const sessions::SyncSessionSnapshot* snapshot); virtual void OnInitializationComplete(); virtual void OnAuthError(const GoogleServiceAuthError& auth_error); virtual void OnPaused(); @@ -334,6 +340,11 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { void HandleAuthErrorEventOnFrontendLoop( const GoogleServiceAuthError& new_auth_error); + // Called from Core::OnSyncCycleCompleted to handle updating frontend + // thread components. + void HandleSyncCycleCompletedOnFrontendLoop( + sessions::SyncSessionSnapshot* snapshot); + // Our parent SyncBackendHost SyncBackendHost* host_; @@ -403,6 +414,9 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { // UI-thread cache of the last AuthErrorState received from syncapi. GoogleServiceAuthError last_auth_error_; + // UI-thread cache of the last SyncSessionSnapshot received from syncapi. + scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; + DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); }; |