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

Side by Side Diff: components/cryptauth/background_eid_generator.cc

Issue 2844743002: Revert of [EasyUnlock] Update BluetoothLowEnergyConnectionFinder to look for EIDs. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cryptauth/background_eid_generator.h" 5 #include "components/cryptauth/background_eid_generator.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/time/default_clock.h" 11 #include "base/time/default_clock.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/cryptauth/proto/cryptauth_api.pb.h" 13 #include "components/cryptauth/proto/cryptauth_api.pb.h"
14 #include "components/cryptauth/raw_eid_generator.h" 14 #include "components/cryptauth/raw_eid_generator.h"
15 #include "components/cryptauth/raw_eid_generator_impl.h" 15 #include "components/cryptauth/raw_eid_generator_impl.h"
16 #include "components/proximity_auth/logging/logging.h" 16 #include "components/proximity_auth/logging/logging.h"
17 17
18 namespace cryptauth { 18 namespace cryptauth {
19 19
20 namespace { 20 namespace {
21 21
22 // The duration of a EID period in milliseconds. 22 // The duration of a EID period in milliseconds.
23 const int64_t kEidPeriodMs = 15 * 60 * 1000; // 15 minutes 23 const int64_t kEidPeriodMs = base::TimeDelta::FromMinutes(15).InMilliseconds();
24 24
25 // The number of periods to look forward and backwards when calculating the 25 // The number of periods to look forward and backwards when calculating the
26 // neartest EIDs. 26 // neartest EIDs.
27 const int kEidLookAhead = 2; 27 const int kEidLookAhead = 2;
28 28
29 // Returns the BeaconSeed valid for |timestamp_ms|, or nullptr if none can be 29 // Returns the BeaconSeed valid for |timestamp_ms|, or nullptr if none can be
30 // found. 30 // found.
31 const BeaconSeed* GetBeaconSeedForTimestamp( 31 const BeaconSeed* GetBeaconSeedForTimestamp(
32 int64_t timestamp_ms, 32 int64_t timestamp_ms,
33 const std::vector<BeaconSeed>& beacon_seeds) { 33 const std::vector<BeaconSeed>& beacon_seeds) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 seed_start_time_ms + (offset_time_ms / kEidPeriodMs) * kEidPeriodMs; 86 seed_start_time_ms + (offset_time_ms / kEidPeriodMs) * kEidPeriodMs;
87 87
88 std::string eid = raw_eid_generator_->GenerateEid( 88 std::string eid = raw_eid_generator_->GenerateEid(
89 beacon_seed->data(), start_of_period_ms, nullptr); 89 beacon_seed->data(), start_of_period_ms, nullptr);
90 90
91 PA_LOG(INFO) << " " << start_of_period_ms << ": " << eid; 91 PA_LOG(INFO) << " " << start_of_period_ms << ": " << eid;
92 return base::MakeUnique<std::string>(eid); 92 return base::MakeUnique<std::string>(eid);
93 } 93 }
94 94
95 } // cryptauth 95 } // cryptauth
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc ('k') | components/proximity_auth/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698