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

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

Issue 10006046: Abort sync cycles when download step fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rearrange SetSyncerStepsForPurpose Created 8 years, 8 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) 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.h" 5 #include "sync/engine/sync_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 const char* SyncScheduler::GetDecisionString( 676 const char* SyncScheduler::GetDecisionString(
677 SyncScheduler::JobProcessDecision mode) { 677 SyncScheduler::JobProcessDecision mode) {
678 switch (mode) { 678 switch (mode) {
679 ENUM_CASE(CONTINUE); 679 ENUM_CASE(CONTINUE);
680 ENUM_CASE(SAVE); 680 ENUM_CASE(SAVE);
681 ENUM_CASE(DROP); 681 ENUM_CASE(DROP);
682 } 682 }
683 return ""; 683 return "";
684 } 684 }
685 685
686 void SyncScheduler::SetSyncerStepsForPurpose(
rlarocque 2012/04/06 20:35:09 This function has moved, but is otherwise mostly u
tim (not reviewing) 2012/04/12 01:28:20 nit - add "// static" above "void SyncScheduler::S
687 SyncSessionJob::SyncSessionJobPurpose purpose,
688 SyncerStep* start, SyncerStep* end) {
689 switch (purpose) {
690 case SyncSessionJob::CONFIGURATION:
691 *start = DOWNLOAD_UPDATES;
692 *end = APPLY_UPDATES;
693 return;
694 case SyncSessionJob::CLEAR_USER_DATA:
695 *start = CLEAR_PRIVATE_DATA;
696 *end = CLEAR_PRIVATE_DATA;
697 return;
698 case SyncSessionJob::NUDGE:
699 case SyncSessionJob::POLL:
700 *start = SYNCER_BEGIN;
701 *end = SYNCER_END;
702 return;
703 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
704 *start = CLEANUP_DISABLED_TYPES;
705 *end = CLEANUP_DISABLED_TYPES;
706 return;
707 default:
708 NOTREACHED();
709 *start = SYNCER_END;
710 *end = SYNCER_END;
711 return;
712 }
713 }
714
686 void SyncScheduler::PostTask( 715 void SyncScheduler::PostTask(
687 const tracked_objects::Location& from_here, 716 const tracked_objects::Location& from_here,
688 const char* name, const base::Closure& task) { 717 const char* name, const base::Closure& task) {
689 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task"; 718 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task";
690 DCHECK_EQ(MessageLoop::current(), sync_loop_); 719 DCHECK_EQ(MessageLoop::current(), sync_loop_);
691 if (!started_) { 720 if (!started_) {
692 SDVLOG(1) << "Not posting task as scheduler is stopped."; 721 SDVLOG(1) << "Not posting task as scheduler is stopped.";
693 return; 722 return;
694 } 723 }
695 sync_loop_->PostTask(from_here, task); 724 sync_loop_->PostTask(from_here, task);
(...skipping 28 matching lines...) Expand all
724 job.session); 753 job.session);
725 pending_nudge_.reset(new SyncSessionJob(job)); 754 pending_nudge_.reset(new SyncSessionJob(job));
726 } 755 }
727 PostDelayedTask(job.from_here, "DoSyncSessionJob", 756 PostDelayedTask(job.from_here, "DoSyncSessionJob",
728 base::Bind(&SyncScheduler::DoSyncSessionJob, 757 base::Bind(&SyncScheduler::DoSyncSessionJob,
729 weak_ptr_factory_.GetWeakPtr(), 758 weak_ptr_factory_.GetWeakPtr(),
730 job), 759 job),
731 delay); 760 delay);
732 } 761 }
733 762
734 void SyncScheduler::SetSyncerStepsForPurpose(
735 SyncSessionJob::SyncSessionJobPurpose purpose,
736 SyncerStep* start, SyncerStep* end) {
737 DCHECK_EQ(MessageLoop::current(), sync_loop_);
738 switch (purpose) {
739 case SyncSessionJob::CONFIGURATION:
740 *start = DOWNLOAD_UPDATES;
741 *end = APPLY_UPDATES;
742 return;
743 case SyncSessionJob::CLEAR_USER_DATA:
744 *start = CLEAR_PRIVATE_DATA;
745 *end = CLEAR_PRIVATE_DATA;
746 return;
747 case SyncSessionJob::NUDGE:
748 case SyncSessionJob::POLL:
749 *start = SYNCER_BEGIN;
750 *end = SYNCER_END;
751 return;
752 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
753 *start = CLEANUP_DISABLED_TYPES;
754 *end = CLEANUP_DISABLED_TYPES;
755 return;
756 default:
757 NOTREACHED();
758 *start = SYNCER_END;
759 *end = SYNCER_END;
760 return;
761 }
762 }
763
764 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) { 763 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) {
765 DCHECK_EQ(MessageLoop::current(), sync_loop_); 764 DCHECK_EQ(MessageLoop::current(), sync_loop_);
766 if (!ShouldRunJob(job)) { 765 if (!ShouldRunJob(job)) {
767 SLOG(WARNING) 766 SLOG(WARNING)
768 << "Not executing " 767 << "Not executing "
769 << SyncSessionJob::GetPurposeString(job.purpose) << " job from " 768 << SyncSessionJob::GetPurposeString(job.purpose) << " job from "
770 << GetUpdatesSourceString(job.session->source().updates_source); 769 << GetUpdatesSourceString(job.session->source().updates_source);
771 return; 770 return;
772 } 771 }
773 772
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 1195
1197 #undef SDVLOG_LOC 1196 #undef SDVLOG_LOC
1198 1197
1199 #undef SDVLOG 1198 #undef SDVLOG
1200 1199
1201 #undef SLOG 1200 #undef SLOG
1202 1201
1203 #undef ENUM_CASE 1202 #undef ENUM_CASE
1204 1203
1205 } // browser_sync 1204 } // browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698