diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 15:11:03 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 15:11:03 +0000 |
commit | ba3899e23674a76ec01abeef281a0b9e819bc5c1 (patch) | |
tree | ef7e69637a7f82edb5726f584e7b5d20ecb958dc | |
parent | 89c9aca0f74519e281f1a0ce425a8f6b195c658b (diff) | |
download | chromium_src-ba3899e23674a76ec01abeef281a0b9e819bc5c1.zip chromium_src-ba3899e23674a76ec01abeef281a0b9e819bc5c1.tar.gz chromium_src-ba3899e23674a76ec01abeef281a0b9e819bc5c1.tar.bz2 |
Reset the polling timer when the service state is updated.
Also reset (stop) the current time when polling delay is adjusted.
- When notification is enabled we start with very long polling delay and
it doesn't reset even when the service state changes to
TEMPORARY_UNAVAILABLE (while we'd want to have more chances to recover
the state). We should reset the polling timer when the delay is
shortened or the service state is updated.
- If we have sync error in batch state the service cannot recover since
it never runs again unless the service state becomes OK. We should try
starting the batch sync when the state is not only OK but also
TEMPORARY_UNAVAILABLE.
BUG=174862
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/12226056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181308 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/sync_file_system/drive_file_sync_service.cc | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc index ff1981d..24d37e0 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc @@ -745,6 +745,10 @@ void DriveFileSyncService::NotifyTaskDone(fileapi::SyncStatusCode status, RemoteServiceState old_state = GetCurrentState(); UpdateServiceState(); + // Reset the polling delay. This will adjust the polling timer + // based on the current service state. + UpdatePollingDelay(polling_delay_seconds_); + // Notify remote sync service state if the state has been changed. if (!token_->description().empty() || old_state != GetCurrentState()) { FOR_EACH_OBSERVER( @@ -767,11 +771,12 @@ void DriveFileSyncService::NotifyTaskDone(fileapi::SyncStatusCode status, SchedulePolling(); - if (GetCurrentState() != REMOTE_SERVICE_OK) + if (GetCurrentState() != REMOTE_SERVICE_OK && + GetCurrentState() != REMOTE_SERVICE_TEMPORARY_UNAVAILABLE) return; - // If the state has become OK and we have any pending batch sync origins - // restart batch sync for them. + // If the state has become OK or TEMPORARY_UNAVAILABLE and we have any + // pending batch sync origins, restart batch sync for them. if (!pending_batch_sync_origins_.empty()) { GURL origin = *pending_batch_sync_origins_.begin(); pending_batch_sync_origins_.erase(pending_batch_sync_origins_.begin()); @@ -1778,17 +1783,22 @@ bool DriveFileSyncService::GetPendingChangeForFileSystemURL( } void DriveFileSyncService::FetchChangesForIncrementalSync() { + scoped_ptr<TaskToken> token(GetToken(FROM_HERE, TASK_TYPE_DRIVE, + "Fetching remote change list")); if (!sync_enabled_ || is_fetching_changes_ || !pending_batch_sync_origins_.empty() || metadata_store_->incremental_sync_origins().empty() || - !pending_changes_.empty()) + !pending_changes_.empty()) { + if (token) { + token->ResetTask(FROM_HERE); + NotifyTaskDone(last_operation_status_, token.Pass()); + } return; + } is_fetching_changes_ = true; - scoped_ptr<TaskToken> token(GetToken(FROM_HERE, TASK_TYPE_DRIVE, - "Fetching remote change list")); if (!token) { pending_tasks_.push_back(base::Bind( &DriveFileSyncService::FetchChangesForIncrementalSync, AsWeakPtr())); @@ -1941,6 +1951,7 @@ void DriveFileSyncService::UpdatePollingDelay(int64 new_delay_sec) { // kPollingDelaySecondsWithNotification) so that we have a mild chance // to recover the state. polling_delay_seconds_ = kMaximumPollingDelaySeconds; + polling_timer_.Stop(); return; } @@ -1949,11 +1960,13 @@ void DriveFileSyncService::UpdatePollingDelay(int64 new_delay_sec) { return; } + int64 old_delay = polling_delay_seconds_; + // Push notifications off. polling_delay_seconds_ = std::min(new_delay_sec, kMaximumPollingDelaySeconds); - // TODO(tzik): Reset the timer if new_delay_sec is less than - // polling_delay_seconds_. + if (polling_delay_seconds_ < old_delay) + polling_timer_.Stop(); } fileapi::SyncStatusCode |