Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / updated_progress_marker_checker.cc
blobcce8084033682776d6b0335410d5e7c7e24c1fd9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
7 #include "chrome/browser/sync/profile_sync_service.h"
8 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
10 UpdatedProgressMarkerChecker::UpdatedProgressMarkerChecker(
11 ProfileSyncService* service) : SingleClientStatusChangeChecker(service) {}
13 UpdatedProgressMarkerChecker::~UpdatedProgressMarkerChecker() {}
15 bool UpdatedProgressMarkerChecker::IsExitConditionSatisfied() {
16 // Checks to see if our self-notify sync cycle has completed and
17 // there's nothing to commit.
19 // If we assume that no one else is committing at this time and that the
20 // current client did not commit anything in its previous sync cycle, then
21 // this client has the latest progress markers.
23 // The !service()->HasUnsyncedItems() check makes sure that we have nothing to
24 // commit.
26 // There is a subtle race condition here. While committing items, the syncer
27 // will unset the IS_UNSYNCED bits in the directory. However, the evidence of
28 // this current sync cycle won't be available from GetLastSessionSnapshot()
29 // until the sync cycle completes. If we query this condition between the
30 // commit response processing and the end of the sync cycle, we could return a
31 // false positive.
33 // In practice, this doesn't happen very often because we only query the
34 // status when the waiting first starts and when we receive notification of a
35 // sync session complete or other significant event from the
36 // ProfileSyncService. If we're calling this right after the sync session
37 // completes, then the snapshot is much more likely to be up to date.
38 const syncer::sessions::SyncSessionSnapshot& snap =
39 service()->GetLastSessionSnapshot();
40 return snap.model_neutral_state().num_successful_commits == 0 &&
41 service()->IsSyncActive() && !service()->HasUnsyncedItems();
44 std::string UpdatedProgressMarkerChecker::GetDebugMessage() const {
45 return "Waiting for progress markers";