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

Side by Side Diff: chrome/browser/sync/test/integration/updated_progress_marker_checker.cc

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " 5 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h "
6 6
7 #include "components/browser_sync/browser/profile_sync_service.h" 7 #include "components/browser_sync/browser/profile_sync_service.h"
8 #include "components/sync/sessions/sync_session_snapshot.h" 8 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
9 9
10 UpdatedProgressMarkerChecker::UpdatedProgressMarkerChecker( 10 UpdatedProgressMarkerChecker::UpdatedProgressMarkerChecker(
11 ProfileSyncService* service) : SingleClientStatusChangeChecker(service) {} 11 ProfileSyncService* service) : SingleClientStatusChangeChecker(service) {}
12 12
13 UpdatedProgressMarkerChecker::~UpdatedProgressMarkerChecker() {} 13 UpdatedProgressMarkerChecker::~UpdatedProgressMarkerChecker() {}
14 14
15 bool UpdatedProgressMarkerChecker::IsExitConditionSatisfied() { 15 bool UpdatedProgressMarkerChecker::IsExitConditionSatisfied() {
16 // Checks to see if our self-notify sync cycle has completed and 16 // Checks to see if our self-notify sync cycle has completed and
17 // there's nothing to commit. 17 // there's nothing to commit.
18 // 18 //
19 // If we assume that no one else is committing at this time and that the 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 20 // current client did not commit anything in its previous sync cycle, then
21 // this client has the latest progress markers. 21 // this client has the latest progress markers.
22 // 22 //
23 // The !service()->HasUnsyncedItems() check makes sure that we have nothing to 23 // The !service()->HasUnsyncedItems() check makes sure that we have nothing to
24 // commit. 24 // commit.
25 // 25 //
26 // There is a subtle race condition here. While committing items, the syncer 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 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() 28 // this current sync cycle won't be available from GetLastCycleSnapshot()
29 // until the sync cycle completes. If we query this condition between the 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 30 // commit response processing and the end of the sync cycle, we could return a
31 // false positive. 31 // false positive.
32 // 32 //
33 // In practice, this doesn't happen very often because we only query the 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 34 // status when the waiting first starts and when we receive notification of a
35 // sync session complete or other significant event from the 35 // sync session complete or other significant event from the
36 // ProfileSyncService. If we're calling this right after the sync session 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. 37 // completes, then the snapshot is much more likely to be up to date.
38 const syncer::sessions::SyncSessionSnapshot& snap = 38 const syncer::SyncCycleSnapshot& snap = service()->GetLastCycleSnapshot();
39 service()->GetLastSessionSnapshot();
40 return snap.model_neutral_state().num_successful_commits == 0 && 39 return snap.model_neutral_state().num_successful_commits == 0 &&
41 service()->IsSyncActive() && !service()->HasUnsyncedItems(); 40 service()->IsSyncActive() && !service()->HasUnsyncedItems();
42 } 41 }
43 42
44 std::string UpdatedProgressMarkerChecker::GetDebugMessage() const { 43 std::string UpdatedProgressMarkerChecker::GetDebugMessage() const {
45 return "Waiting for progress markers"; 44 return "Waiting for progress markers";
46 } 45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698