Index: chrome/browser/sync/engine/sync_scheduler.cc |
diff --git a/chrome/browser/sync/engine/sync_scheduler.cc b/chrome/browser/sync/engine/sync_scheduler.cc |
index 13c822d06df888b869dd1992f5e6c12d7b461238..a1463bb65f580767a439a95335cf287e8b91e964 100644 |
--- a/chrome/browser/sync/engine/sync_scheduler.cc |
+++ b/chrome/browser/sync/engine/sync_scheduler.cc |
@@ -192,10 +192,6 @@ SyncScheduler::SyncScheduler(const std::string& name, |
sessions_commit_delay_( |
TimeDelta::FromSeconds(kDefaultSessionsCommitDelaySeconds)), |
mode_(NORMAL_MODE), |
- // Start with assuming everything is fine with the connection. |
- // At the end of the sync cycle we would have the correct status. |
- server_connection_ok_(true), |
- connection_code_(HttpResponse::SERVER_CONNECTION_OK), |
delay_provider_(new DelayProvider()), |
syncer_(syncer), |
session_context_(context) { |
@@ -207,69 +203,10 @@ SyncScheduler::~SyncScheduler() { |
StopImpl(base::Closure()); |
} |
-void SyncScheduler::OnCredentialsUpdated() { |
- DCHECK_EQ(MessageLoop::current(), sync_loop_); |
- |
- // TODO(lipalani): crbug.com/106262. One issue here is that if after |
- // the auth error we happened to do gettime and it succeeded then |
- // the |connection_code_| would be briefly OK however it would revert |
- // back to SYNC_AUTH_ERROR at the end of the sync cycle. The |
- // referenced bug explores the option of removing gettime calls |
- // altogethere |
- if (HttpResponse::SYNC_AUTH_ERROR == connection_code_) { |
- OnServerConnectionErrorFixed(); |
- } |
-} |
- |
-void SyncScheduler::OnConnectionStatusChange() { |
- if (HttpResponse::CONNECTION_UNAVAILABLE == connection_code_) { |
- // Optimistically assume that the connection is fixed and try |
- // connecting. |
- OnServerConnectionErrorFixed(); |
- } |
-} |
- |
void SyncScheduler::OnServerConnectionErrorFixed() { |
- DCHECK(!server_connection_ok_); |
- connection_code_ = HttpResponse::SERVER_CONNECTION_OK; |
- server_connection_ok_ = true; |
PostTask(FROM_HERE, "DoCanaryJob", |
base::Bind(&SyncScheduler::DoCanaryJob, |
weak_ptr_factory_.GetWeakPtr())); |
- |
-} |
- |
-void SyncScheduler::UpdateServerConnectionManagerStatus( |
- HttpResponse::ServerConnectionCode code) { |
- DCHECK_EQ(MessageLoop::current(), sync_loop_); |
- SDVLOG(2) << "New server connection code: " |
- << HttpResponse::GetServerConnectionCodeString(code); |
- bool old_server_connection_ok = server_connection_ok_; |
- |
- connection_code_ = code; |
- |
- // Note, be careful when adding cases here because if the SyncScheduler |
- // thinks there is no valid connection as determined by this method, it |
- // will drop out of *all* forward progress sync loops (it won't poll and it |
- // will queue up Talk notifications but not actually call SyncShare) until |
- // some external action causes a ServerConnectionManager to broadcast that |
- // a valid connection has been re-established |
- if (HttpResponse::CONNECTION_UNAVAILABLE == code || |
- HttpResponse::SYNC_AUTH_ERROR == code) { |
- server_connection_ok_ = false; |
- SDVLOG(2) << "Sync auth error or unavailable connection: " |
- << "server connection is down"; |
- } else if (HttpResponse::SERVER_CONNECTION_OK == code) { |
- server_connection_ok_ = true; |
- SDVLOG(2) << "Sync server connection is ok: " |
- << "server connection is up, doing canary job"; |
- } |
- |
- if (old_server_connection_ok != server_connection_ok_) { |
- const char* transition = |
- server_connection_ok_ ? "down -> up" : "up -> down"; |
- SDVLOG(2) << "Server connection changed: " << transition; |
- } |
} |
void SyncScheduler::Start(Mode mode, const base::Closure& callback) { |
@@ -385,10 +322,10 @@ SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob( |
return DROP; |
} |
- if (server_connection_ok_) |
+ if (!session_context_->connection_manager()->HasInvalidAuthToken()) |
return CONTINUE; |
- SDVLOG(2) << "Bad server connection. Using that to decide on job."; |
+ SDVLOG(2) << "We have no valid auth token. Using that to decide on job."; |
return job.purpose == SyncSessionJob::NUDGE ? SAVE : DROP; |
} |
@@ -852,17 +789,9 @@ void SyncScheduler::FinishSyncSessionJob(const SyncSessionJob& job) { |
} |
last_sync_session_end_time_ = now; |
- // Now update the status of the connection from SCM. We need this |
- // to decide whether we need to save/run future jobs. The notifications |
- // from SCM are not reliable. |
- // TODO(rlarocque): crbug.com/110954 |
- // We should get rid of the notifications and |
- // it is probably not needed to maintain this status variable |
- // in 2 places. We should query it directly from SCM when needed. |
- // But that would need little more refactoring(including a method to |
- // query if the auth token is invalid) from SCM side. |
ServerConnectionManager* scm = session_context_->connection_manager(); |
- UpdateServerConnectionManagerStatus(scm->server_status()); |
+ SDVLOG(2) << "New server connection code: " |
+ << HttpResponse::GetServerConnectionCodeString(scm->server_status()); |
UpdateCarryoverSessionState(job); |
if (IsSyncingCurrentlySilenced()) { |