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

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: Fred's comments Created 8 years, 4 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 enabled_groups_with_verified_updates.insert(*it); 234 enabled_groups_with_verified_updates.insert(*it);
235 } 235 }
236 } 236 }
237 237
238 return enabled_groups_with_verified_updates; 238 return enabled_groups_with_verified_updates;
239 } 239 }
240 240
241 namespace { 241 namespace {
242 // Return true if the command in question was attempted and did not complete 242 // Return true if the command in question was attempted and did not complete
243 // successfully. 243 // successfully.
244 //
245 bool IsError(SyncerError error) { 244 bool IsError(SyncerError error) {
246 return error != UNSET && error != SYNCER_OK; 245 return error != UNSET && error != SYNCER_OK;
247 } 246 }
248 247
249 // Returns false iff one of the command results had an error. 248 // Returns false iff one of the command results had an error.
250 bool HadErrors(const ModelNeutralState& state) { 249 bool HadErrors(const ModelNeutralState& state) {
250 const bool get_key_error = IsError(state.last_get_key_result);
251 const bool download_updates_error = 251 const bool download_updates_error =
252 IsError(state.last_download_updates_result); 252 IsError(state.last_download_updates_result);
253 const bool commit_error = IsError(state.commit_result); 253 const bool commit_error = IsError(state.commit_result);
254 return download_updates_error || commit_error; 254 return get_key_error || download_updates_error || commit_error;
255 } 255 }
256 } // namespace 256 } // namespace
257 257
258 bool SyncSession::Succeeded() const { 258 bool SyncSession::Succeeded() const {
259 return finished_ && !HadErrors(status_controller_->model_neutral_state()); 259 return finished_ && !HadErrors(status_controller_->model_neutral_state());
260 } 260 }
261 261
262 bool SyncSession::SuccessfullyReachedServer() const { 262 bool SyncSession::SuccessfullyReachedServer() const {
263 const ModelNeutralState& state = status_controller_->model_neutral_state(); 263 const ModelNeutralState& state = status_controller_->model_neutral_state();
264 bool reached_server = state.last_download_updates_result == SYNCER_OK; 264 bool reached_server = state.last_get_key_result == SYNCER_OK ||
265 state.last_download_updates_result == SYNCER_OK;
265 // It's possible that we reached the server on one attempt, then had an error 266 // It's possible that we reached the server on one attempt, then had an error
266 // on the next (or didn't perform some of the server-communicating commands). 267 // on the next (or didn't perform some of the server-communicating commands).
267 // We want to verify that, for all commands attempted, we successfully spoke 268 // We want to verify that, for all commands attempted, we successfully spoke
268 // with the server. Therefore, we verify no errors and at least one SYNCER_OK. 269 // with the server. Therefore, we verify no errors and at least one SYNCER_OK.
269 return reached_server && !HadErrors(state); 270 return reached_server && !HadErrors(state);
270 } 271 }
271 272
272 void SyncSession::SetFinished() { 273 void SyncSession::SetFinished() {
273 finished_ = true; 274 finished_ = true;
274 } 275 }
275 276
276 } // namespace sessions 277 } // namespace sessions
277 } // namespace syncer 278 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698