Index: sync/engine/sync_scheduler_impl.cc |
diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc |
index 6a4f1efa80a89cdec7e12a25534cbf0b772997b5..7c07cdc421f2006da8985de403ec81323af4cdae 100644 |
--- a/sync/engine/sync_scheduler_impl.cc |
+++ b/sync/engine/sync_scheduler_impl.cc |
@@ -14,6 +14,7 @@ |
#include "base/location.h" |
#include "base/logging.h" |
#include "base/message_loop/message_loop.h" |
+#include "base/time/default_clock.h" |
#include "sync/engine/backoff_delay_provider.h" |
#include "sync/engine/syncer.h" |
#include "sync/notifier/object_id_invalidation_map.h" |
@@ -234,7 +235,8 @@ void SyncSchedulerImpl::Start(Mode mode) { |
if (old_mode != mode_ && |
mode_ == NORMAL_MODE && |
- nudge_tracker_.IsSyncRequired() && |
+ (nudge_tracker_.IsSyncRequired() || |
+ nudge_tracker_.IsRetryRequired(base::TimeTicks::Now())) && |
CanRunNudgeJobNow(NORMAL_PRIORITY)) { |
// We just got back to normal mode. Let's try to run the work that was |
// queued up while we were configuring. |
@@ -469,7 +471,7 @@ void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) { |
if (success) { |
// That cycle took care of any outstanding work we had. |
SDVLOG(2) << "Nudge succeeded."; |
- nudge_tracker_.RecordSuccessfulSyncCycle(); |
+ nudge_tracker_.RecordSuccessfulSyncCycle(base::TimeTicks::Now()); |
scheduled_nudge_time_ = base::TimeTicks(); |
// If we're here, then we successfully reached the server. End all backoff. |
@@ -549,18 +551,8 @@ void SyncSchedulerImpl::HandleFailure( |
void SyncSchedulerImpl::DoPollSyncSessionJob() { |
base::AutoReset<bool> protector(&no_scheduling_allowed_, true); |
- if (!CanRunJobNow(NORMAL_PRIORITY)) { |
- SDVLOG(2) << "Unable to run a poll job right now."; |
- return; |
- } |
- |
- if (mode_ != NORMAL_MODE) { |
- SDVLOG(2) << "Not running poll job in configure mode."; |
- return; |
- } |
- |
SDVLOG(2) << "Polling with types " |
- << ModelTypeSetToString(session_context_->enabled_types()); |
+ << ModelTypeSetToString(GetEnabledAndUnthrottledTypes()); |
scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this)); |
syncer_->PollSyncShare( |
GetEnabledAndUnthrottledTypes(), |
@@ -576,6 +568,25 @@ void SyncSchedulerImpl::DoPollSyncSessionJob() { |
} |
} |
+void SyncSchedulerImpl::DoRetrySyncSessionJob() { |
+ DCHECK(CalledOnValidThread()); |
+ DCHECK_EQ(mode_, NORMAL_MODE); |
+ |
+ base::AutoReset<bool> protector(&no_scheduling_allowed_, true); |
+ |
+ SDVLOG(2) << "Retrying with types " |
+ << ModelTypeSetToString(GetEnabledAndUnthrottledTypes()); |
+ scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this)); |
+ if (syncer_->RetrySyncShare(GetEnabledAndUnthrottledTypes(), |
+ session.get()) && |
+ !sessions::HasSyncerError( |
+ session->status_controller().model_neutral_state())) { |
+ nudge_tracker_.RecordSuccessfulSyncCycle(base::TimeTicks::Now()); |
+ } else { |
+ HandleFailure(session->status_controller().model_neutral_state()); |
+ } |
+} |
+ |
void SyncSchedulerImpl::UpdateNudgeTimeRecords(ModelTypeSet types) { |
DCHECK(CalledOnValidThread()); |
base::TimeTicks now = TimeTicks::Now(); |
@@ -683,11 +694,12 @@ void SyncSchedulerImpl::TrySyncSessionJobImpl() { |
SDVLOG(2) << "Found pending configure job"; |
DoConfigurationSyncSessionJob(priority); |
} |
- } else { |
- DCHECK(mode_ == NORMAL_MODE); |
- if (nudge_tracker_.IsSyncRequired() && CanRunNudgeJobNow(priority)) { |
+ } else if (CanRunNudgeJobNow(priority)) { |
+ if (nudge_tracker_.IsSyncRequired()) { |
SDVLOG(2) << "Found pending nudge job"; |
DoNudgeSyncSessionJob(priority); |
+ } else if (nudge_tracker_.IsRetryRequired(base::TimeTicks::Now())) { |
+ DoRetrySyncSessionJob(); |
} else if (do_poll_after_credentials_updated_ || |
((base::TimeTicks::Now() - last_poll_reset_) >= GetPollInterval())) { |
DoPollSyncSessionJob(); |
@@ -737,6 +749,10 @@ void SyncSchedulerImpl::PollTimerCallback() { |
TrySyncSessionJob(); |
} |
+void SyncSchedulerImpl::RetryTimerCallback() { |
+ TrySyncSessionJob(); |
+} |
+ |
void SyncSchedulerImpl::Unthrottle() { |
DCHECK(CalledOnValidThread()); |
DCHECK_EQ(WaitInterval::THROTTLED, wait_interval_->mode); |
@@ -890,6 +906,12 @@ void SyncSchedulerImpl::OnSyncProtocolError( |
OnActionableError(snapshot); |
} |
+void SyncSchedulerImpl::OnReceivedGuRetryDelay(const base::TimeDelta& delay) { |
+ nudge_tracker_.set_next_retry_time(base::TimeTicks::Now() + delay); |
+ retry_timer_.Start(FROM_HERE, delay, this, |
+ &SyncSchedulerImpl::RetryTimerCallback); |
+} |
+ |
void SyncSchedulerImpl::SetNotificationsEnabled(bool notifications_enabled) { |
DCHECK(CalledOnValidThread()); |
session_context_->set_notifications_enabled(notifications_enabled); |