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

Side by Side Diff: sync/engine/syncer.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
« no previous file with comments | « sync/engine/sync_scheduler.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/syncer.h" 5 #include "sync/engine/syncer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 case SYNCER_BEGIN: 112 case SYNCER_BEGIN:
113 // This isn't perfect, as we can end up bundling extensions activity 113 // This isn't perfect, as we can end up bundling extensions activity
114 // intended for the next session into the current one. We could do a 114 // intended for the next session into the current one. We could do a
115 // test-and-reset as with the source, but note that also falls short if 115 // test-and-reset as with the source, but note that also falls short if
116 // the commit request fails (e.g. due to lost connection), as we will 116 // the commit request fails (e.g. due to lost connection), as we will
117 // fall all the way back to the syncer thread main loop in that case, 117 // fall all the way back to the syncer thread main loop in that case,
118 // creating a new session when a connection is established, losing the 118 // creating a new session when a connection is established, losing the
119 // records set here on the original attempt. This should provide us 119 // records set here on the original attempt. This should provide us
120 // with the right data "most of the time", and we're only using this 120 // with the right data "most of the time", and we're only using this
121 // for analysis purposes, so Law of Large Numbers FTW. 121 // for analysis purposes, so Law of Large Numbers FTW.
122 session->context()->extensions_monitor()->GetAndClearRecords( 122 session->context()->extensions_monitor()->GetAndClearRecords(
rlarocque 2012/04/12 21:34:31 While working on a different CL, I realized that t
123 session->mutable_extensions_activity()); 123 session->mutable_extensions_activity());
124 session->context()->PruneUnthrottledTypes(base::TimeTicks::Now()); 124 session->context()->PruneUnthrottledTypes(base::TimeTicks::Now());
125 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN); 125 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN);
126 126
127 next_step = CLEANUP_DISABLED_TYPES; 127 next_step = CLEANUP_DISABLED_TYPES;
128 break; 128 break;
129 case CLEANUP_DISABLED_TYPES: { 129 case CLEANUP_DISABLED_TYPES: {
130 CleanupDisabledTypesCommand cleanup; 130 CleanupDisabledTypesCommand cleanup;
131 cleanup.Execute(session); 131 cleanup.Execute(session);
132 next_step = DOWNLOAD_UPDATES; 132 next_step = DOWNLOAD_UPDATES;
(...skipping 26 matching lines...) Expand all
159 } 159 }
160 case PROCESS_UPDATES: { 160 case PROCESS_UPDATES: {
161 ProcessUpdatesCommand process_updates; 161 ProcessUpdatesCommand process_updates;
162 process_updates.Execute(session); 162 process_updates.Execute(session);
163 next_step = STORE_TIMESTAMPS; 163 next_step = STORE_TIMESTAMPS;
164 break; 164 break;
165 } 165 }
166 case STORE_TIMESTAMPS: { 166 case STORE_TIMESTAMPS: {
167 StoreTimestampsCommand store_timestamps; 167 StoreTimestampsCommand store_timestamps;
168 store_timestamps.Execute(session); 168 store_timestamps.Execute(session);
169 // We should download all of the updates before attempting to process 169 // We download all of the updates before attempting to apply them.
170 // them. 170 if (!session->status_controller().download_updates_succeeded()) {
171 if (session->status_controller().ServerSaysNothingMoreToDownload() || 171 // We may have downloaded some updates, but if the latest download
172 !session->status_controller().download_updates_succeeded()) { 172 // attempt failed then we don't have all the updates. We'll leave
173 // it to a retry job to pick up where we left off.
174 last_step = SYNCER_END; // Necessary for CONFIGURATION mode.
175 next_step = SYNCER_END;
176 DVLOG(1) << "Aborting sync cycle due to download updates failure";
177 } else if (!session->status_controller()
178 .ServerSaysNothingMoreToDownload()) {
179 next_step = DOWNLOAD_UPDATES;
180 } else {
173 next_step = APPLY_UPDATES; 181 next_step = APPLY_UPDATES;
174 } else {
175 next_step = DOWNLOAD_UPDATES;
176 } 182 }
177 break; 183 break;
178 } 184 }
179 case APPLY_UPDATES: { 185 case APPLY_UPDATES: {
180 ApplyUpdatesCommand apply_updates; 186 ApplyUpdatesCommand apply_updates;
181 apply_updates.Execute(session); 187 apply_updates.Execute(session);
182 if (last_step == APPLY_UPDATES) { 188 if (last_step == APPLY_UPDATES) {
183 // We're in configuration mode, but we still need to run the 189 // We're in configuration mode, but we still need to run the
184 // SYNCER_END step. 190 // SYNCER_END step.
185 last_step = SYNCER_END; 191 last_step = SYNCER_END;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 entry->Put(SERVER_CTIME, Time()); 342 entry->Put(SERVER_CTIME, Time());
337 entry->Put(SERVER_VERSION, 0); 343 entry->Put(SERVER_VERSION, 0);
338 entry->Put(SERVER_IS_DIR, false); 344 entry->Put(SERVER_IS_DIR, false);
339 entry->Put(SERVER_IS_DEL, false); 345 entry->Put(SERVER_IS_DEL, false);
340 entry->Put(IS_UNAPPLIED_UPDATE, false); 346 entry->Put(IS_UNAPPLIED_UPDATE, false);
341 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 347 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
342 entry->Put(SERVER_POSITION_IN_PARENT, 0); 348 entry->Put(SERVER_POSITION_IN_PARENT, 0);
343 } 349 }
344 350
345 } // namespace browser_sync 351 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698