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

Unified Diff: components/cryptauth/remote_device_loader.cc

Issue 2859053003: [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: fix memory issue Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cryptauth/remote_device_loader.h ('k') | components/cryptauth/remote_device_loader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cryptauth/remote_device_loader.cc
diff --git a/components/cryptauth/remote_device_loader.cc b/components/cryptauth/remote_device_loader.cc
index d673309b0c3ae95dab713387608d22988d5b5d7b..705a1262d84f79b5b9a20c94c3a25d150e6bcdd6 100644
--- a/components/cryptauth/remote_device_loader.cc
+++ b/components/cryptauth/remote_device_loader.cc
@@ -56,7 +56,8 @@ RemoteDeviceLoader::RemoteDeviceLoader(
const std::string& user_id,
const std::string& user_private_key,
std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate)
- : remaining_devices_(device_info_list),
+ : should_load_beacon_seeds_(false),
+ remaining_devices_(device_info_list),
user_id_(user_id),
user_private_key_(user_private_key),
secure_message_delegate_(std::move(secure_message_delegate)),
@@ -64,8 +65,10 @@ RemoteDeviceLoader::RemoteDeviceLoader(
RemoteDeviceLoader::~RemoteDeviceLoader() {}
-void RemoteDeviceLoader::Load(const RemoteDeviceCallback& callback) {
+void RemoteDeviceLoader::Load(bool should_load_beacon_seeds,
+ const RemoteDeviceCallback& callback) {
DCHECK(callback_.is_null());
+ should_load_beacon_seeds_ = should_load_beacon_seeds;
callback_ = callback;
PA_LOG(INFO) << "Loading " << remaining_devices_.size()
<< " remote devices";
@@ -101,9 +104,18 @@ void RemoteDeviceLoader::OnPSKDerived(
PA_LOG(INFO) << "Derived PSK for " << device.friendly_device_name()
<< ", " << remaining_devices_.size() << " keys remaining.";
- remote_devices_.push_back(cryptauth::RemoteDevice(
+ cryptauth::RemoteDevice remote_device(
user_id_, device.friendly_device_name(), device.public_key(),
- device.bluetooth_address(), psk, std::string()));
+ device.bluetooth_address(), psk, std::string());
+
+ if (should_load_beacon_seeds_) {
+ std::vector<BeaconSeed> beacon_seeds;
+ for (const BeaconSeed& beacon_seed : device.beacon_seeds()) {
+ beacon_seeds.push_back(beacon_seed);
+ }
+ remote_device.LoadBeaconSeeds(beacon_seeds);
+ }
+ remote_devices_.push_back(remote_device);
if (remaining_devices_.empty())
callback_.Run(remote_devices_);
« no previous file with comments | « components/cryptauth/remote_device_loader.h ('k') | components/cryptauth/remote_device_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698