OLD | NEW |
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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_QUIESCE_STATUS_CHANGE_CHECKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_QUIESCE_STATUS_CHANGE_CHECKER_H_ |
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_QUIESCE_STATUS_CHANGE_CHECKER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_QUIESCE_STATUS_CHANGE_CHECKER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/sync/test/integration/status_change_checker.h" | 14 #include "chrome/browser/sync/test/integration/status_change_checker.h" |
15 | 15 |
| 16 class ProgressMarkerWatcher; |
| 17 |
| 18 namespace browser_sync { |
16 class ProfileSyncService; | 19 class ProfileSyncService; |
17 class ProgressMarkerWatcher; | 20 } // namespace browser_sync |
18 | 21 |
19 // Waits until all provided clients have finished committing any unsynced items | 22 // Waits until all provided clients have finished committing any unsynced items |
20 // and downloading each others' udpates. | 23 // and downloading each others' udpates. |
21 // | 24 // |
22 // This requires that "self-notifications" be enabled. Otherwise the clients | 25 // This requires that "self-notifications" be enabled. Otherwise the clients |
23 // will not fetch the latest progress markers on their own, and the latest | 26 // will not fetch the latest progress markers on their own, and the latest |
24 // progress markers are needed to confirm that clients are in sync. | 27 // progress markers are needed to confirm that clients are in sync. |
25 // | 28 // |
26 // There is a race condition here. If we manage to perform the check at | 29 // There is a race condition here. If we manage to perform the check at |
27 // precisely the wrong time, we could end up seeing stale snapshot state | 30 // precisely the wrong time, we could end up seeing stale snapshot state |
28 // (crbug.com/95742), which would make us think that the client has finished | 31 // (crbug.com/95742), which would make us think that the client has finished |
29 // syncing when it hasn't. In practice, this race is rare enough that it | 32 // syncing when it hasn't. In practice, this race is rare enough that it |
30 // doesn't cause test failures. | 33 // doesn't cause test failures. |
31 class QuiesceStatusChangeChecker : public StatusChangeChecker { | 34 class QuiesceStatusChangeChecker : public StatusChangeChecker { |
32 public: | 35 public: |
33 explicit QuiesceStatusChangeChecker( | 36 explicit QuiesceStatusChangeChecker( |
34 std::vector<ProfileSyncService*> services); | 37 std::vector<browser_sync::ProfileSyncService*> services); |
35 ~QuiesceStatusChangeChecker() override; | 38 ~QuiesceStatusChangeChecker() override; |
36 | 39 |
37 // Blocks until all clients have quiesced or we time out. | 40 // Blocks until all clients have quiesced or we time out. |
38 void Wait(); | 41 void Wait(); |
39 | 42 |
40 // A callback function for some helper objects. | 43 // A callback function for some helper objects. |
41 void OnServiceStateChanged(ProfileSyncService* service); | 44 void OnServiceStateChanged(browser_sync::ProfileSyncService* service); |
42 | 45 |
43 // Implementation of StatusChangeChecker. | 46 // Implementation of StatusChangeChecker. |
44 bool IsExitConditionSatisfied() override; | 47 bool IsExitConditionSatisfied() override; |
45 std::string GetDebugMessage() const override; | 48 std::string GetDebugMessage() const override; |
46 | 49 |
47 private: | 50 private: |
48 std::vector<ProfileSyncService*> services_; | 51 std::vector<browser_sync::ProfileSyncService*> services_; |
49 ScopedVector<ProgressMarkerWatcher> observers_; | 52 ScopedVector<ProgressMarkerWatcher> observers_; |
50 | 53 |
51 DISALLOW_COPY_AND_ASSIGN(QuiesceStatusChangeChecker); | 54 DISALLOW_COPY_AND_ASSIGN(QuiesceStatusChangeChecker); |
52 }; | 55 }; |
53 | 56 |
54 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_QUIESCE_STATUS_CHANGE_CHECKER_H_ | 57 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_QUIESCE_STATUS_CHANGE_CHECKER_H_ |
OLD | NEW |