Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_EID_GENERATOR_H _ | |
| 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_EID_GENERATOR_H _ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include <memory> | |
| 12 | |
| 13 #include "components/proximity_auth/remote_device.h" | |
| 14 | |
| 15 namespace proximity_auth { | |
| 16 namespace weave { | |
| 17 | |
| 18 // Represent a EID generator for a single device. The code client has the | |
|
rkc
2016/07/27 00:56:34
What's an EID?
jingxuy
2016/07/27 23:31:48
Done.
| |
| 19 // responsiblity for keeping track of multiple clients | |
| 20 class BluetoothLowEnergyEidGenerator { | |
| 21 public: | |
| 22 class Factory { | |
|
Kyle Horimoto
2016/07/27 17:58:48
Is there a reason that a Factory is needed for thi
jingxuy
2016/07/27 23:31:48
I was under the impression that you want to mock o
| |
| 23 public: | |
| 24 // TODO(jingxuy): this is just stop compiler from complaining. | |
|
rkc
2016/07/27 00:56:34
Complaining about?
Generally when a compiler compl
jingxuy
2016/07/27 23:31:48
I didn't have a .cc file since I intend this class
| |
| 25 static std::unique_ptr<BluetoothLowEnergyEidGenerator> NewInstance( | |
| 26 const RemoteDevice& device) { | |
| 27 return std::unique_ptr<BluetoothLowEnergyEidGenerator>( | |
| 28 new BluetoothLowEnergyEidGenerator(device)); | |
| 29 } | |
| 30 | |
| 31 // Exposed for testing. | |
| 32 static void SetInstanceForTesting(Factory* factory); | |
| 33 | |
| 34 protected: | |
| 35 // Exposed for testing. | |
| 36 virtual std::unique_ptr<BluetoothLowEnergyEidGenerator> BuildInstance( | |
| 37 const RemoteDevice& device); | |
| 38 | |
| 39 private: | |
| 40 static Factory* factory_instance_; | |
| 41 }; | |
| 42 | |
| 43 typedef uint8_t EidSeed[32]; | |
|
rkc
2016/07/27 00:56:34
Why 32? Also, make this a constexpr.
Kyle Horimoto
2016/07/27 17:58:48
+1, I'm not sure that seeds are 32 bytes, but even
jingxuy
2016/07/27 23:31:48
According to Jeremy it is 256 bits. This typedef i
| |
| 44 | |
| 45 // TODO(tether-dev): Make this actually generate EID. | |
| 46 // This function should look at the time and get the correct seed out of the | |
| 47 // remote device. If this seed is different from the current_seed_, then | |
| 48 // re-seed the generator. Otherwise generate based on time and stuff. | |
| 49 uint16_t GetEid() { return 42; } | |
|
rkc
2016/07/27 00:56:34
Again, why 42?
Kyle Horimoto
2016/07/27 17:58:48
This function should take a list of BeaconSeeds an
Kyle Horimoto
2016/07/27 17:58:48
I think she's just returning a fake value and will
jingxuy
2016/07/27 23:31:48
It has a TODO above the function explaining exactl
jingxuy
2016/07/27 23:31:48
I think our design for the EID generator is differ
jingxuy
2016/07/28 22:09:03
Resolved on offline discussion. Currently will tak
| |
| 50 | |
| 51 protected: | |
| 52 BluetoothLowEnergyEidGenerator(const RemoteDevice& device) | |
|
rkc
2016/07/27 00:56:34
Why is this protected?
jingxuy
2016/07/27 23:31:48
Same as the comment in the rotator. It comes with
| |
| 53 : device_(device){}; | |
| 54 | |
| 55 private: | |
| 56 const RemoteDevice& device_; | |
| 57 | |
| 58 EidSeed current_seed_; | |
| 59 }; | |
| 60 | |
| 61 } // namespace weave | |
| 62 | |
| 63 } // namespace proximity_auth | |
| 64 | |
| 65 #endif | |
| OLD | NEW |