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

Side by Side Diff: sync/sessions/sync_session.cc

Issue 10523003: Refactor following sync commit loop change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another rebase Created 8 years, 6 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/sessions/status_controller_unittest.cc ('k') | sync/sessions/test_util.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/sessions/sync_session.h" 5 #include "sync/sessions/sync_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // successfully. 228 // successfully.
229 // 229 //
230 bool IsError(SyncerError error) { 230 bool IsError(SyncerError error) {
231 return error != UNSET && error != SYNCER_OK; 231 return error != UNSET && error != SYNCER_OK;
232 } 232 }
233 233
234 // Returns false iff one of the command results had an error. 234 // Returns false iff one of the command results had an error.
235 bool HadErrors(const ErrorCounters& error) { 235 bool HadErrors(const ErrorCounters& error) {
236 const bool download_updates_error = 236 const bool download_updates_error =
237 IsError(error.last_download_updates_result); 237 IsError(error.last_download_updates_result);
238 const bool post_commit_error = IsError(error.last_post_commit_result); 238 const bool commit_error = IsError(error.commit_result);
239 const bool process_commit_response_error = 239 return download_updates_error || commit_error;
240 IsError(error.last_process_commit_response_result);
241 return download_updates_error ||
242 post_commit_error ||
243 process_commit_response_error;
244 } 240 }
245 } // namespace 241 } // namespace
246 242
247 bool SyncSession::Succeeded() const { 243 bool SyncSession::Succeeded() const {
248 const ErrorCounters& error = status_controller_->error(); 244 const ErrorCounters& error = status_controller_->error();
249 return finished_ && !HadErrors(error); 245 return finished_ && !HadErrors(error);
250 } 246 }
251 247
252 bool SyncSession::SuccessfullyReachedServer() const { 248 bool SyncSession::SuccessfullyReachedServer() const {
253 const ErrorCounters& error = status_controller_->error(); 249 const ErrorCounters& error = status_controller_->error();
254 bool reached_server = error.last_download_updates_result == SYNCER_OK || 250 bool reached_server = error.last_download_updates_result == SYNCER_OK;
255 error.last_post_commit_result == SYNCER_OK ||
256 error.last_process_commit_response_result == SYNCER_OK;
257 // It's possible that we reached the server on one attempt, then had an error 251 // It's possible that we reached the server on one attempt, then had an error
258 // on the next (or didn't perform some of the server-communicating commands). 252 // on the next (or didn't perform some of the server-communicating commands).
259 // We want to verify that, for all commands attempted, we successfully spoke 253 // We want to verify that, for all commands attempted, we successfully spoke
260 // with the server. Therefore, we verify no errors and at least one SYNCER_OK. 254 // with the server. Therefore, we verify no errors and at least one SYNCER_OK.
261 return reached_server && !HadErrors(error); 255 return reached_server && !HadErrors(error);
262 } 256 }
263 257
264 void SyncSession::SetFinished() { 258 void SyncSession::SetFinished() {
265 finished_ = true; 259 finished_ = true;
266 } 260 }
267 261
268 } // namespace sessions 262 } // namespace sessions
269 } // namespace browser_sync 263 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/sessions/status_controller_unittest.cc ('k') | sync/sessions/test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698