| 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 #include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h" | 5 #include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::vector<browser_sync::ProfileSyncService*> services) | 146 std::vector<browser_sync::ProfileSyncService*> services) |
| 147 : services_(services) { | 147 : services_(services) { |
| 148 DCHECK_LE(1U, services_.size()); | 148 DCHECK_LE(1U, services_.size()); |
| 149 for (size_t i = 0; i < services_.size(); ++i) { | 149 for (size_t i = 0; i < services_.size(); ++i) { |
| 150 observers_.push_back(new ProgressMarkerWatcher(services[i], this)); | 150 observers_.push_back(new ProgressMarkerWatcher(services[i], this)); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 QuiesceStatusChangeChecker::~QuiesceStatusChangeChecker() {} | 154 QuiesceStatusChangeChecker::~QuiesceStatusChangeChecker() {} |
| 155 | 155 |
| 156 void QuiesceStatusChangeChecker::Wait() { | |
| 157 DVLOG(1) << "Await: " << GetDebugMessage(); | |
| 158 | |
| 159 if (IsExitConditionSatisfied()) { | |
| 160 DVLOG(1) << "Await -> Exit before waiting: " << GetDebugMessage(); | |
| 161 return; | |
| 162 } | |
| 163 | |
| 164 StartBlockingWait(); | |
| 165 } | |
| 166 | |
| 167 bool QuiesceStatusChangeChecker::IsExitConditionSatisfied() { | 156 bool QuiesceStatusChangeChecker::IsExitConditionSatisfied() { |
| 168 // Check that all progress markers are up to date. | 157 // Check that all progress markers are up to date. |
| 169 for (ScopedVector<ProgressMarkerWatcher>::const_iterator it = | 158 for (ScopedVector<ProgressMarkerWatcher>::const_iterator it = |
| 170 observers_.begin(); it != observers_.end(); ++it) { | 159 observers_.begin(); it != observers_.end(); ++it) { |
| 171 if ((*it)->IsSyncDisabled()) { | 160 if ((*it)->IsSyncDisabled()) { |
| 172 continue; // Skip disabled services. | 161 continue; // Skip disabled services. |
| 173 } | 162 } |
| 174 | 163 |
| 175 if (!(*it)->HasLatestProgressMarkers()) { | 164 if (!(*it)->HasLatestProgressMarkers()) { |
| 176 DVLOG(1) << "Not quiesced: Progress markers are old."; | 165 DVLOG(1) << "Not quiesced: Progress markers are old."; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 202 |
| 214 std::string QuiesceStatusChangeChecker::GetDebugMessage() const { | 203 std::string QuiesceStatusChangeChecker::GetDebugMessage() const { |
| 215 return base::StringPrintf("Waiting for quiescence of %" PRIuS " clients", | 204 return base::StringPrintf("Waiting for quiescence of %" PRIuS " clients", |
| 216 services_.size()); | 205 services_.size()); |
| 217 } | 206 } |
| 218 | 207 |
| 219 void QuiesceStatusChangeChecker::OnServiceStateChanged( | 208 void QuiesceStatusChangeChecker::OnServiceStateChanged( |
| 220 browser_sync::ProfileSyncService* service) { | 209 browser_sync::ProfileSyncService* service) { |
| 221 CheckExitCondition(); | 210 CheckExitCondition(); |
| 222 } | 211 } |
| OLD | NEW |