Home | History | Annotate | Download | only in integration
      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.
      4 
      5 #include "chrome/browser/sync/test/integration/multi_client_status_change_checker.h"
      6 
      7 #include "base/logging.h"
      8 #include "base/scoped_observer.h"
      9 #include "chrome/browser/sync/profile_sync_service.h"
     10 
     11 MultiClientStatusChangeChecker::MultiClientStatusChangeChecker(
     12     std::vector<ProfileSyncService*> services)
     13   : services_(services) {}
     14 
     15 MultiClientStatusChangeChecker::~MultiClientStatusChangeChecker() {}
     16 
     17 void MultiClientStatusChangeChecker::Wait() {
     18   DVLOG(1) << "Await: " << GetDebugMessage();
     19 
     20   if (IsExitConditionSatisfied()) {
     21     DVLOG(1) << "Await -> Exit before waiting: " << GetDebugMessage();
     22     return;
     23   }
     24 
     25   ScopedObserver<ProfileSyncService, MultiClientStatusChangeChecker> obs(this);
     26   for (std::vector<ProfileSyncService*>::iterator it = services_.begin();
     27        it != services_.end(); ++it) {
     28     obs.Add(*it);
     29   }
     30 
     31   StartBlockingWait();
     32 }
     33 
     34 void MultiClientStatusChangeChecker::OnStateChanged() {
     35   CheckExitCondition();
     36 }
     37