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

Unified Diff: components/cryptauth/background_eid_generator.cc

Issue 2847233003: [EasyUnlock] Move DataWithTimestamp out of ForegroundEidGenerator so it can be shared. (Closed)
Patch Set: fixes Created 3 years, 8 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
Index: components/cryptauth/background_eid_generator.cc
diff --git a/components/cryptauth/background_eid_generator.cc b/components/cryptauth/background_eid_generator.cc
index 1103e8cba45c9c9676679b41c16b3cf6b76f2104..a8a1b7bc0944edaef46906087b6b6e1ccd052ac2 100644
--- a/components/cryptauth/background_eid_generator.cc
+++ b/components/cryptauth/background_eid_generator.cc
@@ -54,23 +54,24 @@ BackgroundEidGenerator::BackgroundEidGenerator(
: raw_eid_generator_(std::move(raw_eid_generator)),
clock_(std::move(clock)) {}
-std::vector<std::string> BackgroundEidGenerator::GenerateNearestEids(
+std::vector<DataWithTimestamp> BackgroundEidGenerator::GenerateNearestEids(
const std::vector<BeaconSeed>& beacon_seeds) const {
int64_t now_timestamp_ms = clock_->Now().ToJavaTime();
- std::vector<std::string> eids;
+ std::vector<DataWithTimestamp> eids;
- PA_LOG(INFO) << "Generating EIDs:";
for (int i = -kEidLookAhead; i <= kEidLookAhead; ++i) {
int64_t timestamp_ms = now_timestamp_ms + i * kEidPeriodMs;
- std::unique_ptr<std::string> eid = GenerateEid(timestamp_ms, beacon_seeds);
+ std::unique_ptr<DataWithTimestamp> eid =
+ GenerateEid(timestamp_ms, beacon_seeds);
if (eid)
eids.push_back(*eid);
}
+ PA_LOG(INFO) << "Generated EIDs: " << DataWithTimestamp::ToDebugString(eids);
return eids;
}
-std::unique_ptr<std::string> BackgroundEidGenerator::GenerateEid(
+std::unique_ptr<DataWithTimestamp> BackgroundEidGenerator::GenerateEid(
int64_t timestamp_ms,
const std::vector<BeaconSeed>& beacon_seeds) const {
const BeaconSeed* beacon_seed =
@@ -88,8 +89,8 @@ std::unique_ptr<std::string> BackgroundEidGenerator::GenerateEid(
std::string eid = raw_eid_generator_->GenerateEid(
beacon_seed->data(), start_of_period_ms, nullptr);
- PA_LOG(INFO) << " " << start_of_period_ms << ": " << eid;
- return base::MakeUnique<std::string>(eid);
+ return base::MakeUnique<DataWithTimestamp>(eid, start_of_period_ms,
+ start_of_period_ms + kEidPeriodMs);
}
} // cryptauth
« no previous file with comments | « components/cryptauth/background_eid_generator.h ('k') | components/cryptauth/background_eid_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698