blob: 5970cc771d36b3b23bfa3794593fde5b8493ac42 [file] [log] [blame]
Sky Malicea8b389e2017-12-08 23:17:341// Copyright 2017 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#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_CONFIGURATION_REFRESHER_H_
6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_CONFIGURATION_REFRESHER_H_
7
8#include "base/macros.h"
9#include "base/scoped_observer.h"
Evan Stade22e3f9b2019-10-01 21:12:1710#include "components/sync/driver/sync_service.h"
Sky Malicea8b389e2017-12-08 23:17:3411#include "components/sync/driver/sync_service_observer.h"
12
13// Triggers a GetUpdates via refresh for any observed SyncService after a
14// configuration. This class was created to be used in conjunction with fake
15// invalidations. It turns out there's a race during configuration, after the
16// initial GetUpdates was called, but before invalidations were re-subscribed to
17// that caused updates to be missed. This resulted in some flakey test cases,
18// see crbug,com/644367 for more details. This class fills the gap by forcing a
19// GetUpdates after configuration to fetch anything missed while a client was
20// not subscribed to invalidation(s).
21class ConfigurationRefresher : public syncer::SyncServiceObserver {
22 public:
23 ConfigurationRefresher();
24 ~ConfigurationRefresher() override;
25 void Observe(syncer::SyncService* sync_service);
26
27 private:
28 // syncer::SyncServiceObserver implementation.
29 void OnSyncConfigurationCompleted(syncer::SyncService* sync_service) override;
Nicolas Ouellet-Payeur47435532020-11-02 17:05:2730 void OnSyncShutdown(syncer::SyncService* sync_service) override;
Sky Malicea8b389e2017-12-08 23:17:3431
Evan Stade22e3f9b2019-10-01 21:12:1732 ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
33 scoped_observer_{this};
Sky Malicea8b389e2017-12-08 23:17:3434
35 DISALLOW_COPY_AND_ASSIGN(ConfigurationRefresher);
36};
37
38#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_CONFIGURATION_REFRESHER_H_