blob: 69073594603a2c7e2818e149902bf9c113cf923e [file] [log] [blame]
Richard Knollcd7072bf2019-11-14 16:36:141// Copyright 2019 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_SHARING_SHARING_DEVICE_SOURCE_H_
6#define CHROME_BROWSER_SHARING_SHARING_DEVICE_SOURCE_H_
7
8#include <memory>
9#include <string>
10#include <vector>
11
12#include "base/callback_forward.h"
13#include "base/macros.h"
14
15namespace syncer {
16class DeviceInfo;
17} // namespace syncer
18
19class SharingDeviceSource {
20 public:
21 SharingDeviceSource();
22 virtual ~SharingDeviceSource();
23
24 // Returns if the source is ready. Calling GetAllDevices before this is true
25 // returns an empty list.
26 virtual bool IsReady() = 0;
27
28 // Returns the device matching |guid|, or nullptr if no match was found.
29 virtual std::unique_ptr<syncer::DeviceInfo> GetDeviceByGuid(
30 const std::string& guid) = 0;
31
32 // Returns all devices found.
33 virtual std::vector<std::unique_ptr<syncer::DeviceInfo>> GetAllDevices() = 0;
34
Michael van Ouwerkerk889fff12019-12-13 17:29:2935 // Adds a callback to be run when the SharingDeviceSource is ready. If a
36 // callback is added when it is already ready, it will be run immediately.
Richard Knollcd7072bf2019-11-14 16:36:1437 void AddReadyCallback(base::OnceClosure callback);
38
39 protected:
40 void MaybeRunReadyCallbacks();
41
42 private:
43 std::vector<base::OnceClosure> ready_callbacks_;
44
45 DISALLOW_COPY_AND_ASSIGN(SharingDeviceSource);
46};
47
48#endif // CHROME_BROWSER_SHARING_SHARING_DEVICE_SOURCE_H_