| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/engine/syncer_thread2.h" | 5 #include "chrome/browser/sync/engine/syncer_thread2.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 Mode mode; | 35 Mode mode; |
| 36 | 36 |
| 37 // This bool is set to true if we have observed a nudge during this | 37 // This bool is set to true if we have observed a nudge during this |
| 38 // interval and mode == EXPONENTIAL_BACKOFF. | 38 // interval and mode == EXPONENTIAL_BACKOFF. |
| 39 bool had_nudge; | 39 bool had_nudge; |
| 40 base::TimeDelta length; | 40 base::TimeDelta length; |
| 41 base::OneShotTimer<SyncerThread> timer; | 41 base::OneShotTimer<SyncerThread> timer; |
| 42 WaitInterval(Mode mode, base::TimeDelta length); | 42 WaitInterval(Mode mode, base::TimeDelta length); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 struct SyncerThread::SyncSessionJob { |
| 46 SyncSessionJobPurpose purpose; |
| 47 base::TimeTicks scheduled_start; |
| 48 linked_ptr<sessions::SyncSession> session; |
| 49 }; |
| 50 |
| 45 SyncerThread::DelayProvider::DelayProvider() {} | 51 SyncerThread::DelayProvider::DelayProvider() {} |
| 46 SyncerThread::DelayProvider::~DelayProvider() {} | 52 SyncerThread::DelayProvider::~DelayProvider() {} |
| 47 | 53 |
| 48 TimeDelta SyncerThread::DelayProvider::GetDelay( | 54 TimeDelta SyncerThread::DelayProvider::GetDelay( |
| 49 const base::TimeDelta& last_delay) { | 55 const base::TimeDelta& last_delay) { |
| 50 return SyncerThread::GetRecommendedDelay(last_delay); | 56 return SyncerThread::GetRecommendedDelay(last_delay); |
| 51 } | 57 } |
| 52 | 58 |
| 53 SyncerThread::WaitInterval::WaitInterval(Mode mode, TimeDelta length) | 59 SyncerThread::WaitInterval::WaitInterval(Mode mode, TimeDelta length) |
| 54 : mode(mode), had_nudge(false), length(length) { } | 60 : mode(mode), had_nudge(false), length(length) { } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 81 } | 87 } |
| 82 | 88 |
| 83 void SyncerThread::StartImpl(Mode mode) { | 89 void SyncerThread::StartImpl(Mode mode) { |
| 84 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 90 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 85 DCHECK(!session_context_->account_name().empty()); | 91 DCHECK(!session_context_->account_name().empty()); |
| 86 DCHECK(syncer_.get()); | 92 DCHECK(syncer_.get()); |
| 87 mode_ = mode; | 93 mode_ = mode; |
| 88 AdjustPolling(NULL); // Will kick start poll timer if needed. | 94 AdjustPolling(NULL); // Will kick start poll timer if needed. |
| 89 } | 95 } |
| 90 | 96 |
| 91 bool SyncerThread::ShouldRunJob(SyncSessionJob::Purpose purpose, | 97 bool SyncerThread::ShouldRunJob(SyncSessionJobPurpose purpose, |
| 92 const TimeTicks& scheduled_start) { | 98 const TimeTicks& scheduled_start) { |
| 93 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 99 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 94 | 100 |
| 95 // Check wait interval. | 101 // Check wait interval. |
| 96 if (wait_interval_.get()) { | 102 if (wait_interval_.get()) { |
| 97 if (wait_interval_->mode == WaitInterval::THROTTLED) | 103 if (wait_interval_->mode == WaitInterval::THROTTLED) |
| 98 return false; | 104 return false; |
| 99 | 105 |
| 100 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); | 106 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); |
| 101 DCHECK(purpose == SyncSessionJob::POLL || | 107 DCHECK(purpose == POLL || |
| 102 purpose == SyncSessionJob::NUDGE); | 108 purpose == NUDGE); |
| 103 if ((purpose != SyncSessionJob::NUDGE) || wait_interval_->had_nudge) | 109 if ((purpose != NUDGE) || wait_interval_->had_nudge) |
| 104 return false; | 110 return false; |
| 105 } | 111 } |
| 106 | 112 |
| 107 // Mode / purpose contract (See 'Mode' enum in header). Don't run jobs that | 113 // Mode / purpose contract (See 'Mode' enum in header). Don't run jobs that |
| 108 // were intended for a normal sync if we are in configuration mode, and vice | 114 // were intended for a normal sync if we are in configuration mode, and vice |
| 109 // versa. | 115 // versa. |
| 110 switch (mode_) { | 116 switch (mode_) { |
| 111 case CONFIGURATION_MODE: | 117 case CONFIGURATION_MODE: |
| 112 if (purpose != SyncSessionJob::CONFIGURATION) | 118 if (purpose != CONFIGURATION) |
| 113 return false; | 119 return false; |
| 114 break; | 120 break; |
| 115 case NORMAL_MODE: | 121 case NORMAL_MODE: |
| 116 if (purpose != SyncSessionJob::POLL && purpose != SyncSessionJob::NUDGE) | 122 if (purpose != POLL && purpose != NUDGE) |
| 117 return false; | 123 return false; |
| 118 break; | 124 break; |
| 119 default: | 125 default: |
| 120 NOTREACHED() << "Unknown SyncerThread Mode: " << mode_; | 126 NOTREACHED() << "Unknown SyncerThread Mode: " << mode_; |
| 121 return false; | 127 return false; |
| 122 } | 128 } |
| 123 | 129 |
| 124 // Continuation NUDGE tasks have priority over POLLs because they are the | 130 // Continuation NUDGE tasks have priority over POLLs because they are the |
| 125 // only tasks that trigger exponential backoff, so this prevents them from | 131 // only tasks that trigger exponential backoff, so this prevents them from |
| 126 // being starved from running (e.g. due to a very, very low poll interval, | 132 // being starved from running (e.g. due to a very, very low poll interval, |
| 127 // such as 0ms). It's rare that this would ever matter in practice. | 133 // such as 0ms). It's rare that this would ever matter in practice. |
| 128 if (purpose == SyncSessionJob::POLL && (pending_nudge_.get() && | 134 if (purpose == POLL && (pending_nudge_.get() && |
| 129 pending_nudge_->session->source().first == | 135 pending_nudge_->session->source().first == |
| 130 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION)) { | 136 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION)) { |
| 131 return false; | 137 return false; |
| 132 } | 138 } |
| 133 | 139 |
| 134 // Freshness condition. | 140 // Freshness condition. |
| 135 if (purpose == SyncSessionJob::NUDGE && | 141 if (purpose == NUDGE && |
| 136 (scheduled_start < last_sync_session_end_time_)) { | 142 (scheduled_start < last_sync_session_end_time_)) { |
| 137 return false; | 143 return false; |
| 138 } | 144 } |
| 139 | 145 |
| 140 return server_connection_ok_; | 146 return server_connection_ok_; |
| 141 } | 147 } |
| 142 | 148 |
| 143 namespace { | 149 namespace { |
| 144 GetUpdatesCallerInfo::GetUpdatesSource GetUpdatesFromNudgeSource( | 150 GetUpdatesCallerInfo::GetUpdatesSource GetUpdatesFromNudgeSource( |
| 145 NudgeSource source) { | 151 NudgeSource source) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 176 } | 182 } |
| 177 | 183 |
| 178 thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 184 thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 179 this, &SyncerThread::ScheduleNudgeImpl, delay, source, types)); | 185 this, &SyncerThread::ScheduleNudgeImpl, delay, source, types)); |
| 180 } | 186 } |
| 181 | 187 |
| 182 void SyncerThread::ScheduleNudgeImpl(const TimeDelta& delay, | 188 void SyncerThread::ScheduleNudgeImpl(const TimeDelta& delay, |
| 183 NudgeSource source, const ModelTypeBitSet& model_types) { | 189 NudgeSource source, const ModelTypeBitSet& model_types) { |
| 184 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 190 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 185 TimeTicks rough_start = TimeTicks::Now() + delay; | 191 TimeTicks rough_start = TimeTicks::Now() + delay; |
| 186 if (!ShouldRunJob(SyncSessionJob::NUDGE, rough_start)) | 192 if (!ShouldRunJob(NUDGE, rough_start)) |
| 187 return; | 193 return; |
| 188 | 194 |
| 189 // Note we currently nudge for all types regardless of the ones incurring | 195 // Note we currently nudge for all types regardless of the ones incurring |
| 190 // the nudge. Doing different would throw off some syncer commands like | 196 // the nudge. Doing different would throw off some syncer commands like |
| 191 // CleanupDisabledTypes. We may want to change this in the future. | 197 // CleanupDisabledTypes. We may want to change this in the future. |
| 192 ModelSafeRoutingInfo routes; | 198 ModelSafeRoutingInfo routes; |
| 193 std::vector<ModelSafeWorker*> workers; | 199 std::vector<ModelSafeWorker*> workers; |
| 194 session_context_->registrar()->GetModelSafeRoutingInfo(&routes); | 200 session_context_->registrar()->GetModelSafeRoutingInfo(&routes); |
| 195 session_context_->registrar()->GetWorkers(&workers); | 201 session_context_->registrar()->GetWorkers(&workers); |
| 196 SyncSourceInfo info(GetUpdatesFromNudgeSource(source), model_types); | 202 SyncSourceInfo info(GetUpdatesFromNudgeSource(source), model_types); |
| 197 | 203 |
| 198 scoped_ptr<SyncSession> session(new SyncSession( | 204 scoped_ptr<SyncSession> session(new SyncSession( |
| 199 session_context_.get(), this, info, routes, workers)); | 205 session_context_.get(), this, info, routes, workers)); |
| 200 | 206 |
| 201 if (pending_nudge_.get()) { | 207 if (pending_nudge_.get()) { |
| 202 if (IsBackingOff() && delay > TimeDelta::FromSeconds(1)) | 208 if (IsBackingOff() && delay > TimeDelta::FromSeconds(1)) |
| 203 return; | 209 return; |
| 204 | 210 |
| 205 pending_nudge_->session->Coalesce(*session.get()); | 211 pending_nudge_->session->Coalesce(*session.get()); |
| 206 if (!IsBackingOff()) { | 212 if (!IsBackingOff()) { |
| 207 return; | 213 return; |
| 208 } else { | 214 } else { |
| 209 // Re-schedule the current pending nudge. | 215 // Re-schedule the current pending nudge. |
| 210 SyncSession* s = pending_nudge_->session.get(); | 216 SyncSession* s = pending_nudge_->session.get(); |
| 211 session.reset(new SyncSession(s->context(), s->delegate(), s->source(), | 217 session.reset(new SyncSession(s->context(), s->delegate(), s->source(), |
| 212 s->routing_info(), s->workers())); | 218 s->routing_info(), s->workers())); |
| 213 pending_nudge_.reset(); | 219 pending_nudge_.reset(); |
| 214 } | 220 } |
| 215 } | 221 } |
| 216 ScheduleSyncSessionJob(delay, SyncSessionJob::NUDGE, session.release()); | 222 ScheduleSyncSessionJob(delay, NUDGE, session.release()); |
| 217 } | 223 } |
| 218 | 224 |
| 219 // Helper to extract the routing info and workers corresponding to types in | 225 // Helper to extract the routing info and workers corresponding to types in |
| 220 // |types| from |registrar|. | 226 // |types| from |registrar|. |
| 221 void GetModelSafeParamsForTypes(const ModelTypeBitSet& types, | 227 void GetModelSafeParamsForTypes(const ModelTypeBitSet& types, |
| 222 ModelSafeWorkerRegistrar* registrar, ModelSafeRoutingInfo* routes, | 228 ModelSafeWorkerRegistrar* registrar, ModelSafeRoutingInfo* routes, |
| 223 std::vector<ModelSafeWorker*>* workers) { | 229 std::vector<ModelSafeWorker*>* workers) { |
| 224 ModelSafeRoutingInfo r_tmp; | 230 ModelSafeRoutingInfo r_tmp; |
| 225 std::vector<ModelSafeWorker*> w_tmp; | 231 std::vector<ModelSafeWorker*> w_tmp; |
| 226 registrar->GetModelSafeRoutingInfo(&r_tmp); | 232 registrar->GetModelSafeRoutingInfo(&r_tmp); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 271 } |
| 266 | 272 |
| 267 void SyncerThread::ScheduleConfigImpl(const TimeDelta& delay, | 273 void SyncerThread::ScheduleConfigImpl(const TimeDelta& delay, |
| 268 const ModelSafeRoutingInfo& routing_info, | 274 const ModelSafeRoutingInfo& routing_info, |
| 269 const std::vector<ModelSafeWorker*>& workers) { | 275 const std::vector<ModelSafeWorker*>& workers) { |
| 270 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 276 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 271 NOTIMPLEMENTED() << "TODO(tim)"; | 277 NOTIMPLEMENTED() << "TODO(tim)"; |
| 272 } | 278 } |
| 273 | 279 |
| 274 void SyncerThread::ScheduleSyncSessionJob(const base::TimeDelta& delay, | 280 void SyncerThread::ScheduleSyncSessionJob(const base::TimeDelta& delay, |
| 275 SyncSessionJob::Purpose purpose, sessions::SyncSession* session) { | 281 SyncSessionJobPurpose purpose, sessions::SyncSession* session) { |
| 276 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 282 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 277 SyncSessionJob job = {purpose, TimeTicks::Now() + delay, | 283 SyncSessionJob job = {purpose, TimeTicks::Now() + delay, |
| 278 make_linked_ptr(session)}; | 284 make_linked_ptr(session)}; |
| 279 if (purpose == SyncSessionJob::NUDGE) { | 285 if (purpose == NUDGE) { |
| 280 DCHECK(!pending_nudge_.get() || pending_nudge_->session.get() == session); | 286 DCHECK(!pending_nudge_.get() || pending_nudge_->session.get() == session); |
| 281 pending_nudge_.reset(new SyncSessionJob(job)); | 287 pending_nudge_.reset(new SyncSessionJob(job)); |
| 282 } | 288 } |
| 283 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(this, | 289 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(this, |
| 284 &SyncerThread::DoSyncSessionJob, job), delay.InMilliseconds()); | 290 &SyncerThread::DoSyncSessionJob, job), delay.InMilliseconds()); |
| 285 } | 291 } |
| 286 | 292 |
| 287 void SyncerThread::DoSyncSessionJob(const SyncSessionJob& job) { | 293 void SyncerThread::DoSyncSessionJob(const SyncSessionJob& job) { |
| 288 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 294 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 289 | 295 |
| 290 if (job.purpose == SyncSessionJob::NUDGE) { | 296 if (job.purpose == NUDGE) { |
| 291 DCHECK(pending_nudge_.get()); | 297 DCHECK(pending_nudge_.get()); |
| 292 if (pending_nudge_->session != job.session) | 298 if (pending_nudge_->session != job.session) |
| 293 return; // Another nudge must have been scheduled in in the meantime. | 299 return; // Another nudge must have been scheduled in in the meantime. |
| 294 pending_nudge_.reset(); | 300 pending_nudge_.reset(); |
| 295 } else if (job.purpose == SyncSessionJob::CONFIGURATION) { | 301 } else if (job.purpose == CONFIGURATION) { |
| 296 NOTIMPLEMENTED() << "TODO(tim): SyncShare [DOWNLOAD_UPDATES,APPLY_UPDATES]"; | 302 NOTIMPLEMENTED() << "TODO(tim): SyncShare [DOWNLOAD_UPDATES,APPLY_UPDATES]"; |
| 297 } | 303 } |
| 298 | 304 |
| 299 bool has_more_to_sync = true; | 305 bool has_more_to_sync = true; |
| 300 bool did_job = false; | 306 bool did_job = false; |
| 301 while (ShouldRunJob(job.purpose, job.scheduled_start) && has_more_to_sync) { | 307 while (ShouldRunJob(job.purpose, job.scheduled_start) && has_more_to_sync) { |
| 302 VLOG(1) << "SyncerThread: Calling SyncShare."; | 308 VLOG(1) << "SyncerThread: Calling SyncShare."; |
| 303 did_job = true; | 309 did_job = true; |
| 304 // Synchronously perform the sync session from this thread. | 310 // Synchronously perform the sync session from this thread. |
| 305 syncer_->SyncShare(job.session.get()); | 311 syncer_->SyncShare(job.session.get()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 wait_interval_.reset(); // Success implies backoff relief. | 360 wait_interval_.reset(); // Success implies backoff relief. |
| 355 return; | 361 return; |
| 356 } | 362 } |
| 357 | 363 |
| 358 if (old_job.session->source().first == | 364 if (old_job.session->source().first == |
| 359 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) { | 365 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) { |
| 360 // We don't seem to have made forward progress. Start or extend backoff. | 366 // We don't seem to have made forward progress. Start or extend backoff. |
| 361 HandleConsecutiveContinuationError(old_job); | 367 HandleConsecutiveContinuationError(old_job); |
| 362 } else if (IsBackingOff()) { | 368 } else if (IsBackingOff()) { |
| 363 // We weren't continuing but we're in backoff; must have been a nudge. | 369 // We weren't continuing but we're in backoff; must have been a nudge. |
| 364 DCHECK_EQ(SyncSessionJob::NUDGE, old_job.purpose); | 370 DCHECK_EQ(NUDGE, old_job.purpose); |
| 365 DCHECK(!wait_interval_->had_nudge); | 371 DCHECK(!wait_interval_->had_nudge); |
| 366 wait_interval_->had_nudge = true; | 372 wait_interval_->had_nudge = true; |
| 367 wait_interval_->timer.Reset(); | 373 wait_interval_->timer.Reset(); |
| 368 } else { | 374 } else { |
| 369 // We weren't continuing and we aren't in backoff. Schedule a normal | 375 // We weren't continuing and we aren't in backoff. Schedule a normal |
| 370 // continuation. | 376 // continuation. |
| 371 ScheduleNudgeImpl(TimeDelta::FromSeconds(0), NUDGE_SOURCE_CONTINUATION, | 377 ScheduleNudgeImpl(TimeDelta::FromSeconds(0), NUDGE_SOURCE_CONTINUATION, |
| 372 old_job.session->source().second); | 378 old_job.session->source().second); |
| 373 } | 379 } |
| 374 } | 380 } |
| 375 | 381 |
| 376 void SyncerThread::AdjustPolling(const SyncSessionJob* old_job) { | 382 void SyncerThread::AdjustPolling(const SyncSessionJob* old_job) { |
| 377 DCHECK(thread_.IsRunning()); | 383 DCHECK(thread_.IsRunning()); |
| 378 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 384 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 379 | 385 |
| 380 TimeDelta poll = (!session_context_->notifications_enabled()) ? | 386 TimeDelta poll = (!session_context_->notifications_enabled()) ? |
| 381 syncer_short_poll_interval_seconds_ : | 387 syncer_short_poll_interval_seconds_ : |
| 382 syncer_long_poll_interval_seconds_; | 388 syncer_long_poll_interval_seconds_; |
| 383 bool rate_changed = !poll_timer_.IsRunning() || | 389 bool rate_changed = !poll_timer_.IsRunning() || |
| 384 poll != poll_timer_.GetCurrentDelay(); | 390 poll != poll_timer_.GetCurrentDelay(); |
| 385 | 391 |
| 386 if (old_job && old_job->purpose != SyncSessionJob::POLL && !rate_changed) | 392 if (old_job && old_job->purpose != POLL && !rate_changed) |
| 387 poll_timer_.Reset(); | 393 poll_timer_.Reset(); |
| 388 | 394 |
| 389 if (!rate_changed) | 395 if (!rate_changed) |
| 390 return; | 396 return; |
| 391 | 397 |
| 392 // Adjust poll rate. | 398 // Adjust poll rate. |
| 393 poll_timer_.Stop(); | 399 poll_timer_.Stop(); |
| 394 poll_timer_.Start(poll, this, &SyncerThread::PollTimerCallback); | 400 poll_timer_.Start(poll, this, &SyncerThread::PollTimerCallback); |
| 395 } | 401 } |
| 396 | 402 |
| 397 void SyncerThread::HandleConsecutiveContinuationError( | 403 void SyncerThread::HandleConsecutiveContinuationError( |
| 398 const SyncSessionJob& old_job) { | 404 const SyncSessionJob& old_job) { |
| 399 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 405 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 400 DCHECK(!IsBackingOff() || !wait_interval_->timer.IsRunning()); | 406 DCHECK(!IsBackingOff() || !wait_interval_->timer.IsRunning()); |
| 401 SyncSession* old = old_job.session.get(); | 407 SyncSession* old = old_job.session.get(); |
| 402 SyncSession* s(new SyncSession(session_context_.get(), this, | 408 SyncSession* s(new SyncSession(session_context_.get(), this, |
| 403 old->source(), old->routing_info(), old->workers())); | 409 old->source(), old->routing_info(), old->workers())); |
| 404 TimeDelta length = delay_provider_->GetDelay( | 410 TimeDelta length = delay_provider_->GetDelay( |
| 405 IsBackingOff() ? wait_interval_->length : TimeDelta::FromSeconds(1)); | 411 IsBackingOff() ? wait_interval_->length : TimeDelta::FromSeconds(1)); |
| 406 wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, | 412 wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, |
| 407 length)); | 413 length)); |
| 408 SyncSessionJob job = {SyncSessionJob::NUDGE, TimeTicks::Now() + length, | 414 SyncSessionJob job = {NUDGE, TimeTicks::Now() + length, |
| 409 make_linked_ptr(s)}; | 415 make_linked_ptr(s)}; |
| 410 pending_nudge_.reset(new SyncSessionJob(job)); | 416 pending_nudge_.reset(new SyncSessionJob(job)); |
| 411 wait_interval_->timer.Start(length, this, &SyncerThread::DoCanaryJob); | 417 wait_interval_->timer.Start(length, this, &SyncerThread::DoCanaryJob); |
| 412 } | 418 } |
| 413 | 419 |
| 414 // static | 420 // static |
| 415 TimeDelta SyncerThread::GetRecommendedDelay(const TimeDelta& last_delay) { | 421 TimeDelta SyncerThread::GetRecommendedDelay(const TimeDelta& last_delay) { |
| 416 if (last_delay.InSeconds() >= kMaxBackoffSeconds) | 422 if (last_delay.InSeconds() >= kMaxBackoffSeconds) |
| 417 return TimeDelta::FromSeconds(kMaxBackoffSeconds); | 423 return TimeDelta::FromSeconds(kMaxBackoffSeconds); |
| 418 | 424 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } | 457 } |
| 452 | 458 |
| 453 void SyncerThread::PollTimerCallback() { | 459 void SyncerThread::PollTimerCallback() { |
| 454 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 460 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 455 ModelSafeRoutingInfo r; | 461 ModelSafeRoutingInfo r; |
| 456 std::vector<ModelSafeWorker*> w; | 462 std::vector<ModelSafeWorker*> w; |
| 457 session_context_->registrar()->GetModelSafeRoutingInfo(&r); | 463 session_context_->registrar()->GetModelSafeRoutingInfo(&r); |
| 458 session_context_->registrar()->GetWorkers(&w); | 464 session_context_->registrar()->GetWorkers(&w); |
| 459 SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, ModelTypeBitSet()); | 465 SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, ModelTypeBitSet()); |
| 460 SyncSession* s = new SyncSession(session_context_.get(), this, info, r, w); | 466 SyncSession* s = new SyncSession(session_context_.get(), this, info, r, w); |
| 461 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), SyncSessionJob::POLL, s); | 467 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), POLL, s); |
| 462 } | 468 } |
| 463 | 469 |
| 464 void SyncerThread::Unthrottle() { | 470 void SyncerThread::Unthrottle() { |
| 465 DCHECK_EQ(WaitInterval::THROTTLED, wait_interval_->mode); | 471 DCHECK_EQ(WaitInterval::THROTTLED, wait_interval_->mode); |
| 466 wait_interval_.reset(); | 472 wait_interval_.reset(); |
| 467 } | 473 } |
| 468 | 474 |
| 469 void SyncerThread::Notify(SyncEngineEvent::EventCause cause) { | 475 void SyncerThread::Notify(SyncEngineEvent::EventCause cause) { |
| 470 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); | 476 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
| 471 session_context_->NotifyListeners(SyncEngineEvent(cause)); | 477 session_context_->NotifyListeners(SyncEngineEvent(cause)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 const ServerConnectionEvent& event) { | 515 const ServerConnectionEvent& event) { |
| 510 NOTIMPLEMENTED(); | 516 NOTIMPLEMENTED(); |
| 511 } | 517 } |
| 512 | 518 |
| 513 void SyncerThread::set_notifications_enabled(bool notifications_enabled) { | 519 void SyncerThread::set_notifications_enabled(bool notifications_enabled) { |
| 514 session_context_->set_notifications_enabled(notifications_enabled); | 520 session_context_->set_notifications_enabled(notifications_enabled); |
| 515 } | 521 } |
| 516 | 522 |
| 517 } // s3 | 523 } // s3 |
| 518 } // browser_sync | 524 } // browser_sync |
| OLD | NEW |