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

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

Issue 2847233003: [EasyUnlock] Move DataWithTimestamp out of ForegroundEidGenerator so it can be shared. (Closed)
Patch Set: fixes 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 unified diff | Download patch
« no previous file with comments | « components/cryptauth/BUILD.gn ('k') | components/cryptauth/background_eid_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef COMPONENTS_CRYPTAUTH_BLE_BACKGROUND_EID_GENERATOR_H_ 5 #ifndef COMPONENTS_CRYPTAUTH_BLE_BACKGROUND_EID_GENERATOR_H_
6 #define COMPONENTS_CRYPTAUTH_BLE_BACKGROUND_EID_GENERATOR_H_ 6 #define COMPONENTS_CRYPTAUTH_BLE_BACKGROUND_EID_GENERATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/time/clock.h" 13 #include "base/time/clock.h"
14 #include "components/cryptauth/data_with_timestamp.h"
14 15
15 namespace cryptauth { 16 namespace cryptauth {
16 17
17 class BeaconSeed; 18 class BeaconSeed;
18 class RawEidGenerator; 19 class RawEidGenerator;
19 20
20 // Generates ephemeral ID (EID) values that are broadcast for background BLE 21 // Generates ephemeral ID (EID) values that are broadcast for background BLE
21 // advertisements in the ProximityAuth protocol. 22 // advertisements in the ProximityAuth protocol.
22 // 23 //
23 // When advertising in background mode, we offload advertising to the hardware 24 // When advertising in background mode, we offload advertising to the hardware
24 // in order to conserve battery. We assume, however, that the scanning side is 25 // in order to conserve battery. We assume, however, that the scanning side is
25 // not bound by battery constraints. 26 // not bound by battery constraints.
26 // 27 //
27 // For the inverse of this model, in which advertising is battery-sensitive, see 28 // For the inverse of this model, in which advertising is battery-sensitive, see
28 // ForegroundEidGenerator. 29 // ForegroundEidGenerator.
29 class BackgroundEidGenerator { 30 class BackgroundEidGenerator {
30 public: 31 public:
31 BackgroundEidGenerator(); 32 BackgroundEidGenerator();
32 virtual ~BackgroundEidGenerator(); 33 virtual ~BackgroundEidGenerator();
33 34
34 // Returns a list of the nearest EIDs from the current time. Note that the 35 // Returns a list of the nearest EIDs from the current time. Note that the
35 // list of EIDs is sorted from earliest timestamp to latest. 36 // list of EIDs is sorted from earliest timestamp to latest.
36 virtual std::vector<std::string> GenerateNearestEids( 37 virtual std::vector<DataWithTimestamp> GenerateNearestEids(
37 const std::vector<BeaconSeed>& beacon_seed) const; 38 const std::vector<BeaconSeed>& beacon_seed) const;
38 39
39 private: 40 private:
40 friend class CryptAuthBackgroundEidGeneratorTest; 41 friend class CryptAuthBackgroundEidGeneratorTest;
41 BackgroundEidGenerator(std::unique_ptr<RawEidGenerator> raw_eid_generator, 42 BackgroundEidGenerator(std::unique_ptr<RawEidGenerator> raw_eid_generator,
42 std::unique_ptr<base::Clock> clock); 43 std::unique_ptr<base::Clock> clock);
43 44
44 // Helper function to generate the EID for any |timestamp_ms|, properly 45 // Helper function to generate the EID for any |timestamp_ms|, properly
45 // calculating the start of the period. Returns nullptr if |timestamp_ms| is 46 // calculating the start of the period. Returns nullptr if |timestamp_ms| is
46 // outside of range of |beacon_seeds|. 47 // outside of range of |beacon_seeds|.
47 std::unique_ptr<std::string> GenerateEid( 48 std::unique_ptr<DataWithTimestamp> GenerateEid(
48 int64_t timestamp_ms, 49 int64_t timestamp_ms,
49 const std::vector<BeaconSeed>& beacon_seeds) const; 50 const std::vector<BeaconSeed>& beacon_seeds) const;
50 51
51 std::unique_ptr<RawEidGenerator> raw_eid_generator_; 52 std::unique_ptr<RawEidGenerator> raw_eid_generator_;
52 std::unique_ptr<base::Clock> clock_; 53 std::unique_ptr<base::Clock> clock_;
53 54
54 DISALLOW_COPY_AND_ASSIGN(BackgroundEidGenerator); 55 DISALLOW_COPY_AND_ASSIGN(BackgroundEidGenerator);
55 }; 56 };
56 57
57 } // cryptauth 58 } // cryptauth
58 59
59 #endif // COMPONENTS_CRYPTAUTH_BLE_BACKGROUND_EID_GENERATOR_H_ 60 #endif // COMPONENTS_CRYPTAUTH_BLE_BACKGROUND_EID_GENERATOR_H_
OLDNEW
« no previous file with comments | « components/cryptauth/BUILD.gn ('k') | components/cryptauth/background_eid_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698