| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_REMOTE_DEVICE_H_ | 5 #ifndef COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ |
| 6 #define COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ | 6 #define COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "components/cryptauth/proto/cryptauth_api.pb.h" | |
| 12 | |
| 13 namespace cryptauth { | 11 namespace cryptauth { |
| 14 | 12 |
| 15 struct RemoteDevice { | 13 struct RemoteDevice { |
| 16 public: | 14 public: |
| 17 std::string user_id; | 15 std::string user_id; |
| 18 std::string name; | 16 std::string name; |
| 19 std::string public_key; | 17 std::string public_key; |
| 20 std::string bluetooth_address; | 18 std::string bluetooth_address; |
| 21 std::string persistent_symmetric_key; | 19 std::string persistent_symmetric_key; |
| 22 std::string sign_in_challenge; | 20 std::string sign_in_challenge; |
| 23 | 21 |
| 24 // Note: To save space, the BeaconSeeds may not necessarily be included in | |
| 25 // this object. | |
| 26 bool are_beacon_seeds_loaded; | |
| 27 std::vector<BeaconSeed> beacon_seeds; | |
| 28 | |
| 29 RemoteDevice(); | 22 RemoteDevice(); |
| 30 RemoteDevice(const std::string& user_id, | 23 RemoteDevice(const std::string& user_id, |
| 31 const std::string& name, | 24 const std::string& name, |
| 32 const std::string& public_key, | 25 const std::string& public_key, |
| 33 const std::string& bluetooth_address, | 26 const std::string& bluetooth_address, |
| 34 const std::string& persistent_symmetric_key, | 27 const std::string& persistent_symmetric_key, |
| 35 std::string sign_in_challenge); | 28 std::string sign_in_challenge); |
| 36 RemoteDevice(const RemoteDevice& other); | 29 RemoteDevice(const RemoteDevice& other); |
| 37 ~RemoteDevice(); | 30 ~RemoteDevice(); |
| 38 | 31 |
| 39 // Loads a vector of BeaconSeeds for the RemoteDevice. | |
| 40 void LoadBeaconSeeds(const std::vector<BeaconSeed>& beacon_seeds); | |
| 41 | |
| 42 // Returns a unique ID for the device. | 32 // Returns a unique ID for the device. |
| 43 std::string GetDeviceId() const; | 33 std::string GetDeviceId() const; |
| 44 | 34 |
| 45 // Returns a shortened device ID for the purpose of concise logging (device | 35 // Returns a shortened device ID for the purpose of concise logging (device |
| 46 // IDs are often so long that logs are difficult to read). Note that this | 36 // IDs are often so long that logs are difficult to read). Note that this |
| 47 // ID is not guaranteed to be unique, so it should only be used for log. | 37 // ID is not guaranteed to be unique, so it should only be used for log. |
| 48 std::string GetTruncatedDeviceIdForLogs() const; | 38 std::string GetTruncatedDeviceIdForLogs() const; |
| 49 | 39 |
| 50 bool operator==(const RemoteDevice& other) const; | 40 bool operator==(const RemoteDevice& other) const; |
| 51 | 41 |
| 52 // Compares devices via their public keys. Note that this function is | 42 // Compares devices via their public keys. Note that this function is |
| 53 // necessary in order to use |RemoteDevice| as a key of a std::map. | 43 // necessary in order to use |RemoteDevice| as a key of a std::map. |
| 54 bool operator<(const RemoteDevice& other) const; | 44 bool operator<(const RemoteDevice& other) const; |
| 55 | 45 |
| 56 // Static method for truncated device ID for logs. | 46 // Static method for truncated device ID for logs. |
| 57 static std::string TruncateDeviceIdForLogs(const std::string& full_id); | 47 static std::string TruncateDeviceIdForLogs(const std::string& full_id); |
| 58 }; | 48 }; |
| 59 | 49 |
| 60 typedef std::vector<RemoteDevice> RemoteDeviceList; | 50 typedef std::vector<RemoteDevice> RemoteDeviceList; |
| 61 | 51 |
| 62 } // namespace cryptauth | 52 } // namespace cryptauth |
| 63 | 53 |
| 64 #endif // COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ | 54 #endif // COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ |
| OLD | NEW |