 Chromium Code Reviews
 Chromium Code Reviews Issue 14963002:
  sync: Report GetUpdate triggers to the server  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 14963002:
  sync: Report GetUpdate triggers to the server  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 started_ = true; | 220 started_ = true; | 
| 221 SendInitialSnapshot(); | 221 SendInitialSnapshot(); | 
| 222 } | 222 } | 
| 223 | 223 | 
| 224 DCHECK(!session_context_->account_name().empty()); | 224 DCHECK(!session_context_->account_name().empty()); | 
| 225 DCHECK(syncer_.get()); | 225 DCHECK(syncer_.get()); | 
| 226 Mode old_mode = mode_; | 226 Mode old_mode = mode_; | 
| 227 mode_ = mode; | 227 mode_ = mode; | 
| 228 AdjustPolling(UPDATE_INTERVAL); // Will kick start poll timer if needed. | 228 AdjustPolling(UPDATE_INTERVAL); // Will kick start poll timer if needed. | 
| 229 | 229 | 
| 230 if (old_mode != mode_ && mode_ == NORMAL_MODE && !nudge_tracker_.IsEmpty()) { | 230 if (old_mode != mode_ && mode_ == NORMAL_MODE && | 
| 231 nudge_tracker_.IsSyncRequired()) { | |
| 231 // We just got back to normal mode. Let's try to run the work that was | 232 // We just got back to normal mode. Let's try to run the work that was | 
| 232 // queued up while we were configuring. | 233 // queued up while we were configuring. | 
| 233 DoNudgeSyncSessionJob(NORMAL_PRIORITY); | 234 DoNudgeSyncSessionJob(NORMAL_PRIORITY); | 
| 234 } | 235 } | 
| 235 } | 236 } | 
| 236 | 237 | 
| 237 void SyncSchedulerImpl::SendInitialSnapshot() { | 238 void SyncSchedulerImpl::SendInitialSnapshot() { | 
| 238 DCHECK(CalledOnValidThread()); | 239 DCHECK(CalledOnValidThread()); | 
| 239 scoped_ptr<SyncSession> dummy(new SyncSession( | 240 scoped_ptr<SyncSession> dummy( | 
| 240 session_context_, this, SyncSourceInfo())); | 241 SyncSession::BuildForNonNudge(session_context_, this, SyncSourceInfo())); | 
| 241 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); | 242 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); | 
| 242 event.snapshot = dummy->TakeSnapshot(); | 243 event.snapshot = dummy->TakeSnapshot(); | 
| 243 session_context_->NotifyListeners(event); | 244 session_context_->NotifyListeners(event); | 
| 244 } | 245 } | 
| 245 | 246 | 
| 246 namespace { | 247 namespace { | 
| 247 | 248 | 
| 248 // Helper to extract the routing info corresponding to types in | 249 // Helper to extract the routing info corresponding to types in | 
| 249 // |types_to_download| from |current_routes|. | 250 // |types_to_download| from |current_routes|. | 
| 250 void BuildModelSafeParams( | 251 void BuildModelSafeParams( | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 } | 348 } | 
| 348 | 349 | 
| 349 if (mode_ == CONFIGURATION_MODE) { | 350 if (mode_ == CONFIGURATION_MODE) { | 
| 350 SDVLOG(1) << "Not running nudge because we're in configuration mode."; | 351 SDVLOG(1) << "Not running nudge because we're in configuration mode."; | 
| 351 return false; | 352 return false; | 
| 352 } | 353 } | 
| 353 | 354 | 
| 354 return true; | 355 return true; | 
| 355 } | 356 } | 
| 356 | 357 | 
| 357 void SyncSchedulerImpl::ScheduleNudgeAsync( | 358 void SyncSchedulerImpl::ScheduleLocalNudge( | 
| 358 const TimeDelta& desired_delay, | 359 const TimeDelta& desired_delay, | 
| 359 NudgeSource source, ModelTypeSet types, | 360 ModelTypeSet types, | 
| 360 const tracked_objects::Location& nudge_location) { | 361 const tracked_objects::Location& nudge_location) { | 
| 361 DCHECK(CalledOnValidThread()); | 362 DCHECK(CalledOnValidThread()); | 
| 363 DCHECK(!types.Empty()); | |
| 364 | |
| 362 SDVLOG_LOC(nudge_location, 2) | 365 SDVLOG_LOC(nudge_location, 2) | 
| 363 << "Nudge scheduled with delay " | 366 << "Scheduling sync because of local change to " | 
| 364 << desired_delay.InMilliseconds() << " ms, " | 367 << ModelTypeSetToString(types); | 
| 365 << "source " << GetNudgeSourceString(source) << ", " | 368 UpdateNudgeTimeRecords(types); | 
| 366 << "types " << ModelTypeSetToString(types); | 369 nudge_tracker_.RecordLocalChange(types); | 
| 367 | 370 ScheduleNudgeImpl(desired_delay, nudge_location); | 
| 368 ModelTypeInvalidationMap invalidation_map = | |
| 369 ModelTypeSetToInvalidationMap(types, std::string()); | |
| 370 SyncSchedulerImpl::ScheduleNudgeImpl(desired_delay, | |
| 371 GetUpdatesFromNudgeSource(source), | |
| 372 invalidation_map, | |
| 373 nudge_location); | |
| 374 } | 371 } | 
| 375 | 372 | 
| 376 void SyncSchedulerImpl::ScheduleNudgeWithStatesAsync( | 373 void SyncSchedulerImpl::ScheduleLocalRefreshRequest( | 
| 377 const TimeDelta& desired_delay, | 374 const TimeDelta& desired_delay, | 
| 378 NudgeSource source, const ModelTypeInvalidationMap& invalidation_map, | 375 ModelTypeSet types, | 
| 379 const tracked_objects::Location& nudge_location) { | 376 const tracked_objects::Location& nudge_location) { | 
| 380 DCHECK(CalledOnValidThread()); | 377 DCHECK(CalledOnValidThread()); | 
| 378 DCHECK(!types.Empty()); | |
| 379 | |
| 381 SDVLOG_LOC(nudge_location, 2) | 380 SDVLOG_LOC(nudge_location, 2) | 
| 382 << "Nudge scheduled with delay " | 381 << "Scheduling sync because of local refresch request for " | 
| 383 << desired_delay.InMilliseconds() << " ms, " | 382 << ModelTypeSetToString(types); | 
| 384 << "source " << GetNudgeSourceString(source) << ", " | 383 nudge_tracker_.RecordLocalRefreshRequest(types); | 
| 385 << "payloads " | 384 ScheduleNudgeImpl(desired_delay, nudge_location); | 
| 386 << ModelTypeInvalidationMapToString(invalidation_map); | |
| 387 | |
| 388 SyncSchedulerImpl::ScheduleNudgeImpl(desired_delay, | |
| 389 GetUpdatesFromNudgeSource(source), | |
| 390 invalidation_map, | |
| 391 nudge_location); | |
| 392 } | 385 } | 
| 393 | 386 | 
| 387 void SyncSchedulerImpl::ScheduleInvalidationNudge( | |
| 388 const TimeDelta& desired_delay, | |
| 389 const ModelTypeInvalidationMap& invalidation_map, | |
| 390 const tracked_objects::Location& nudge_location) { | |
| 391 DCHECK(CalledOnValidThread()); | |
| 392 DCHECK(!invalidation_map.empty()); | |
| 393 | |
| 394 SDVLOG_LOC(nudge_location, 2) | |
| 395 << "Scheduling sync because we received invalidation for " | |
| 396 << ModelTypeInvalidationMapToString(invalidation_map); | |
| 397 nudge_tracker_.RecordRemoteInvalidation(invalidation_map); | |
| 398 ScheduleNudgeImpl(desired_delay, nudge_location); | |
| 399 } | |
| 394 | 400 | 
| 395 // TODO(zea): Consider adding separate throttling/backoff for datatype | 401 // TODO(zea): Consider adding separate throttling/backoff for datatype | 
| 396 // refresh requests. | 402 // refresh requests. | 
| 397 void SyncSchedulerImpl::ScheduleNudgeImpl( | 403 void SyncSchedulerImpl::ScheduleNudgeImpl( | 
| 398 const TimeDelta& delay, | 404 const TimeDelta& delay, | 
| 399 GetUpdatesCallerInfo::GetUpdatesSource source, | |
| 400 const ModelTypeInvalidationMap& invalidation_map, | |
| 401 const tracked_objects::Location& nudge_location) { | 405 const tracked_objects::Location& nudge_location) { | 
| 402 DCHECK(CalledOnValidThread()); | 406 DCHECK(CalledOnValidThread()); | 
| 403 DCHECK(!invalidation_map.empty()) << "Nudge scheduled for no types!"; | |
| 404 | 407 | 
| 405 if (no_scheduling_allowed_) { | 408 if (no_scheduling_allowed_) { | 
| 406 NOTREACHED() << "Illegal to schedule job while session in progress."; | 409 NOTREACHED() << "Illegal to schedule job while session in progress."; | 
| 407 return; | 410 return; | 
| 408 } | 411 } | 
| 409 | 412 | 
| 410 if (!started_) { | 413 if (!started_) { | 
| 411 SDVLOG_LOC(nudge_location, 2) | 414 SDVLOG_LOC(nudge_location, 2) | 
| 412 << "Dropping nudge, scheduler is not running."; | 415 << "Dropping nudge, scheduler is not running."; | 
| 413 return; | 416 return; | 
| 414 } | 417 } | 
| 415 | 418 | 
| 416 SDVLOG_LOC(nudge_location, 2) | 419 SDVLOG_LOC(nudge_location, 2) | 
| 417 << "In ScheduleNudgeImpl with delay " | 420 << "In ScheduleNudgeImpl with delay " | 
| 418 << delay.InMilliseconds() << " ms, " | 421 << delay.InMilliseconds() << " ms"; | 
| 419 << "source " << GetUpdatesSourceString(source) << ", " | |
| 420 << "payloads " | |
| 421 << ModelTypeInvalidationMapToString(invalidation_map); | |
| 422 | |
| 423 SyncSourceInfo info(source, invalidation_map); | |
| 424 UpdateNudgeTimeRecords(info); | |
| 425 | |
| 426 // Coalesce the new nudge information with any existing information. | |
| 427 nudge_tracker_.CoalesceSources(info); | |
| 428 | 422 | 
| 429 if (!CanRunNudgeJobNow(NORMAL_PRIORITY)) | 423 if (!CanRunNudgeJobNow(NORMAL_PRIORITY)) | 
| 430 return; | 424 return; | 
| 431 | 425 | 
| 432 if (!started_) { | 426 if (!started_) { | 
| 433 SDVLOG_LOC(nudge_location, 2) | 427 SDVLOG_LOC(nudge_location, 2) | 
| 434 << "Schedule not started; not running a nudge."; | 428 << "Schedule not started; not running a nudge."; | 
| 435 return; | 429 return; | 
| 436 } | 430 } | 
| 437 | 431 | 
| (...skipping 28 matching lines...) Expand all Loading... | |
| 466 } | 460 } | 
| 467 | 461 | 
| 468 void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) { | 462 void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) { | 
| 469 DCHECK(CalledOnValidThread()); | 463 DCHECK(CalledOnValidThread()); | 
| 470 | 464 | 
| 471 if (!CanRunNudgeJobNow(priority)) | 465 if (!CanRunNudgeJobNow(priority)) | 
| 472 return; | 466 return; | 
| 473 | 467 | 
| 474 DVLOG(2) << "Will run normal mode sync cycle with routing info " | 468 DVLOG(2) << "Will run normal mode sync cycle with routing info " | 
| 475 << ModelSafeRoutingInfoToString(session_context_->routing_info()); | 469 << ModelSafeRoutingInfoToString(session_context_->routing_info()); | 
| 476 SyncSession session(session_context_, this, nudge_tracker_.source_info()); | 470 scoped_ptr<SyncSession> session( | 
| 477 bool premature_exit = !syncer_->SyncShare(&session, SYNCER_BEGIN, SYNCER_END); | 471 SyncSession::BuildForNudge( | 
| 472 session_context_, | |
| 473 this, | |
| 474 nudge_tracker_.GetSourceInfo(), | |
| 475 &nudge_tracker_)); | |
| 476 bool premature_exit = !syncer_->SyncShare(session.get(), | |
| 477 SYNCER_BEGIN, | |
| 478 SYNCER_END); | |
| 478 AdjustPolling(FORCE_RESET); | 479 AdjustPolling(FORCE_RESET); | 
| 479 | 480 | 
| 480 bool success = !premature_exit | 481 bool success = !premature_exit | 
| 481 && !sessions::HasSyncerError( | 482 && !sessions::HasSyncerError( | 
| 482 session.status_controller().model_neutral_state()); | 483 session->status_controller().model_neutral_state()); | 
| 483 | 484 | 
| 484 if (success) { | 485 if (success) { | 
| 485 // That cycle took care of any outstanding work we had. | 486 // That cycle took care of any outstanding work we had. | 
| 486 SDVLOG(2) << "Nudge succeeded."; | 487 SDVLOG(2) << "Nudge succeeded."; | 
| 487 nudge_tracker_.Reset(); | 488 nudge_tracker_.RecordSuccessfulSyncCycle(); | 
| 488 scheduled_nudge_time_ = base::TimeTicks(); | 489 scheduled_nudge_time_ = base::TimeTicks(); | 
| 489 | 490 | 
| 490 // If we're here, then we successfully reached the server. End all backoff. | 491 // If we're here, then we successfully reached the server. End all backoff. | 
| 491 wait_interval_.reset(); | 492 wait_interval_.reset(); | 
| 492 NotifyRetryTime(base::Time()); | 493 NotifyRetryTime(base::Time()); | 
| 493 return; | 494 return; | 
| 494 } else { | 495 } else { | 
| 495 HandleFailure(session.status_controller().model_neutral_state()); | 496 HandleFailure(session->status_controller().model_neutral_state()); | 
| 496 } | 497 } | 
| 497 } | 498 } | 
| 498 | 499 | 
| 499 bool SyncSchedulerImpl::DoConfigurationSyncSessionJob(JobPriority priority) { | 500 bool SyncSchedulerImpl::DoConfigurationSyncSessionJob(JobPriority priority) { | 
| 500 DCHECK(CalledOnValidThread()); | 501 DCHECK(CalledOnValidThread()); | 
| 501 DCHECK_EQ(mode_, CONFIGURATION_MODE); | 502 DCHECK_EQ(mode_, CONFIGURATION_MODE); | 
| 502 | 503 | 
| 503 if (!CanRunJobNow(priority)) { | 504 if (!CanRunJobNow(priority)) { | 
| 504 SDVLOG(2) << "Unable to run configure job right now."; | 505 SDVLOG(2) << "Unable to run configure job right now."; | 
| 505 return false; | 506 return false; | 
| 506 } | 507 } | 
| 507 | 508 | 
| 508 SDVLOG(2) << "Will run configure SyncShare with routes " | 509 SDVLOG(2) << "Will run configure SyncShare with routes " | 
| 509 << ModelSafeRoutingInfoToString(session_context_->routing_info()); | 510 << ModelSafeRoutingInfoToString(session_context_->routing_info()); | 
| 510 SyncSourceInfo source_info(pending_configure_params_->source, | 511 SyncSourceInfo source_info(pending_configure_params_->source, | 
| 511 ModelSafeRoutingInfoToInvalidationMap( | 512 ModelSafeRoutingInfoToInvalidationMap( | 
| 512 session_context_->routing_info(), | 513 session_context_->routing_info(), | 
| 513 std::string())); | 514 std::string())); | 
| 514 SyncSession session(session_context_, this, source_info); | 515 scoped_ptr<SyncSession> session( | 
| 515 bool premature_exit = !syncer_->SyncShare(&session, | 516 SyncSession::BuildForNonNudge(session_context_, this, source_info)); | 
| 517 bool premature_exit = !syncer_->SyncShare(session.get(), | |
| 516 DOWNLOAD_UPDATES, | 518 DOWNLOAD_UPDATES, | 
| 517 APPLY_UPDATES); | 519 APPLY_UPDATES); | 
| 518 AdjustPolling(FORCE_RESET); | 520 AdjustPolling(FORCE_RESET); | 
| 519 | 521 | 
| 520 bool success = !premature_exit | 522 bool success = !premature_exit | 
| 521 && !sessions::HasSyncerError( | 523 && !sessions::HasSyncerError( | 
| 522 session.status_controller().model_neutral_state()); | 524 session->status_controller().model_neutral_state()); | 
| 523 | 525 | 
| 524 if (success) { | 526 if (success) { | 
| 525 SDVLOG(2) << "Configure succeeded."; | 527 SDVLOG(2) << "Configure succeeded."; | 
| 526 pending_configure_params_->ready_task.Run(); | 528 pending_configure_params_->ready_task.Run(); | 
| 527 pending_configure_params_.reset(); | 529 pending_configure_params_.reset(); | 
| 528 | 530 | 
| 529 // If we're here, then we successfully reached the server. End all backoff. | 531 // If we're here, then we successfully reached the server. End all backoff. | 
| 530 wait_interval_.reset(); | 532 wait_interval_.reset(); | 
| 531 NotifyRetryTime(base::Time()); | 533 NotifyRetryTime(base::Time()); | 
| 532 return true; | 534 return true; | 
| 533 } else { | 535 } else { | 
| 534 HandleFailure(session.status_controller().model_neutral_state()); | 536 HandleFailure(session->status_controller().model_neutral_state()); | 
| 535 return false; | 537 return false; | 
| 536 } | 538 } | 
| 537 } | 539 } | 
| 538 | 540 | 
| 539 void SyncSchedulerImpl::HandleFailure( | 541 void SyncSchedulerImpl::HandleFailure( | 
| 540 const sessions::ModelNeutralState& model_neutral_state) { | 542 const sessions::ModelNeutralState& model_neutral_state) { | 
| 541 if (IsSyncingCurrentlySilenced()) { | 543 if (IsSyncingCurrentlySilenced()) { | 
| 542 SDVLOG(2) << "Was throttled during previous sync cycle."; | 544 SDVLOG(2) << "Was throttled during previous sync cycle."; | 
| 543 RestartWaiting(); | 545 RestartWaiting(); | 
| 544 } else { | 546 } else { | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 561 return; | 563 return; | 
| 562 } | 564 } | 
| 563 | 565 | 
| 564 if (mode_ != NORMAL_MODE) { | 566 if (mode_ != NORMAL_MODE) { | 
| 565 SDVLOG(2) << "Not running poll job in configure mode."; | 567 SDVLOG(2) << "Not running poll job in configure mode."; | 
| 566 return; | 568 return; | 
| 567 } | 569 } | 
| 568 | 570 | 
| 569 SDVLOG(2) << "Polling with routes " | 571 SDVLOG(2) << "Polling with routes " | 
| 570 << ModelSafeRoutingInfoToString(session_context_->routing_info()); | 572 << ModelSafeRoutingInfoToString(session_context_->routing_info()); | 
| 571 SyncSession session(session_context_, this, info); | 573 scoped_ptr<SyncSession> session( | 
| 572 syncer_->SyncShare(&session, SYNCER_BEGIN, SYNCER_END); | 574 SyncSession::BuildForNonNudge(session_context_, this, info)); | 
| 575 syncer_->SyncShare(session.get(), SYNCER_BEGIN, SYNCER_END); | |
| 573 | 576 | 
| 574 AdjustPolling(UPDATE_INTERVAL); | 577 AdjustPolling(UPDATE_INTERVAL); | 
| 575 | 578 | 
| 576 if (IsSyncingCurrentlySilenced()) { | 579 if (IsSyncingCurrentlySilenced()) { | 
| 577 SDVLOG(2) << "Poll request got us throttled."; | 580 SDVLOG(2) << "Poll request got us throttled."; | 
| 578 // The OnSilencedUntil() call set up the WaitInterval for us. All we need | 581 // The OnSilencedUntil() call set up the WaitInterval for us. All we need | 
| 579 // to do is start the timer. | 582 // to do is start the timer. | 
| 580 RestartWaiting(); | 583 RestartWaiting(); | 
| 581 } | 584 } | 
| 582 } | 585 } | 
| 583 | 586 | 
| 584 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { | 587 void SyncSchedulerImpl::UpdateNudgeTimeRecords(ModelTypeSet types) { | 
| 585 DCHECK(CalledOnValidThread()); | 588 DCHECK(CalledOnValidThread()); | 
| 586 | |
| 587 // We are interested in recording time between local nudges for datatypes. | |
| 588 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. | |
| 589 if (info.updates_source != GetUpdatesCallerInfo::LOCAL) | |
| 590 return; | |
| 591 | |
| 592 base::TimeTicks now = TimeTicks::Now(); | 589 base::TimeTicks now = TimeTicks::Now(); | 
| 593 // Update timing information for how often datatypes are triggering nudges. | 590 // Update timing information for how often datatypes are triggering nudges. | 
| 594 for (ModelTypeInvalidationMap::const_iterator iter = info.types.begin(); | 591 for (ModelTypeSet::Iterator iter = types.First(); iter.Good(); iter.Inc()) { | 
| 595 iter != info.types.end(); | 592 base::TimeTicks previous = last_local_nudges_by_model_type_[iter.Get()]; | 
| 596 ++iter) { | 593 last_local_nudges_by_model_type_[iter.Get()] = now; | 
| 597 base::TimeTicks previous = last_local_nudges_by_model_type_[iter->first]; | |
| 598 last_local_nudges_by_model_type_[iter->first] = now; | |
| 599 if (previous.is_null()) | 594 if (previous.is_null()) | 
| 600 continue; | 595 continue; | 
| 601 | 596 | 
| 602 #define PER_DATA_TYPE_MACRO(type_str) \ | 597 #define PER_DATA_TYPE_MACRO(type_str) \ | 
| 603 SYNC_FREQ_HISTOGRAM("Sync.Freq" type_str, now - previous); | 598 SYNC_FREQ_HISTOGRAM("Sync.Freq" type_str, now - previous); | 
| 604 SYNC_DATA_TYPE_HISTOGRAM(iter->first); | 599 SYNC_DATA_TYPE_HISTOGRAM(iter.Get()); | 
| 605 #undef PER_DATA_TYPE_MACRO | 600 #undef PER_DATA_TYPE_MACRO | 
| 606 } | 601 } | 
| 607 } | 602 } | 
| 608 | 603 | 
| 609 void SyncSchedulerImpl::AdjustPolling(PollAdjustType type) { | 604 void SyncSchedulerImpl::AdjustPolling(PollAdjustType type) { | 
| 610 DCHECK(CalledOnValidThread()); | 605 DCHECK(CalledOnValidThread()); | 
| 611 | 606 | 
| 612 TimeDelta poll = (!session_context_->notifications_enabled()) ? | 607 TimeDelta poll = (!session_context_->notifications_enabled()) ? | 
| 613 syncer_short_poll_interval_seconds_ : | 608 syncer_short_poll_interval_seconds_ : | 
| 614 syncer_long_poll_interval_seconds_; | 609 syncer_long_poll_interval_seconds_; | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 } | 681 } | 
| 687 | 682 | 
| 688 // This is the only place where we invoke DoSyncSessionJob with canary | 683 // This is the only place where we invoke DoSyncSessionJob with canary | 
| 689 // privileges. Everyone else should use NORMAL_PRIORITY. | 684 // privileges. Everyone else should use NORMAL_PRIORITY. | 
| 690 void SyncSchedulerImpl::TryCanaryJob() { | 685 void SyncSchedulerImpl::TryCanaryJob() { | 
| 691 DCHECK(CalledOnValidThread()); | 686 DCHECK(CalledOnValidThread()); | 
| 692 | 687 | 
| 693 if (mode_ == CONFIGURATION_MODE && pending_configure_params_) { | 688 if (mode_ == CONFIGURATION_MODE && pending_configure_params_) { | 
| 694 SDVLOG(2) << "Found pending configure job; will run as canary"; | 689 SDVLOG(2) << "Found pending configure job; will run as canary"; | 
| 695 DoConfigurationSyncSessionJob(CANARY_PRIORITY); | 690 DoConfigurationSyncSessionJob(CANARY_PRIORITY); | 
| 696 } else if (mode_ == NORMAL_MODE && !nudge_tracker_.IsEmpty()) { | 691 } else if (mode_ == NORMAL_MODE && nudge_tracker_.IsSyncRequired()) { | 
| 697 SDVLOG(2) << "Found pending nudge job; will run as canary"; | 692 SDVLOG(2) << "Found pending nudge job; will run as canary"; | 
| 698 DoNudgeSyncSessionJob(CANARY_PRIORITY); | 693 DoNudgeSyncSessionJob(CANARY_PRIORITY); | 
| 699 } else { | 694 } else { | 
| 700 SDVLOG(2) << "Found no work to do; will not run a canary"; | 695 SDVLOG(2) << "Found no work to do; will not run a canary"; | 
| 701 } | 696 } | 
| 702 } | 697 } | 
| 703 | 698 | 
| 704 void SyncSchedulerImpl::PollTimerCallback() { | 699 void SyncSchedulerImpl::PollTimerCallback() { | 
| 705 DCHECK(CalledOnValidThread()); | 700 DCHECK(CalledOnValidThread()); | 
| 706 if (no_scheduling_allowed_) { | 701 if (no_scheduling_allowed_) { | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 SDVLOG(2) << "Sync Scheduler requesting early exit."; | 801 SDVLOG(2) << "Sync Scheduler requesting early exit."; | 
| 807 syncer_->RequestEarlyExit(); // Thread-safe. | 802 syncer_->RequestEarlyExit(); // Thread-safe. | 
| 808 } | 803 } | 
| 809 if (IsActionableError(snapshot.model_neutral_state().sync_protocol_error)) | 804 if (IsActionableError(snapshot.model_neutral_state().sync_protocol_error)) | 
| 810 OnActionableError(snapshot); | 805 OnActionableError(snapshot); | 
| 811 } | 806 } | 
| 812 | 807 | 
| 813 void SyncSchedulerImpl::SetNotificationsEnabled(bool notifications_enabled) { | 808 void SyncSchedulerImpl::SetNotificationsEnabled(bool notifications_enabled) { | 
| 814 DCHECK(CalledOnValidThread()); | 809 DCHECK(CalledOnValidThread()); | 
| 815 session_context_->set_notifications_enabled(notifications_enabled); | 810 session_context_->set_notifications_enabled(notifications_enabled); | 
| 811 if (notifications_enabled) { | |
| 
tim (not reviewing)
2013/05/07 20:34:13
nit - the majority of this file uses no { } on sin
 
rlarocque
2013/05/07 21:50:57
Does that apply to if / else pairs as well?  I don
 
tim (not reviewing)
2013/05/07 22:40:33
It applies if all branches are single lines. If on
 | |
| 812 nudge_tracker_.OnInvalidationsEnabled(); | |
| 813 } else { | |
| 814 nudge_tracker_.OnInvalidationsDisabled(); | |
| 815 } | |
| 816 } | 816 } | 
| 817 | 817 | 
| 818 base::TimeDelta SyncSchedulerImpl::GetSessionsCommitDelay() const { | 818 base::TimeDelta SyncSchedulerImpl::GetSessionsCommitDelay() const { | 
| 819 DCHECK(CalledOnValidThread()); | 819 DCHECK(CalledOnValidThread()); | 
| 820 return sessions_commit_delay_; | 820 return sessions_commit_delay_; | 
| 821 } | 821 } | 
| 822 | 822 | 
| 823 #undef SDVLOG_LOC | 823 #undef SDVLOG_LOC | 
| 824 | 824 | 
| 825 #undef SDVLOG | 825 #undef SDVLOG | 
| 826 | 826 | 
| 827 #undef SLOG | 827 #undef SLOG | 
| 828 | 828 | 
| 829 #undef ENUM_CASE | 829 #undef ENUM_CASE | 
| 830 | 830 | 
| 831 } // namespace syncer | 831 } // namespace syncer | 
| OLD | NEW |