Chromium Code Reviews| Index: chromeos/components/tether/local_device_data_provider.h |
| diff --git a/chromeos/components/tether/local_device_data_provider.h b/chromeos/components/tether/local_device_data_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..240cc6e6c7b7509c2b0d842212e90bb4a257b165 |
| --- /dev/null |
| +++ b/chromeos/components/tether/local_device_data_provider.h |
| @@ -0,0 +1,88 @@ |
| +// Copyright 2016 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 CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H |
| +#define CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H |
| + |
| +#include <memory> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ptr_util.h" |
| + |
| +namespace cryptauth { |
| +class BeaconSeed; |
| +class ExternalDeviceInfo; |
| +class CryptAuthDeviceManager; |
| +class CryptAuthEnrollmentManager; |
| +} |
| + |
| +namespace chromeos { |
| + |
| +namespace tether { |
| + |
| +// Fetches CryptAuth data about the local device (i.e., the device on which this |
| +// code is running) for the current user (i.e., the one which is logged-in). |
| +class LocalDeviceDataProvider { |
| + public: |
| + LocalDeviceDataProvider( |
| + const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager, |
| + const cryptauth::CryptAuthEnrollmentManager* |
| + cryptauth_enrollment_manager); |
| + virtual ~LocalDeviceDataProvider(); |
| + |
| + // Fetches the public key and/or the beacon seeds for the local device. |
| + // Returns whether the operation succeeded. If |nullptr| is passed as a |
| + // parameter, the associated data will not be fetched. |
| + bool GetLocalDeviceData( |
| + std::string* public_key_out, |
| + std::vector<cryptauth::BeaconSeed>* beacon_seeds_out) const; |
| + |
| + private: |
| + friend class LocalDeviceDataProviderTest; |
| + |
| + 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.
|
| + public: |
| + virtual ~LocalDeviceDataProviderContext() {} |
| + virtual std::string GetUserPublicKey() const = 0; |
| + virtual std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices() |
| + const = 0; |
| + }; |
| + |
| + class LocalDeviceDataProviderContextImpl |
| + : public LocalDeviceDataProviderContext { |
| + public: |
| + LocalDeviceDataProviderContextImpl( |
| + const cryptauth::CryptAuthDeviceManager* cryptauth_device_manager, |
| + const cryptauth::CryptAuthEnrollmentManager* |
| + cryptauth_enrollment_manager); |
| + ~LocalDeviceDataProviderContextImpl() override; |
| + |
| + std::string GetUserPublicKey() const override; |
| + std::vector<cryptauth::ExternalDeviceInfo> GetSyncedDevices() |
| + const override; |
| + |
| + private: |
| + // Not owned and must outlive this instance. |
| + const cryptauth::CryptAuthDeviceManager* const cryptauth_device_manager_; |
| + |
| + // Not owned and must outlive this instance. |
| + const cryptauth::CryptAuthEnrollmentManager* const |
| + cryptauth_enrollment_manager_; |
| + }; |
| + |
| + LocalDeviceDataProvider( |
| + std::unique_ptr<LocalDeviceDataProviderContext> context); |
| + |
| + std::unique_ptr<LocalDeviceDataProviderContext> context_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(LocalDeviceDataProvider); |
| +}; |
| + |
| +} // namespace tether |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_COMPONENTS_TETHER_LOCAL_DEVICE_DATA_PROVIDER_H |