blob: 6eda2d826a3ebd060963cf942d59b98543f84a4d [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"
Sigurdur Asgeirsson956f032f2021-05-12 14:49:399#include "base/scoped_multi_source_observation.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();
Peter Boström53c6c5952021-09-17 09:41:2624
25 ConfigurationRefresher(const ConfigurationRefresher&) = delete;
26 ConfigurationRefresher& operator=(const ConfigurationRefresher&) = delete;
27
Sky Malicea8b389e2017-12-08 23:17:3428 ~ConfigurationRefresher() override;
29 void Observe(syncer::SyncService* sync_service);
30
31 private:
32 // syncer::SyncServiceObserver implementation.
33 void OnSyncConfigurationCompleted(syncer::SyncService* sync_service) override;
Nicolas Ouellet-Payeur47435532020-11-02 17:05:2734 void OnSyncShutdown(syncer::SyncService* sync_service) override;
Sky Malicea8b389e2017-12-08 23:17:3435
Sigurdur Asgeirsson956f032f2021-05-12 14:49:3936 base::ScopedMultiSourceObservation<syncer::SyncService,
37 syncer::SyncServiceObserver>
38 scoped_observations_{this};
Sky Malicea8b389e2017-12-08 23:17:3439};
40
41#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_CONFIGURATION_REFRESHER_H_