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

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

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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/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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 namespace { 242 namespace {
243 // Return true if the command in question was attempted and did not complete 243 // Return true if the command in question was attempted and did not complete
244 // successfully. 244 // successfully.
245 // 245 //
246 bool IsError(SyncerError error) { 246 bool IsError(SyncerError error) {
247 return error != UNSET && error != SYNCER_OK; 247 return error != UNSET && error != SYNCER_OK;
248 } 248 }
249 249
250 // Returns false iff one of the command results had an error. 250 // Returns false iff one of the command results had an error.
251 bool HadErrors(const ModelNeutralState& state) { 251 bool HadErrors(const ModelNeutralState& state) {
252 const bool get_key_error = IsError(state.last_get_key_result);
252 const bool download_updates_error = 253 const bool download_updates_error =
253 IsError(state.last_download_updates_result); 254 IsError(state.last_download_updates_result);
254 const bool commit_error = IsError(state.commit_result); 255 const bool commit_error = IsError(state.commit_result);
255 return download_updates_error || commit_error; 256 return get_key_error || download_updates_error || commit_error;
256 } 257 }
257 } // namespace 258 } // namespace
258 259
259 bool SyncSession::Succeeded() const { 260 bool SyncSession::Succeeded() const {
260 return finished_ && !HadErrors(status_controller_->model_neutral_state()); 261 return finished_ && !HadErrors(status_controller_->model_neutral_state());
261 } 262 }
262 263
263 bool SyncSession::SuccessfullyReachedServer() const { 264 bool SyncSession::SuccessfullyReachedServer() const {
264 const ModelNeutralState& state = status_controller_->model_neutral_state(); 265 const ModelNeutralState& state = status_controller_->model_neutral_state();
265 bool reached_server = state.last_download_updates_result == SYNCER_OK; 266 bool reached_server = state.last_get_key_result == SYNCER_OK ||
267 state.last_download_updates_result == SYNCER_OK;
266 // It's possible that we reached the server on one attempt, then had an error 268 // It's possible that we reached the server on one attempt, then had an error
267 // on the next (or didn't perform some of the server-communicating commands). 269 // on the next (or didn't perform some of the server-communicating commands).
268 // We want to verify that, for all commands attempted, we successfully spoke 270 // We want to verify that, for all commands attempted, we successfully spoke
269 // with the server. Therefore, we verify no errors and at least one SYNCER_OK. 271 // with the server. Therefore, we verify no errors and at least one SYNCER_OK.
270 return reached_server && !HadErrors(state); 272 return reached_server && !HadErrors(state);
271 } 273 }
272 274
273 void SyncSession::SetFinished() { 275 void SyncSession::SetFinished() {
274 finished_ = true; 276 finished_ = true;
275 } 277 }
276 278
277 } // namespace sessions 279 } // namespace sessions
278 } // namespace syncer 280 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698