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

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: Rebase 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 // static
687 void SyncScheduler::SetSyncerStepsForPurpose(
688 SyncSessionJob::SyncSessionJobPurpose purpose,
689 SyncerStep* start,
690 SyncerStep* end) {
691 switch (purpose) {
692 case SyncSessionJob::CONFIGURATION:
693 *start = DOWNLOAD_UPDATES;
694 *end = APPLY_UPDATES;
695 return;
696 case SyncSessionJob::CLEAR_USER_DATA:
697 *start = CLEAR_PRIVATE_DATA;
698 *end = CLEAR_PRIVATE_DATA;
699 return;
700 case SyncSessionJob::NUDGE:
701 case SyncSessionJob::POLL:
702 *start = SYNCER_BEGIN;
703 *end = SYNCER_END;
704 return;
705 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
706 *start = CLEANUP_DISABLED_TYPES;
707 *end = CLEANUP_DISABLED_TYPES;
708 return;
709 default:
710 NOTREACHED();
711 *start = SYNCER_END;
712 *end = SYNCER_END;
713 return;
714 }
715 }
716
686 void SyncScheduler::PostTask( 717 void SyncScheduler::PostTask(
687 const tracked_objects::Location& from_here, 718 const tracked_objects::Location& from_here,
688 const char* name, const base::Closure& task) { 719 const char* name, const base::Closure& task) {
689 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task"; 720 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task";
690 DCHECK_EQ(MessageLoop::current(), sync_loop_); 721 DCHECK_EQ(MessageLoop::current(), sync_loop_);
691 if (!started_) { 722 if (!started_) {
692 SDVLOG(1) << "Not posting task as scheduler is stopped."; 723 SDVLOG(1) << "Not posting task as scheduler is stopped.";
693 return; 724 return;
694 } 725 }
695 sync_loop_->PostTask(from_here, task); 726 sync_loop_->PostTask(from_here, task);
(...skipping 28 matching lines...) Expand all
724 job.session); 755 job.session);
725 pending_nudge_.reset(new SyncSessionJob(job)); 756 pending_nudge_.reset(new SyncSessionJob(job));
726 } 757 }
727 PostDelayedTask(job.from_here, "DoSyncSessionJob", 758 PostDelayedTask(job.from_here, "DoSyncSessionJob",
728 base::Bind(&SyncScheduler::DoSyncSessionJob, 759 base::Bind(&SyncScheduler::DoSyncSessionJob,
729 weak_ptr_factory_.GetWeakPtr(), 760 weak_ptr_factory_.GetWeakPtr(),
730 job), 761 job),
731 delay); 762 delay);
732 } 763 }
733 764
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) { 765 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) {
765 DCHECK_EQ(MessageLoop::current(), sync_loop_); 766 DCHECK_EQ(MessageLoop::current(), sync_loop_);
766 if (!ShouldRunJob(job)) { 767 if (!ShouldRunJob(job)) {
767 SLOG(WARNING) 768 SLOG(WARNING)
768 << "Not executing " 769 << "Not executing "
769 << SyncSessionJob::GetPurposeString(job.purpose) << " job from " 770 << SyncSessionJob::GetPurposeString(job.purpose) << " job from "
770 << GetUpdatesSourceString(job.session->source().updates_source); 771 << GetUpdatesSourceString(job.session->source().updates_source);
771 return; 772 return;
772 } 773 }
773 774
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 1197
1197 #undef SDVLOG_LOC 1198 #undef SDVLOG_LOC
1198 1199
1199 #undef SDVLOG 1200 #undef SDVLOG
1200 1201
1201 #undef SLOG 1202 #undef SLOG
1202 1203
1203 #undef ENUM_CASE 1204 #undef ENUM_CASE
1204 1205
1205 } // browser_sync 1206 } // browser_sync
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler.h ('k') | sync/engine/syncer.cc » ('j') | sync/engine/syncer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698