diff options
Diffstat (limited to 'chrome/browser/sync/engine')
-rw-r--r-- | chrome/browser/sync/engine/syncapi.cc | 18 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncapi.h | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index a149a08..484e6c3 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -1249,6 +1249,14 @@ void SyncManager::Authenticate(const char* username, const char* password, std::string(captcha)); } +bool SyncManager::RequestPause() { + return data_->syncer_thread()->RequestPause(); +} + +bool SyncManager::RequestResume() { + return data_->syncer_thread()->RequestResume(); +} + const std::string& SyncManager::GetAuthenticatedUsername() { DCHECK(data_); return data_->username_for_share(); @@ -1745,6 +1753,16 @@ void SyncManager::SyncInternal::HandleSyncerEvent(const SyncerEvent& event) { << " talk_mediator(): " << talk_mediator(); } } + + if (event.what_happened == SyncerEvent::PAUSED) { + observer_->OnPaused(); + return; + } + + if (event.what_happened == SyncerEvent::RESUMED) { + observer_->OnResumed(); + return; + } } void SyncManager::SyncInternal::HandleAuthWatcherEvent( diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h index 0b0572f..459ff40 100644 --- a/chrome/browser/sync/engine/syncapi.h +++ b/chrome/browser/sync/engine/syncapi.h @@ -570,6 +570,12 @@ class SyncManager { // message, unless otherwise specified, produces undefined behavior. virtual void OnInitializationComplete() = 0; + // The syncer thread has been paused. + virtual void OnPaused() = 0; + + // The syncer thread has been resumed. + virtual void OnResumed() = 0; + private: DISALLOW_COPY_AND_ASSIGN(Observer); }; @@ -644,6 +650,18 @@ class SyncManager { void Authenticate(const char* username, const char* password, const char* captcha); + // Requests the syncer thread to pause. The observer's OnPause + // method will be called when the syncer thread is paused. Returns + // false if the syncer thread can not be paused (e.g. if it is not + // started). + bool RequestPause(); + + // Requests the syncer thread to resume. The observer's OnResume + // method will be called when the syncer thread is resumed. Returns + // false if the syncer thread can not be resumed (e.g. if it is not + // paused). + bool RequestResume(); + // Adds a listener to be notified of sync events. // NOTE: It is OK (in fact, it's probably a good idea) to call this before // having received OnInitializationCompleted. |