Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/engine/sync_scheduler_impl.h" | 5 #include "sync/engine/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 // execute in the new mode. | 273 // execute in the new mode. |
| 274 if (mode_ == NORMAL_MODE) { | 274 if (mode_ == NORMAL_MODE) { |
| 275 // It is illegal to switch to NORMAL_MODE if a previous CONFIGURATION job | 275 // It is illegal to switch to NORMAL_MODE if a previous CONFIGURATION job |
| 276 // has not yet completed. | 276 // has not yet completed. |
| 277 DCHECK(!wait_interval_.get() || !wait_interval_->pending_configure_job); | 277 DCHECK(!wait_interval_.get() || !wait_interval_->pending_configure_job); |
| 278 } | 278 } |
| 279 | 279 |
| 280 scoped_ptr<SyncSessionJob> pending(TakePendingJobForCurrentMode()); | 280 scoped_ptr<SyncSessionJob> pending(TakePendingJobForCurrentMode()); |
| 281 if (pending.get()) { | 281 if (pending.get()) { |
| 282 SDVLOG(2) << "Executing pending job. Good luck!"; | 282 SDVLOG(2) << "Executing pending job. Good luck!"; |
| 283 DoSyncSessionJob(pending.Pass()); | 283 DoSyncSessionJob(pending.Pass(), false); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 void SyncSchedulerImpl::SendInitialSnapshot() { | 288 void SyncSchedulerImpl::SendInitialSnapshot() { |
| 289 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 289 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 290 scoped_ptr<SyncSession> dummy(new SyncSession( | 290 scoped_ptr<SyncSession> dummy(new SyncSession( |
| 291 session_context_, this, SyncSourceInfo())); | 291 session_context_, this, SyncSourceInfo())); |
| 292 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); | 292 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); |
| 293 event.snapshot = dummy->TakeSnapshot(); | 293 event.snapshot = dummy->TakeSnapshot(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 ModelSafeRoutingInfoToInvalidationMap( | 343 ModelSafeRoutingInfoToInvalidationMap( |
| 344 restricted_routes, | 344 restricted_routes, |
| 345 std::string())))); | 345 std::string())))); |
| 346 scoped_ptr<SyncSessionJob> job(new SyncSessionJob( | 346 scoped_ptr<SyncSessionJob> job(new SyncSessionJob( |
| 347 SyncSessionJob::CONFIGURATION, | 347 SyncSessionJob::CONFIGURATION, |
| 348 TimeTicks::Now(), | 348 TimeTicks::Now(), |
| 349 session.Pass(), | 349 session.Pass(), |
| 350 params, | 350 params, |
| 351 FROM_HERE)); | 351 FROM_HERE)); |
| 352 job->set_destruction_observer(weak_ptr_factory_.GetWeakPtr()); | 352 job->set_destruction_observer(weak_ptr_factory_.GetWeakPtr()); |
| 353 bool succeeded = DoSyncSessionJob(job.Pass()); | 353 bool succeeded = DoSyncSessionJob(job.Pass(), false); |
| 354 | 354 |
| 355 // If we failed, the job would have been saved as the pending configure | 355 // If we failed, the job would have been saved as the pending configure |
| 356 // job and a wait interval would have been set. | 356 // job and a wait interval would have been set. |
| 357 if (!succeeded) { | 357 if (!succeeded) { |
| 358 DCHECK(wait_interval_.get() && wait_interval_->pending_configure_job); | 358 DCHECK(wait_interval_.get() && wait_interval_->pending_configure_job); |
| 359 return false; | 359 return false; |
| 360 } | 360 } |
| 361 } else { | 361 } else { |
| 362 SDVLOG(2) << "No change in routing info, calling ready task directly."; | 362 SDVLOG(2) << "No change in routing info, calling ready task directly."; |
| 363 params.ready_task.Run(); | 363 params.ready_task.Run(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 return true; | 366 return true; |
| 367 } | 367 } |
| 368 | 368 |
| 369 SyncSchedulerImpl::JobProcessDecision | 369 SyncSchedulerImpl::JobProcessDecision |
| 370 SyncSchedulerImpl::DecideWhileInWaitInterval(const SyncSessionJob& job) { | 370 SyncSchedulerImpl::DecideWhileInWaitInterval(const SyncSessionJob& job, |
| 371 bool is_canary) { | |
| 371 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 372 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 372 DCHECK(wait_interval_.get()); | 373 DCHECK(wait_interval_.get()); |
| 373 | 374 |
| 374 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " | 375 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " |
| 375 << WaitInterval::GetModeString(wait_interval_->mode) | 376 << WaitInterval::GetModeString(wait_interval_->mode) |
| 376 << (wait_interval_->had_nudge ? " (had nudge)" : "") | 377 << (wait_interval_->had_nudge ? " (had nudge)" : "") |
| 377 << (job.is_canary() ? " (canary)" : ""); | 378 << (is_canary ? " (canary)" : ""); |
| 378 | 379 |
| 379 if (job.purpose() == SyncSessionJob::POLL) | 380 if (job.purpose() == SyncSessionJob::POLL) |
| 380 return DROP; | 381 return DROP; |
| 381 | 382 |
| 382 // If we save a job while in a WaitInterval, there is a well-defined moment | 383 // If we save a job while in a WaitInterval, there is a well-defined moment |
| 383 // in time in the future when it makes sense for that SAVE-worthy job to try | 384 // in time in the future when it makes sense for that SAVE-worthy job to try |
| 384 // running again -- the end of the WaitInterval. | 385 // running again -- the end of the WaitInterval. |
| 385 DCHECK(job.purpose() == SyncSessionJob::NUDGE || | 386 DCHECK(job.purpose() == SyncSessionJob::NUDGE || |
| 386 job.purpose() == SyncSessionJob::CONFIGURATION); | 387 job.purpose() == SyncSessionJob::CONFIGURATION); |
| 387 | 388 |
| 388 // If throttled, there's a clock ticking to unthrottle. We want to get | 389 // If throttled, there's a clock ticking to unthrottle. We want to get |
| 389 // on the same train. | 390 // on the same train. |
| 390 if (wait_interval_->mode == WaitInterval::THROTTLED) | 391 if (wait_interval_->mode == WaitInterval::THROTTLED) |
| 391 return SAVE; | 392 return SAVE; |
| 392 | 393 |
| 393 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); | 394 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); |
| 394 if (job.purpose() == SyncSessionJob::NUDGE) { | 395 if (job.purpose() == SyncSessionJob::NUDGE) { |
| 395 if (mode_ == CONFIGURATION_MODE) | 396 if (mode_ == CONFIGURATION_MODE) |
| 396 return SAVE; | 397 return SAVE; |
| 397 | 398 |
| 398 // If we already had one nudge then just drop this nudge. We will retry | 399 // If we already had one nudge then just drop this nudge. We will retry |
| 399 // later when the timer runs out. | 400 // later when the timer runs out. |
| 400 if (!job.is_canary()) | 401 if (!is_canary) |
| 401 return wait_interval_->had_nudge ? DROP : CONTINUE; | 402 return wait_interval_->had_nudge ? DROP : CONTINUE; |
| 402 else // We are here because timer ran out. So retry. | 403 else // We are here because timer ran out. So retry. |
| 403 return CONTINUE; | 404 return CONTINUE; |
| 404 } | 405 } |
| 405 return job.is_canary() ? CONTINUE : SAVE; | 406 return is_canary ? CONTINUE : SAVE; |
| 406 } | 407 } |
| 407 | 408 |
| 408 SyncSchedulerImpl::JobProcessDecision SyncSchedulerImpl::DecideOnJob( | 409 SyncSchedulerImpl::JobProcessDecision SyncSchedulerImpl::DecideOnJob( |
| 409 const SyncSessionJob& job) { | 410 const SyncSessionJob& job, |
| 411 bool is_canary) { | |
| 410 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 412 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 411 | 413 |
| 412 // See if our type is throttled. | 414 // See if our type is throttled. |
| 413 ModelTypeSet throttled_types = | 415 ModelTypeSet throttled_types = |
| 414 session_context_->throttled_data_type_tracker()->GetThrottledTypes(); | 416 session_context_->throttled_data_type_tracker()->GetThrottledTypes(); |
| 415 if (job.purpose() == SyncSessionJob::NUDGE && | 417 if (job.purpose() == SyncSessionJob::NUDGE && |
| 416 job.session()->source().updates_source == GetUpdatesCallerInfo::LOCAL) { | 418 job.session()->source().updates_source == GetUpdatesCallerInfo::LOCAL) { |
| 417 ModelTypeSet requested_types; | 419 ModelTypeSet requested_types; |
| 418 for (ModelTypeInvalidationMap::const_iterator i = | 420 for (ModelTypeInvalidationMap::const_iterator i = |
| 419 job.session()->source().types.begin(); | 421 job.session()->source().types.begin(); |
| 420 i != job.session()->source().types.end(); | 422 i != job.session()->source().types.end(); |
| 421 ++i) { | 423 ++i) { |
| 422 requested_types.Put(i->first); | 424 requested_types.Put(i->first); |
| 423 } | 425 } |
| 424 | 426 |
| 425 // If all types are throttled, do not CONTINUE. Today, we don't treat | 427 // If all types are throttled, do not CONTINUE. Today, we don't treat |
| 426 // a per-datatype "unthrottle" event as something that should force a | 428 // a per-datatype "unthrottle" event as something that should force a |
| 427 // canary job. For this reason, there's no good time to reschedule this job | 429 // canary job. For this reason, there's no good time to reschedule this job |
| 428 // to run -- we'll lazily wait for an independent event to trigger a sync. | 430 // to run -- we'll lazily wait for an independent event to trigger a sync. |
| 429 // Note that there may already be such an event if we're in a WaitInterval, | 431 // Note that there may already be such an event if we're in a WaitInterval, |
| 430 // so we can retry it then. | 432 // so we can retry it then. |
| 431 if (!requested_types.Empty() && throttled_types.HasAll(requested_types)) | 433 if (!requested_types.Empty() && throttled_types.HasAll(requested_types)) |
| 432 return SAVE; | 434 return SAVE; |
| 433 } | 435 } |
| 434 | 436 |
| 435 if (wait_interval_.get()) | 437 if (wait_interval_.get()) |
| 436 return DecideWhileInWaitInterval(job); | 438 return DecideWhileInWaitInterval(job, is_canary); |
| 437 | 439 |
| 438 if (mode_ == CONFIGURATION_MODE) { | 440 if (mode_ == CONFIGURATION_MODE) { |
| 439 if (job.purpose() == SyncSessionJob::NUDGE) | 441 if (job.purpose() == SyncSessionJob::NUDGE) |
| 440 return SAVE; // Running requires a mode switch. | 442 return SAVE; // Running requires a mode switch. |
| 441 else if (job.purpose() == SyncSessionJob::CONFIGURATION) | 443 else if (job.purpose() == SyncSessionJob::CONFIGURATION) |
| 442 return CONTINUE; | 444 return CONTINUE; |
| 443 else | 445 else |
| 444 return DROP; | 446 return DROP; |
| 445 } | 447 } |
| 446 | 448 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 if (!session_context_->connection_manager()->HasInvalidAuthToken()) | 490 if (!session_context_->connection_manager()->HasInvalidAuthToken()) |
| 489 return CONTINUE; | 491 return CONTINUE; |
| 490 | 492 |
| 491 SDVLOG(2) << "No valid auth token. Using that to decide on job."; | 493 SDVLOG(2) << "No valid auth token. Using that to decide on job."; |
| 492 // Running the job would require updated auth, so we can't honour | 494 // Running the job would require updated auth, so we can't honour |
| 493 // job.scheduled_start(). | 495 // job.scheduled_start(). |
| 494 return job.purpose() == SyncSessionJob::NUDGE ? SAVE : DROP; | 496 return job.purpose() == SyncSessionJob::NUDGE ? SAVE : DROP; |
| 495 } | 497 } |
| 496 | 498 |
| 497 void SyncSchedulerImpl::HandleSaveJobDecision(scoped_ptr<SyncSessionJob> job) { | 499 void SyncSchedulerImpl::HandleSaveJobDecision(scoped_ptr<SyncSessionJob> job) { |
| 498 DCHECK_EQ(DecideOnJob(*job), SAVE); | |
| 499 const bool is_nudge = job->purpose() == SyncSessionJob::NUDGE; | 500 const bool is_nudge = job->purpose() == SyncSessionJob::NUDGE; |
| 500 if (is_nudge && pending_nudge_) { | 501 if (is_nudge && pending_nudge_) { |
| 501 SDVLOG(2) << "Coalescing a pending nudge"; | 502 SDVLOG(2) << "Coalescing a pending nudge"; |
| 502 // TODO(tim): This basically means we never use the more-careful coalescing | 503 // TODO(tim): This basically means we never use the more-careful coalescing |
| 503 // logic in ScheduleNudgeImpl that takes the min of the two nudge start | 504 // logic in ScheduleNudgeImpl that takes the min of the two nudge start |
| 504 // times, because we're calling this function first. Pull this out | 505 // times, because we're calling this function first. Pull this out |
| 505 // into a function to coalesce + set start times and reuse. | 506 // into a function to coalesce + set start times and reuse. |
| 506 pending_nudge_->mutable_session()->CoalesceSources( | 507 pending_nudge_->mutable_session()->CoalesceSources( |
| 507 job->session()->source()); | 508 job->session()->source()); |
| 508 return; | 509 return; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 SyncSourceInfo info(source, invalidation_map); | 616 SyncSourceInfo info(source, invalidation_map); |
| 616 UpdateNudgeTimeRecords(info); | 617 UpdateNudgeTimeRecords(info); |
| 617 | 618 |
| 618 scoped_ptr<SyncSessionJob> job(new SyncSessionJob( | 619 scoped_ptr<SyncSessionJob> job(new SyncSessionJob( |
| 619 SyncSessionJob::NUDGE, | 620 SyncSessionJob::NUDGE, |
| 620 TimeTicks::Now() + delay, | 621 TimeTicks::Now() + delay, |
| 621 CreateSyncSession(info).Pass(), | 622 CreateSyncSession(info).Pass(), |
| 622 ConfigurationParams(), | 623 ConfigurationParams(), |
| 623 nudge_location)); | 624 nudge_location)); |
| 624 job->set_destruction_observer(weak_ptr_factory_.GetWeakPtr()); | 625 job->set_destruction_observer(weak_ptr_factory_.GetWeakPtr()); |
| 625 JobProcessDecision decision = DecideOnJob(*job); | 626 JobProcessDecision decision = DecideOnJob(*job, false); |
| 626 SDVLOG(2) << "Should run " | 627 SDVLOG(2) << "Should run " |
| 627 << SyncSessionJob::GetPurposeString(job->purpose()) | 628 << SyncSessionJob::GetPurposeString(job->purpose()) |
| 628 << " job " << job->session() | 629 << " job " << job->session() |
| 629 << " in mode " << GetModeString(mode_) | 630 << " in mode " << GetModeString(mode_) |
| 630 << ": " << GetDecisionString(decision); | 631 << ": " << GetDecisionString(decision); |
| 631 if (decision != CONTINUE) { | 632 if (decision != CONTINUE) { |
| 632 // End of the line, though we may save the job for later. | 633 // End of the line, though we may save the job for later. |
| 633 if (decision == SAVE) { | 634 if (decision == SAVE) { |
| 634 HandleSaveJobDecision(job.Pass()); | 635 HandleSaveJobDecision(job.Pass()); |
| 635 } else { | 636 } else { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 if (job->purpose() == SyncSessionJob::NUDGE) { | 731 if (job->purpose() == SyncSessionJob::NUDGE) { |
| 731 SDVLOG_LOC(loc, 2) << "Resetting pending_nudge to "; | 732 SDVLOG_LOC(loc, 2) << "Resetting pending_nudge to "; |
| 732 DCHECK(!pending_nudge_ || pending_nudge_->session() == | 733 DCHECK(!pending_nudge_ || pending_nudge_->session() == |
| 733 job->session()); | 734 job->session()); |
| 734 set_pending_nudge(job.get()); | 735 set_pending_nudge(job.get()); |
| 735 } | 736 } |
| 736 | 737 |
| 737 PostDelayedTask(loc, "DoSyncSessionJob", | 738 PostDelayedTask(loc, "DoSyncSessionJob", |
| 738 base::Bind(base::IgnoreResult(&SyncSchedulerImpl::DoSyncSessionJob), | 739 base::Bind(base::IgnoreResult(&SyncSchedulerImpl::DoSyncSessionJob), |
| 739 weak_ptr_factory_.GetWeakPtr(), | 740 weak_ptr_factory_.GetWeakPtr(), |
| 740 base::Passed(&job)), | 741 base::Passed(&job), |
| 742 false), | |
| 741 delay); | 743 delay); |
| 742 } | 744 } |
| 743 | 745 |
| 744 bool SyncSchedulerImpl::DoSyncSessionJob(scoped_ptr<SyncSessionJob> job) { | 746 bool SyncSchedulerImpl::DoSyncSessionJob(scoped_ptr<SyncSessionJob> job, |
| 747 bool is_canary) { | |
| 745 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 748 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 746 if (job->purpose() == SyncSessionJob::NUDGE) { | 749 if (job->purpose() == SyncSessionJob::NUDGE) { |
| 747 if (pending_nudge_ == NULL || | 750 if (pending_nudge_ == NULL || |
| 748 pending_nudge_->session() != job->session()) { | 751 pending_nudge_->session() != job->session()) { |
| 749 // |job| is abandoned. | 752 // |job| is abandoned. |
| 750 SDVLOG(2) << "Dropping a nudge in " | 753 SDVLOG(2) << "Dropping a nudge in " |
| 751 << "DoSyncSessionJob because another nudge was scheduled"; | 754 << "DoSyncSessionJob because another nudge was scheduled"; |
| 752 return false; | 755 return false; |
| 753 } | 756 } |
| 754 pending_nudge_ = NULL; | 757 pending_nudge_ = NULL; |
| 755 } | 758 } |
| 756 | 759 |
| 757 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); | 760 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); |
| 758 JobProcessDecision decision = DecideOnJob(*job); | 761 JobProcessDecision decision = DecideOnJob(*job, is_canary); |
| 759 SDVLOG(2) << "Should run " | 762 SDVLOG(2) << "Should run " |
| 760 << SyncSessionJob::GetPurposeString(job->purpose()) | 763 << SyncSessionJob::GetPurposeString(job->purpose()) |
| 761 << " job " << job->session() | 764 << " job " << job->session() |
| 762 << " in mode " << GetModeString(mode_) | 765 << " in mode " << GetModeString(mode_) |
| 763 << " with source " << job->session()->source().updates_source | 766 << " with source " << job->session()->source().updates_source |
| 764 << ": " << GetDecisionString(decision); | 767 << ": " << GetDecisionString(decision); |
| 765 if (decision != CONTINUE) { | 768 if (decision != CONTINUE) { |
| 766 if (decision == SAVE) { | 769 if (decision == SAVE) { |
| 767 HandleSaveJobDecision(job.Pass()); | 770 HandleSaveJobDecision(job.Pass()); |
| 768 } else { | 771 } else { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 wait_interval_->timer.Start(FROM_HERE, wait_interval_->length, | 943 wait_interval_->timer.Start(FROM_HERE, wait_interval_->length, |
| 941 base::Bind(&SyncSchedulerImpl::DoCanaryJob, | 944 base::Bind(&SyncSchedulerImpl::DoCanaryJob, |
| 942 weak_ptr_factory_.GetWeakPtr(), | 945 weak_ptr_factory_.GetWeakPtr(), |
| 943 base::Passed(&job))); | 946 base::Passed(&job))); |
| 944 } | 947 } |
| 945 } | 948 } |
| 946 | 949 |
| 947 void SyncSchedulerImpl::HandleContinuationError( | 950 void SyncSchedulerImpl::HandleContinuationError( |
| 948 scoped_ptr<SyncSessionJob> old_job) { | 951 scoped_ptr<SyncSessionJob> old_job) { |
| 949 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 952 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 950 if (DCHECK_IS_ON()) { | |
| 951 if (IsBackingOff()) { | |
| 952 DCHECK(wait_interval_->timer.IsRunning() || old_job->is_canary()); | |
| 953 } | |
| 954 } | |
| 955 | 953 |
| 956 TimeDelta length = delay_provider_->GetDelay( | 954 TimeDelta length = delay_provider_->GetDelay( |
| 957 IsBackingOff() ? wait_interval_->length : | 955 IsBackingOff() ? wait_interval_->length : |
| 958 delay_provider_->GetInitialDelay( | 956 delay_provider_->GetInitialDelay( |
| 959 old_job->session()->status_controller().model_neutral_state())); | 957 old_job->session()->status_controller().model_neutral_state())); |
| 960 | 958 |
| 961 SDVLOG(2) << "In handle continuation error with " | 959 SDVLOG(2) << "In handle continuation error with " |
| 962 << SyncSessionJob::GetPurposeString(old_job->purpose()) | 960 << SyncSessionJob::GetPurposeString(old_job->purpose()) |
| 963 << " job. The time delta(ms) is " | 961 << " job. The time delta(ms) is " |
| 964 << length.InMilliseconds(); | 962 << length.InMilliseconds(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 started_ = false; | 1007 started_ = false; |
| 1010 } | 1008 } |
| 1011 if (!callback.is_null()) | 1009 if (!callback.is_null()) |
| 1012 callback.Run(); | 1010 callback.Run(); |
| 1013 } | 1011 } |
| 1014 | 1012 |
| 1015 void SyncSchedulerImpl::DoCanaryJob(scoped_ptr<SyncSessionJob> to_be_canary) { | 1013 void SyncSchedulerImpl::DoCanaryJob(scoped_ptr<SyncSessionJob> to_be_canary) { |
| 1016 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1014 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1017 SDVLOG(2) << "Do canary job"; | 1015 SDVLOG(2) << "Do canary job"; |
| 1018 | 1016 |
| 1019 // Only set canary privileges here, when we are about to run the job. This | |
| 1020 // avoids confusion in managing canary bits during scheduling, when you | |
| 1021 // consider that mode switches (e.g., to config) can "pre-empt" a NUDGE that | |
| 1022 // was scheduled as canary, and send it to an "unscheduled" state. | |
|
tim (not reviewing)
2013/03/02 01:03:39
This comment is even more relevant than it was bef
rlarocque
2013/03/02 01:21:12
OK, will fix.
| |
| 1023 to_be_canary->GrantCanaryPrivilege(); | |
| 1024 | |
| 1025 if (to_be_canary->purpose() == SyncSessionJob::NUDGE) { | 1017 if (to_be_canary->purpose() == SyncSessionJob::NUDGE) { |
| 1026 // TODO(tim): Bug 158313. Remove this check. | 1018 // TODO(tim): Bug 158313. Remove this check. |
| 1027 if (pending_nudge_ == NULL || | 1019 if (pending_nudge_ == NULL || |
| 1028 pending_nudge_->session() != to_be_canary->session()) { | 1020 pending_nudge_->session() != to_be_canary->session()) { |
| 1029 // |job| is abandoned. | 1021 // |job| is abandoned. |
| 1030 SDVLOG(2) << "Dropping a nudge in " | 1022 SDVLOG(2) << "Dropping a nudge in " |
| 1031 << "DoSyncSessionJob because another nudge was scheduled"; | 1023 << "DoSyncSessionJob because another nudge was scheduled"; |
| 1032 return; | 1024 return; |
| 1033 } | 1025 } |
| 1034 DCHECK_EQ(pending_nudge_->session(), to_be_canary->session()); | 1026 DCHECK_EQ(pending_nudge_->session(), to_be_canary->session()); |
| 1035 } | 1027 } |
| 1036 DoSyncSessionJob(to_be_canary.Pass()); | 1028 DoSyncSessionJob(to_be_canary.Pass(), true); |
| 1037 } | 1029 } |
| 1038 | 1030 |
| 1039 scoped_ptr<SyncSessionJob> SyncSchedulerImpl::TakePendingJobForCurrentMode() { | 1031 scoped_ptr<SyncSessionJob> SyncSchedulerImpl::TakePendingJobForCurrentMode() { |
| 1040 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1032 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1041 // If we find a scheduled pending_ job, abandon the old one and return a | 1033 // If we find a scheduled pending_ job, abandon the old one and return a |
| 1042 // a clone. If unscheduled, just hand over ownership. | 1034 // a clone. If unscheduled, just hand over ownership. |
| 1043 scoped_ptr<SyncSessionJob> candidate; | 1035 scoped_ptr<SyncSessionJob> candidate; |
| 1044 if (mode_ == CONFIGURATION_MODE && wait_interval_.get() | 1036 if (mode_ == CONFIGURATION_MODE && wait_interval_.get() |
| 1045 && wait_interval_->pending_configure_job) { | 1037 && wait_interval_->pending_configure_job) { |
| 1046 SDVLOG(2) << "Found pending configure job"; | 1038 SDVLOG(2) << "Found pending configure job"; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1198 | 1190 |
| 1199 #undef SDVLOG_LOC | 1191 #undef SDVLOG_LOC |
| 1200 | 1192 |
| 1201 #undef SDVLOG | 1193 #undef SDVLOG |
| 1202 | 1194 |
| 1203 #undef SLOG | 1195 #undef SLOG |
| 1204 | 1196 |
| 1205 #undef ENUM_CASE | 1197 #undef ENUM_CASE |
| 1206 | 1198 |
| 1207 } // namespace syncer | 1199 } // namespace syncer |
| OLD | NEW |