summaryrefslogtreecommitdiff
path: root/chromium/components/browser_sync/active_devices_provider_impl.h
blob: d0bbed0f989204a573a34268a08d7ca9c73978d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_BROWSER_SYNC_ACTIVE_DEVICES_PROVIDER_IMPL_H_
#define COMPONENTS_BROWSER_SYNC_ACTIVE_DEVICES_PROVIDER_IMPL_H_

#include "base/sequence_checker.h"
#include "base/time/default_clock.h"
#include "components/sync/driver/active_devices_provider.h"
#include "components/sync_device_info/device_info_tracker.h"

namespace browser_sync {

class ActiveDevicesProviderImpl : public syncer::ActiveDevicesProvider,
                                  public syncer::DeviceInfoTracker::Observer {
 public:
  ActiveDevicesProviderImpl(syncer::DeviceInfoTracker* device_info_tracker,
                            base::Clock* clock);
  ActiveDevicesProviderImpl(const ActiveDevicesProviderImpl&) = delete;
  ActiveDevicesProviderImpl& operator=(const ActiveDevicesProviderImpl&) =
      delete;

  ~ActiveDevicesProviderImpl() override;

  // syncer::ActiveDevicesProvider implementation.
  size_t CountActiveDevicesIfAvailable() override;

  void SetActiveDevicesChangedCallback(
      ActiveDevicesChangedCallback callback) override;

  // syncer::DeviceInfoTracker::Observer implementation.
  void OnDeviceInfoChange() override;

 private:
  syncer::DeviceInfoTracker* const device_info_tracker_;
  const base::Clock* const clock_;
  ActiveDevicesChangedCallback callback_;

  SEQUENCE_CHECKER(sequence_checker_);
};

}  // namespace browser_sync

#endif  // COMPONENTS_BROWSER_SYNC_ACTIVE_DEVICES_PROVIDER_IMPL_H_