Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Side by Side Diff: chrome/browser/sync/engine/sync_scheduler.cc

Issue 7281017: [Sync] Add RequestCleanupDisabledTypes() method to SyncManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/sync_scheduler.h" 5 #include "chrome/browser/sync/engine/sync_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/tracked.h" 14 #include "base/tracked.h"
15 #include "chrome/browser/sync/engine/syncer.h" 15 #include "chrome/browser/sync/engine/syncer.h"
16 #include "chrome/browser/sync/protocol/sync.pb.h"
16 #include "chrome/browser/sync/protocol/proto_enum_conversions.h" 17 #include "chrome/browser/sync/protocol/proto_enum_conversions.h"
17 #include "chrome/browser/sync/util/logging.h" 18 #include "chrome/browser/sync/util/logging.h"
18 19
19 using base::TimeDelta; 20 using base::TimeDelta;
20 using base::TimeTicks; 21 using base::TimeTicks;
21 22
22 namespace browser_sync { 23 namespace browser_sync {
23 24
24 using sessions::SyncSession; 25 using sessions::SyncSession;
25 using sessions::SyncSessionSnapshot; 26 using sessions::SyncSessionSnapshot;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 69 }
69 70
70 const char* SyncScheduler::SyncSessionJob::GetPurposeString( 71 const char* SyncScheduler::SyncSessionJob::GetPurposeString(
71 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { 72 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) {
72 switch (purpose) { 73 switch (purpose) {
73 ENUM_CASE(UNKNOWN); 74 ENUM_CASE(UNKNOWN);
74 ENUM_CASE(POLL); 75 ENUM_CASE(POLL);
75 ENUM_CASE(NUDGE); 76 ENUM_CASE(NUDGE);
76 ENUM_CASE(CLEAR_USER_DATA); 77 ENUM_CASE(CLEAR_USER_DATA);
77 ENUM_CASE(CONFIGURATION); 78 ENUM_CASE(CONFIGURATION);
79 ENUM_CASE(CLEANUP_DISABLED_TYPES);
78 } 80 }
79 NOTREACHED(); 81 NOTREACHED();
80 return ""; 82 return "";
81 } 83 }
82 84
83 TimeDelta SyncScheduler::DelayProvider::GetDelay( 85 TimeDelta SyncScheduler::DelayProvider::GetDelay(
84 const base::TimeDelta& last_delay) { 86 const base::TimeDelta& last_delay) {
85 return SyncScheduler::GetRecommendedDelay(last_delay); 87 return SyncScheduler::GetRecommendedDelay(last_delay);
86 } 88 }
87 89
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // We just changed our mode. See if there are any pending jobs that we could 247 // We just changed our mode. See if there are any pending jobs that we could
246 // execute in the new mode. 248 // execute in the new mode.
247 DoPendingJobIfPossible(false); 249 DoPendingJobIfPossible(false);
248 } 250 }
249 251
250 SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval( 252 SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval(
251 const SyncSessionJob& job) { 253 const SyncSessionJob& job) {
252 DCHECK_EQ(MessageLoop::current(), sync_loop_); 254 DCHECK_EQ(MessageLoop::current(), sync_loop_);
253 DCHECK(wait_interval_.get()); 255 DCHECK(wait_interval_.get());
254 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA); 256 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA);
257 DCHECK_NE(job.purpose, SyncSessionJob::CLEANUP_DISABLED_TYPES);
255 258
256 SVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " 259 SVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode "
257 << WaitInterval::GetModeString(wait_interval_->mode) 260 << WaitInterval::GetModeString(wait_interval_->mode)
258 << (wait_interval_->had_nudge ? " (had nudge)" : "") 261 << (wait_interval_->had_nudge ? " (had nudge)" : "")
259 << (job.is_canary_job ? " (canary)" : ""); 262 << (job.is_canary_job ? " (canary)" : "");
260 263
261 if (job.purpose == SyncSessionJob::POLL) 264 if (job.purpose == SyncSessionJob::POLL)
262 return DROP; 265 return DROP;
263 266
264 DCHECK(job.purpose == SyncSessionJob::NUDGE || 267 DCHECK(job.purpose == SyncSessionJob::NUDGE ||
265 job.purpose == SyncSessionJob::CONFIGURATION); 268 job.purpose == SyncSessionJob::CONFIGURATION);
266 if (wait_interval_->mode == WaitInterval::THROTTLED) 269 if (wait_interval_->mode == WaitInterval::THROTTLED)
267 return SAVE; 270 return SAVE;
268 271
269 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); 272 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF);
270 if (job.purpose == SyncSessionJob::NUDGE) { 273 if (job.purpose == SyncSessionJob::NUDGE) {
271 if (mode_ == CONFIGURATION_MODE) 274 if (mode_ == CONFIGURATION_MODE)
272 return SAVE; 275 return SAVE;
273 276
274 // If we already had one nudge then just drop this nudge. We will retry 277 // If we already had one nudge then just drop this nudge. We will retry
275 // later when the timer runs out. 278 // later when the timer runs out.
276 return wait_interval_->had_nudge ? DROP : CONTINUE; 279 return wait_interval_->had_nudge ? DROP : CONTINUE;
277 } 280 }
278 // This is a config job. 281 // This is a config job.
279 return job.is_canary_job ? CONTINUE : SAVE; 282 return job.is_canary_job ? CONTINUE : SAVE;
280 } 283 }
281 284
282 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob( 285 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob(
283 const SyncSessionJob& job) { 286 const SyncSessionJob& job) {
284 DCHECK_EQ(MessageLoop::current(), sync_loop_); 287 DCHECK_EQ(MessageLoop::current(), sync_loop_);
285 if (job.purpose == SyncSessionJob::CLEAR_USER_DATA) 288 if (job.purpose == SyncSessionJob::CLEAR_USER_DATA ||
289 job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES)
286 return CONTINUE; 290 return CONTINUE;
287 291
288 if (wait_interval_.get()) 292 if (wait_interval_.get())
289 return DecideWhileInWaitInterval(job); 293 return DecideWhileInWaitInterval(job);
290 294
291 if (mode_ == CONFIGURATION_MODE) { 295 if (mode_ == CONFIGURATION_MODE) {
292 if (job.purpose == SyncSessionJob::NUDGE) 296 if (job.purpose == SyncSessionJob::NUDGE)
293 return SAVE; 297 return SAVE;
294 else if (job.purpose == SyncSessionJob::CONFIGURATION) 298 else if (job.purpose == SyncSessionJob::CONFIGURATION)
295 return CONTINUE; 299 return CONTINUE;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 354
351 DCHECK(job.purpose == SyncSessionJob::NUDGE || job.purpose == 355 DCHECK(job.purpose == SyncSessionJob::NUDGE || job.purpose ==
352 SyncSessionJob::CONFIGURATION); 356 SyncSessionJob::CONFIGURATION);
353 357
354 SaveJob(job); 358 SaveJob(job);
355 return false; 359 return false;
356 } 360 }
357 361
358 void SyncScheduler::SaveJob(const SyncSessionJob& job) { 362 void SyncScheduler::SaveJob(const SyncSessionJob& job) {
359 DCHECK_EQ(MessageLoop::current(), sync_loop_); 363 DCHECK_EQ(MessageLoop::current(), sync_loop_);
360 DCHECK(job.purpose != SyncSessionJob::CLEAR_USER_DATA); 364 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA);
365 DCHECK_NE(job.purpose, SyncSessionJob::CLEANUP_DISABLED_TYPES);
361 if (job.purpose == SyncSessionJob::NUDGE) { 366 if (job.purpose == SyncSessionJob::NUDGE) {
362 SVLOG(2) << "Saving a nudge job"; 367 SVLOG(2) << "Saving a nudge job";
363 InitOrCoalescePendingJob(job); 368 InitOrCoalescePendingJob(job);
364 } else if (job.purpose == SyncSessionJob::CONFIGURATION){ 369 } else if (job.purpose == SyncSessionJob::CONFIGURATION){
365 SVLOG(2) << "Saving a configuration job"; 370 SVLOG(2) << "Saving a configuration job";
366 DCHECK(wait_interval_.get()); 371 DCHECK(wait_interval_.get());
367 DCHECK(mode_ == CONFIGURATION_MODE); 372 DCHECK(mode_ == CONFIGURATION_MODE);
368 373
369 SyncSession* old = job.session.get(); 374 SyncSession* old = job.session.get();
370 SyncSession* s(new SyncSession(session_context_.get(), this, 375 SyncSession* s(new SyncSession(session_context_.get(), this,
(...skipping 13 matching lines...) Expand all
384 ModelSafeGroup group; 389 ModelSafeGroup group;
385 }; 390 };
386 391
387 void SyncScheduler::ScheduleClearUserData() { 392 void SyncScheduler::ScheduleClearUserData() {
388 DCHECK_EQ(MessageLoop::current(), sync_loop_); 393 DCHECK_EQ(MessageLoop::current(), sync_loop_);
389 PostTask(FROM_HERE, "ScheduleClearUserDataImpl", 394 PostTask(FROM_HERE, "ScheduleClearUserDataImpl",
390 method_factory_.NewRunnableMethod( 395 method_factory_.NewRunnableMethod(
391 &SyncScheduler::ScheduleClearUserDataImpl)); 396 &SyncScheduler::ScheduleClearUserDataImpl));
392 } 397 }
393 398
399 void SyncScheduler::ScheduleCleanupDisabledTypes() {
400 DCHECK_EQ(MessageLoop::current(), sync_loop_);
401 PostTask(FROM_HERE, "ScheduleCleanupDisabledTypes",
402 method_factory_.NewRunnableMethod(
403 &SyncScheduler::ScheduleCleanupDisabledTypesImpl));
404 }
405
394 void SyncScheduler::ScheduleNudge( 406 void SyncScheduler::ScheduleNudge(
395 const TimeDelta& delay, 407 const TimeDelta& delay,
396 NudgeSource source, const ModelTypeBitSet& types, 408 NudgeSource source, const ModelTypeBitSet& types,
397 const tracked_objects::Location& nudge_location) { 409 const tracked_objects::Location& nudge_location) {
398 DCHECK_EQ(MessageLoop::current(), sync_loop_); 410 DCHECK_EQ(MessageLoop::current(), sync_loop_);
399 SVLOG_LOC(nudge_location, 2) 411 SVLOG_LOC(nudge_location, 2)
400 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " 412 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, "
401 << "source " << GetNudgeSourceString(source) << ", " 413 << "source " << GetNudgeSourceString(source) << ", "
402 << "types " << syncable::ModelTypeBitSetToString(types); 414 << "types " << syncable::ModelTypeBitSetToString(types);
403 415
(...skipping 19 matching lines...) Expand all
423 435
424 PostTask(nudge_location, "ScheduleNudgeImpl", 436 PostTask(nudge_location, "ScheduleNudgeImpl",
425 method_factory_.NewRunnableMethod( 437 method_factory_.NewRunnableMethod(
426 &SyncScheduler::ScheduleNudgeImpl, delay, 438 &SyncScheduler::ScheduleNudgeImpl, delay,
427 GetUpdatesFromNudgeSource(source), types_with_payloads, false, 439 GetUpdatesFromNudgeSource(source), types_with_payloads, false,
428 nudge_location)); 440 nudge_location));
429 } 441 }
430 442
431 void SyncScheduler::ScheduleClearUserDataImpl() { 443 void SyncScheduler::ScheduleClearUserDataImpl() {
432 DCHECK_EQ(MessageLoop::current(), sync_loop_); 444 DCHECK_EQ(MessageLoop::current(), sync_loop_);
433 SyncSession* session = new SyncSession(session_context_.get(), this, 445 ScheduleSyncSessionJob(
434 SyncSourceInfo(), ModelSafeRoutingInfo(), 446 TimeDelta::FromSeconds(0), SyncSessionJob::CLEAR_USER_DATA,
435 std::vector<ModelSafeWorker*>()); 447 CreateSyncSession(SyncSourceInfo()), FROM_HERE);
436 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), 448 }
437 SyncSessionJob::CLEAR_USER_DATA, session, FROM_HERE); 449
450 void SyncScheduler::ScheduleCleanupDisabledTypesImpl() {
451 DCHECK_EQ(MessageLoop::current(), sync_loop_);
452 ScheduleSyncSessionJob(
453 TimeDelta::FromSeconds(0), SyncSessionJob::CLEANUP_DISABLED_TYPES,
454 CreateSyncSession(SyncSourceInfo()), FROM_HERE);
438 } 455 }
439 456
440 void SyncScheduler::ScheduleNudgeImpl( 457 void SyncScheduler::ScheduleNudgeImpl(
441 const TimeDelta& delay, 458 const TimeDelta& delay,
442 GetUpdatesCallerInfo::GetUpdatesSource source, 459 GetUpdatesCallerInfo::GetUpdatesSource source,
443 const ModelTypePayloadMap& types_with_payloads, 460 const ModelTypePayloadMap& types_with_payloads,
444 bool is_canary_job, const tracked_objects::Location& nudge_location) { 461 bool is_canary_job, const tracked_objects::Location& nudge_location) {
445 DCHECK_EQ(MessageLoop::current(), sync_loop_); 462 DCHECK_EQ(MessageLoop::current(), sync_loop_);
446 463
447 SVLOG_LOC(nudge_location, 2) 464 SVLOG_LOC(nudge_location, 2)
448 << "In ScheduleNudgeImpl with delay " 465 << "In ScheduleNudgeImpl with delay "
449 << delay.InMilliseconds() << " ms, " 466 << delay.InMilliseconds() << " ms, "
450 << "source " << GetUpdatesSourceString(source) << ", " 467 << "source " << GetUpdatesSourceString(source) << ", "
451 << "payloads " 468 << "payloads "
452 << syncable::ModelTypePayloadMapToString(types_with_payloads) 469 << syncable::ModelTypePayloadMapToString(types_with_payloads)
453 << (is_canary_job ? " (canary)" : ""); 470 << (is_canary_job ? " (canary)" : "");
454 471
455 // Note we currently nudge for all types regardless of the ones incurring
456 // the nudge. Doing different would throw off some syncer commands like
457 // CleanupDisabledTypes. We may want to change this in the future.
458 SyncSourceInfo info(source, types_with_payloads); 472 SyncSourceInfo info(source, types_with_payloads);
459 473
460 SyncSession* session(CreateSyncSession(info)); 474 SyncSession* session(CreateSyncSession(info));
461 SyncSessionJob job(SyncSessionJob::NUDGE, TimeTicks::Now() + delay, 475 SyncSessionJob job(SyncSessionJob::NUDGE, TimeTicks::Now() + delay,
462 make_linked_ptr(session), is_canary_job, 476 make_linked_ptr(session), is_canary_job,
463 nudge_location); 477 nudge_location);
464 478
465 session = NULL; 479 session = NULL;
466 if (!ShouldRunJob(job)) 480 if (!ShouldRunJob(job))
467 return; 481 return;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 PostDelayedTask(from_here, "DoSyncSessionJob", 638 PostDelayedTask(from_here, "DoSyncSessionJob",
625 method_factory_.NewRunnableMethod( 639 method_factory_.NewRunnableMethod(
626 &SyncScheduler::DoSyncSessionJob, job), 640 &SyncScheduler::DoSyncSessionJob, job),
627 delay.InMilliseconds()); 641 delay.InMilliseconds());
628 } 642 }
629 643
630 void SyncScheduler::SetSyncerStepsForPurpose( 644 void SyncScheduler::SetSyncerStepsForPurpose(
631 SyncSessionJob::SyncSessionJobPurpose purpose, 645 SyncSessionJob::SyncSessionJobPurpose purpose,
632 SyncerStep* start, SyncerStep* end) { 646 SyncerStep* start, SyncerStep* end) {
633 DCHECK_EQ(MessageLoop::current(), sync_loop_); 647 DCHECK_EQ(MessageLoop::current(), sync_loop_);
634 *end = SYNCER_END;
635 switch (purpose) { 648 switch (purpose) {
636 case SyncSessionJob::CONFIGURATION: 649 case SyncSessionJob::CONFIGURATION:
637 *start = DOWNLOAD_UPDATES; 650 *start = DOWNLOAD_UPDATES;
638 *end = APPLY_UPDATES; 651 *end = APPLY_UPDATES;
639 return; 652 return;
640 case SyncSessionJob::CLEAR_USER_DATA: 653 case SyncSessionJob::CLEAR_USER_DATA:
641 *start = CLEAR_PRIVATE_DATA; 654 *start = CLEAR_PRIVATE_DATA;
655 *end = CLEAR_PRIVATE_DATA;
642 return; 656 return;
643 case SyncSessionJob::NUDGE: 657 case SyncSessionJob::NUDGE:
644 case SyncSessionJob::POLL: 658 case SyncSessionJob::POLL:
645 *start = SYNCER_BEGIN; 659 *start = SYNCER_BEGIN;
660 *end = SYNCER_END;
661 return;
662 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
663 *start = CLEANUP_DISABLED_TYPES;
664 *end = CLEANUP_DISABLED_TYPES;
646 return; 665 return;
647 default: 666 default:
648 NOTREACHED(); 667 NOTREACHED();
668 *start = SYNCER_END;
669 *end = SYNCER_END;
670 return;
649 } 671 }
650 } 672 }
651 673
652 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) { 674 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) {
653 DCHECK_EQ(MessageLoop::current(), sync_loop_); 675 DCHECK_EQ(MessageLoop::current(), sync_loop_);
654 if (!ShouldRunJob(job)) { 676 if (!ShouldRunJob(job)) {
655 SLOG(WARNING) 677 SLOG(WARNING)
656 << "Not executing " 678 << "Not executing "
657 << SyncSessionJob::GetPurposeString(job.purpose) << " job from " 679 << SyncSessionJob::GetPurposeString(job.purpose) << " job from "
658 << GetUpdatesSourceString(job.session->source().updates_source); 680 << GetUpdatesSourceString(job.session->source().updates_source);
(...skipping 11 matching lines...) Expand all
670 692
671 // Create the session with the latest model safe table and use it to purge 693 // Create the session with the latest model safe table and use it to purge
672 // and update any disabled or modified entries in the job. 694 // and update any disabled or modified entries in the job.
673 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); 695 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source()));
674 696
675 job.session->RebaseRoutingInfoWithLatest(session.get()); 697 job.session->RebaseRoutingInfoWithLatest(session.get());
676 } 698 }
677 SVLOG(2) << "DoSyncSessionJob with " 699 SVLOG(2) << "DoSyncSessionJob with "
678 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; 700 << SyncSessionJob::GetPurposeString(job.purpose) << " job";
679 701
680 SyncerStep begin(SYNCER_BEGIN); 702 SyncerStep begin(SYNCER_END);
681 SyncerStep end(SYNCER_END); 703 SyncerStep end(SYNCER_END);
682 SetSyncerStepsForPurpose(job.purpose, &begin, &end); 704 SetSyncerStepsForPurpose(job.purpose, &begin, &end);
683 705
684 bool has_more_to_sync = true; 706 bool has_more_to_sync = true;
685 while (ShouldRunJob(job) && has_more_to_sync) { 707 while (ShouldRunJob(job) && has_more_to_sync) {
686 SVLOG(2) << "Calling SyncShare."; 708 SVLOG(2) << "Calling SyncShare.";
687 // Synchronously perform the sync session from this thread. 709 // Synchronously perform the sync session from this thread.
688 syncer_->SyncShare(job.session.get(), begin, end); 710 syncer_->SyncShare(job.session.get(), begin, end);
689 has_more_to_sync = job.session->HasMoreToSync(); 711 has_more_to_sync = job.session->HasMoreToSync();
690 if (has_more_to_sync) 712 if (has_more_to_sync)
691 job.session->ResetTransientState(); 713 job.session->ResetTransientState();
692 } 714 }
693 SVLOG(2) << "Done SyncShare looping."; 715 SVLOG(2) << "Done SyncShare looping.";
716
694 FinishSyncSessionJob(job); 717 FinishSyncSessionJob(job);
695 } 718 }
696 719
697 void SyncScheduler::UpdateCarryoverSessionState( 720 void SyncScheduler::UpdateCarryoverSessionState(
698 const SyncSessionJob& old_job) { 721 const SyncSessionJob& old_job) {
699 DCHECK_EQ(MessageLoop::current(), sync_loop_); 722 DCHECK_EQ(MessageLoop::current(), sync_loop_);
700 if (old_job.purpose == SyncSessionJob::CONFIGURATION) { 723 if (old_job.purpose == SyncSessionJob::CONFIGURATION) {
701 // Whatever types were part of a configuration task will have had updates 724 // Whatever types were part of a configuration task will have had updates
702 // downloaded. For that reason, we make sure they get recorded in the 725 // downloaded. For that reason, we make sure they get recorded in the
703 // event that they get disabled at a later time. 726 // event that they get disabled at a later time.
(...skipping 21 matching lines...) Expand all
725 iter != job.session->source().types.end(); 748 iter != job.session->source().types.end();
726 ++iter) { 749 ++iter) {
727 syncable::PostTimeToTypeHistogram(iter->first, 750 syncable::PostTimeToTypeHistogram(iter->first,
728 now - last_sync_session_end_time_); 751 now - last_sync_session_end_time_);
729 } 752 }
730 } 753 }
731 last_sync_session_end_time_ = now; 754 last_sync_session_end_time_ = now;
732 UpdateCarryoverSessionState(job); 755 UpdateCarryoverSessionState(job);
733 if (IsSyncingCurrentlySilenced()) { 756 if (IsSyncingCurrentlySilenced()) {
734 SVLOG(2) << "We are currently throttled; not scheduling the next sync."; 757 SVLOG(2) << "We are currently throttled; not scheduling the next sync.";
735 SaveJob(job); 758 if (job.purpose != SyncSessionJob::CLEAR_USER_DATA &&
759 job.purpose != SyncSessionJob::CLEANUP_DISABLED_TYPES) {
tim (not reviewing) 2011/07/28 04:10:40 hmm.. are you sure about this? See http://code.go
akalin 2011/07/28 06:36:45 Well, we'll hit the DCHECK otherwise. And even if
tim (not reviewing) 2011/07/28 17:28:04 Well, my point is that one of the main things we d
akalin 2011/07/28 17:50:28 Replaced with TODOs, PTAL.
760 SaveJob(job);
761 }
736 return; // Nothing to do. 762 return; // Nothing to do.
737 } 763 }
738 764
739 SVLOG(2) << "Updating the next polling time after SyncMain"; 765 SVLOG(2) << "Updating the next polling time after SyncMain";
740 ScheduleNextSync(job); 766 ScheduleNextSync(job);
741 } 767 }
742 768
743 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) { 769 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) {
744 DCHECK_EQ(MessageLoop::current(), sync_loop_); 770 DCHECK_EQ(MessageLoop::current(), sync_loop_);
745 DCHECK(!old_job.session->HasMoreToSync()); 771 DCHECK(!old_job.session->HasMoreToSync());
(...skipping 10 matching lines...) Expand all
756 const bool work_to_do = 782 const bool work_to_do =
757 num_server_changes_remaining > 0 || num_unsynced_handles > 0; 783 num_server_changes_remaining > 0 || num_unsynced_handles > 0;
758 SVLOG(2) << "num server changes remaining: " << num_server_changes_remaining 784 SVLOG(2) << "num server changes remaining: " << num_server_changes_remaining
759 << ", num unsynced handles: " << num_unsynced_handles 785 << ", num unsynced handles: " << num_unsynced_handles
760 << ", syncer has work to do: " << work_to_do; 786 << ", syncer has work to do: " << work_to_do;
761 787
762 AdjustPolling(&old_job); 788 AdjustPolling(&old_job);
763 789
764 // TODO(tim): Old impl had special code if notifications disabled. Needed? 790 // TODO(tim): Old impl had special code if notifications disabled. Needed?
765 if (!work_to_do) { 791 if (!work_to_do) {
766 // Success implies backoff relief. Note that if this was a "one-off" job 792 // Success implies backoff relief. Note that if this was a
767 // (i.e. purpose == SyncSessionJob::CLEAR_USER_DATA), if there was 793 // "one-off" job (i.e. purpose ==
768 // work_to_do before it ran this wont have changed, as jobs like this don't 794 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if
769 // run a full sync cycle. So we don't need special code here. 795 // there was work_to_do before it ran this wont have changed, as
796 // jobs like this don't run a full sync cycle. So we don't need
797 // special code here.
770 wait_interval_.reset(); 798 wait_interval_.reset();
771 SVLOG(2) << "Job succeeded so not scheduling more jobs"; 799 SVLOG(2) << "Job succeeded so not scheduling more jobs";
772 return; 800 return;
773 } 801 }
774 802
775 if (old_job.session->source().updates_source == 803 if (old_job.session->source().updates_source ==
776 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) { 804 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) {
777 SVLOG(2) << "Job failed with source continuation"; 805 SVLOG(2) << "Job failed with source continuation";
778 // We don't seem to have made forward progress. Start or extend backoff. 806 // We don't seem to have made forward progress. Start or extend backoff.
779 HandleConsecutiveContinuationError(old_job); 807 HandleConsecutiveContinuationError(old_job);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1070
1043 #undef SLOG 1071 #undef SLOG
1044 1072
1045 #undef VLOG_LOC 1073 #undef VLOG_LOC
1046 1074
1047 #undef VLOG_LOC_STREAM 1075 #undef VLOG_LOC_STREAM
1048 1076
1049 #undef ENUM_CASE 1077 #undef ENUM_CASE
1050 1078
1051 } // browser_sync 1079 } // browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/sync_scheduler.h ('k') | chrome/browser/sync/engine/sync_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698