Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2258)

Side by Side Diff: chromeos/components/tether/local_device_data_provider.h

Issue 2587963003: [CrOS Tether]: Add LocalDeviceDataProvider, which fetches device data for the local device. (Closed)
Patch Set: Rebased. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H
6 #define CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
14
15 namespace cryptauth {
16 class BeaconSeed;
17 class ExternalDeviceInfo;
18 class CryptAuthDeviceManager;
19 class CryptAuthEnrollmentManager;
20 }
21
22 namespace chromeos {
23
24 namespace tether {
25
26 // Fetches CryptAuth data about the local device (i.e., the device on which this
27 // code is running) for the current user (i.e., the one which is logged-in).
28 class LocalDeviceDataProvider {
29 public:
30 LocalDeviceDataProvider(
31 const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager,
32 const cryptauth::CryptAuthEnrollmentManager*
33 cryptauth_enrollment_manager);
34 virtual ~LocalDeviceDataProvider();
35
36 // Fetches the public key and/or the beacon seeds for the local device.
37 // Returns whether the operation succeeded. If |nullptr| is passed as a
38 // parameter, the associated data will not be fetched.
39 bool GetLocalDeviceData(
40 std::string* public_key_out,
41 std::vector<cryptauth::BeaconSeed>* beacon_seeds_out) const;
42
43 private:
44 friend class LocalDeviceDataProviderTest;
45
46 class LocalDeviceDataProviderDelegate {
47 public:
48 virtual ~LocalDeviceDataProviderDelegate() {}
49 virtual std::string GetUserPublicKey() const = 0;
50 virtual std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices()
51 const = 0;
52 };
53
54 class LocalDeviceDataProviderDelegateImpl
55 : public LocalDeviceDataProviderDelegate {
56 public:
57 LocalDeviceDataProviderDelegateImpl(
58 const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager,
59 const cryptauth::CryptAuthEnrollmentManager*
60 cryptauth_enrollment_manager);
61 ~LocalDeviceDataProviderDelegateImpl() override;
62
63 std::string GetUserPublicKey() const override;
64 std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices()
65 const override;
66
67 private:
68 // Not owned and must outlive this instance.
69 const cryptauth::CryptAuthDeviceManager* const cryptauth_device_manager_;
70
71 // Not owned and must outlive this instance.
72 const cryptauth::CryptAuthEnrollmentManager* const
73 cryptauth_enrollment_manager_;
74 };
75
76 LocalDeviceDataProvider(
77 std::unique_ptr<LocalDeviceDataProviderDelegate> delegate);
78
79 std::unique_ptr<LocalDeviceDataProviderDelegate> delegate_;
80
81 DISALLOW_COPY_AND_ASSIGN(LocalDeviceDataProvider);
82 };
83
84 } // namespace tether
85
86 } // namespace chromeos
87
88 #endif // CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H
OLDNEW
« no previous file with comments | « chromeos/components/tether/BUILD.gn ('k') | chromeos/components/tether/local_device_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698