OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_LOADER_H_ | 5 #ifndef COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_LOADER_H_ |
6 #define COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_LOADER_H_ | 6 #define COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_LOADER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 RemoteDeviceLoader( | 55 RemoteDeviceLoader( |
56 const std::vector<cryptauth::ExternalDeviceInfo>& device_info_list, | 56 const std::vector<cryptauth::ExternalDeviceInfo>& device_info_list, |
57 const std::string& user_id, | 57 const std::string& user_id, |
58 const std::string& user_private_key, | 58 const std::string& user_private_key, |
59 std::unique_ptr<cryptauth::SecureMessageDelegate> | 59 std::unique_ptr<cryptauth::SecureMessageDelegate> |
60 secure_message_delegate); | 60 secure_message_delegate); |
61 | 61 |
62 virtual ~RemoteDeviceLoader(); | 62 virtual ~RemoteDeviceLoader(); |
63 | 63 |
64 // Loads the RemoteDevice objects. |callback| will be invoked upon completion. | 64 // Loads the RemoteDevice objects. |callback| will be invoked upon completion. |
65 // For space considerations, BeaconSeeds will only be loaded if | |
66 // |should_load_beacon_seeds| is true. | |
67 typedef base::Callback<void(const cryptauth::RemoteDeviceList&)> | 65 typedef base::Callback<void(const cryptauth::RemoteDeviceList&)> |
68 RemoteDeviceCallback; | 66 RemoteDeviceCallback; |
69 virtual void Load(bool should_load_beacon_seeds, | 67 virtual void Load(const RemoteDeviceCallback& callback); |
70 const RemoteDeviceCallback& callback); | |
71 | 68 |
72 private: | 69 private: |
73 // Called when the PSK is derived for each device. If the PSKs for all devices | 70 // Called when the PSK is derived for each device. If the PSKs for all devices |
74 // have been derived, then we can invoke |callback_|. | 71 // have been derived, then we can invoke |callback_|. |
75 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& device, | 72 void OnPSKDerived(const cryptauth::ExternalDeviceInfo& device, |
76 const std::string& psk); | 73 const std::string& psk); |
77 | 74 |
78 // True if the loader should include BeaconSeeds in the loaded RemoteDevices. | |
79 bool should_load_beacon_seeds_; | |
80 | |
81 // The remaining devices whose PSK we're waiting on. | 75 // The remaining devices whose PSK we're waiting on. |
82 std::vector<cryptauth::ExternalDeviceInfo> remaining_devices_; | 76 std::vector<cryptauth::ExternalDeviceInfo> remaining_devices_; |
83 | 77 |
84 // The id of the user who the remote devices belong to. | 78 // The id of the user who the remote devices belong to. |
85 const std::string user_id_; | 79 const std::string user_id_; |
86 | 80 |
87 // The private key of the user's local device. | 81 // The private key of the user's local device. |
88 const std::string user_private_key_; | 82 const std::string user_private_key_; |
89 | 83 |
90 // Performs the PSK key derivation. | 84 // Performs the PSK key derivation. |
91 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate_; | 85 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate_; |
92 | 86 |
93 // Invoked when the RemoteDevices are loaded. | 87 // Invoked when the RemoteDevices are loaded. |
94 RemoteDeviceCallback callback_; | 88 RemoteDeviceCallback callback_; |
95 | 89 |
96 // The collection of RemoteDevices to return. | 90 // The collection of RemoteDevices to return. |
97 cryptauth::RemoteDeviceList remote_devices_; | 91 cryptauth::RemoteDeviceList remote_devices_; |
98 | 92 |
99 base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_; | 93 base::WeakPtrFactory<RemoteDeviceLoader> weak_ptr_factory_; |
100 | 94 |
101 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader); | 95 DISALLOW_COPY_AND_ASSIGN(RemoteDeviceLoader); |
102 }; | 96 }; |
103 | 97 |
104 } // namespace cryptauth | 98 } // namespace cryptauth |
105 | 99 |
106 #endif // COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_LOADER_H_ | 100 #endif // COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_LOADER_H_ |
OLD | NEW |