Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 LocalDeviceDataProviderContext { | |
|
Ryan Hansberry
2016/12/19 20:25:31
In your HostScanScheduler CL, tengs@ preferred the
Kyle Horimoto
2016/12/19 21:23:54
Done.
| |
| 47 public: | |
| 48 virtual ~LocalDeviceDataProviderContext() {} | |
| 49 virtual std::string GetUserPublicKey() const = 0; | |
| 50 virtual std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices() | |
| 51 const = 0; | |
| 52 }; | |
| 53 | |
| 54 class LocalDeviceDataProviderContextImpl | |
| 55 : public LocalDeviceDataProviderContext { | |
| 56 public: | |
| 57 LocalDeviceDataProviderContextImpl( | |
| 58 const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager, | |
| 59 const cryptauth::CryptAuthEnrollmentManager* | |
| 60 cryptauth_enrollment_manager); | |
| 61 ~LocalDeviceDataProviderContextImpl() 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<LocalDeviceDataProviderContext> context); | |
| 78 | |
| 79 std::unique_ptr<LocalDeviceDataProviderContext> context_; | |
| 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 | |
| OLD | NEW |