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

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

Issue 2561683002: Update CryptAuthDeviceManager to store all synced devices instead of only unlock keys. (Closed)
Patch Set: Created 4 years 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 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_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_DEVICE_MANAGER_H 5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_DEVICE_MANAGER_H
6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_DEVICE_MANAGER_H 6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CRYPTAUTH_DEVICE_MANAGER_H
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::TimeDelta GetTimeToNextAttempt() const; 98 base::TimeDelta GetTimeToNextAttempt() const;
99 99
100 // Returns true if a device sync attempt is currently in progress. 100 // Returns true if a device sync attempt is currently in progress.
101 bool IsSyncInProgress() const; 101 bool IsSyncInProgress() const;
102 102
103 // Returns true if the last device sync failed and the manager is now 103 // Returns true if the last device sync failed and the manager is now
104 // scheduling sync attempts more aggressively to recover. If no enrollment 104 // scheduling sync attempts more aggressively to recover. If no enrollment
105 // has ever been recorded, then this function will also return true. 105 // has ever been recorded, then this function will also return true.
106 bool IsRecoveringFromFailure() const; 106 bool IsRecoveringFromFailure() const;
107 107
108 // Returns a list of all remote devices that have been synced.
109 const std::vector<cryptauth::ExternalDeviceInfo> synced_devices() const {
110 return synced_devices_;
Ryan Hansberry 2016/12/07 23:51:37 Noob question: Why implement this method in the he
Kyle Horimoto 2016/12/08 00:11:13 It's common to trivial getters this way to tell th
111 }
112
108 // Returns a list of remote devices that can unlock the user's other devices. 113 // Returns a list of remote devices that can unlock the user's other devices.
109 const std::vector<cryptauth::ExternalDeviceInfo>& unlock_keys() const { 114 const std::vector<cryptauth::ExternalDeviceInfo> unlock_keys() const;
110 return unlock_keys_; 115
111 } 116 // Returns a list of remote devices that can host tether hotspots.
117 const std::vector<cryptauth::ExternalDeviceInfo> tether_hosts() const;
112 118
113 protected: 119 protected:
114 // Creates a new SyncScheduler instance. Exposed for testing. 120 // Creates a new SyncScheduler instance. Exposed for testing.
115 virtual std::unique_ptr<SyncScheduler> CreateSyncScheduler(); 121 virtual std::unique_ptr<SyncScheduler> CreateSyncScheduler();
116 122
117 private: 123 private:
118 // CryptAuthGCMManager::Observer: 124 // CryptAuthGCMManager::Observer:
119 void OnResyncMessage() override; 125 void OnResyncMessage() override;
120 126
121 // Updates |unlock_keys_| by fetching the list stored in |pref_service_|. 127 // Updates |unlock_keys_| by fetching the list stored in |pref_service_|.
(...skipping 15 matching lines...) Expand all
137 143
138 // Notifies when GCM push messages trigger device sync. Not owned and must 144 // Notifies when GCM push messages trigger device sync. Not owned and must
139 // outlive this instance. 145 // outlive this instance.
140 CryptAuthGCMManager* gcm_manager_; 146 CryptAuthGCMManager* gcm_manager_;
141 147
142 // Contains preferences that outlive the lifetime of this object and across 148 // Contains preferences that outlive the lifetime of this object and across
143 // process restarts. |pref_service_| must outlive the lifetime of this 149 // process restarts. |pref_service_| must outlive the lifetime of this
144 // instance. 150 // instance.
145 PrefService* const pref_service_; 151 PrefService* const pref_service_;
146 152
147 // The unlock keys currently synced from CryptAuth. 153 // All devices currently synced from CryptAuth.
148 std::vector<cryptauth::ExternalDeviceInfo> unlock_keys_; 154 std::vector<cryptauth::ExternalDeviceInfo> synced_devices_;
149 155
150 // Schedules the time between device sync attempts. 156 // Schedules the time between device sync attempts.
151 std::unique_ptr<SyncScheduler> scheduler_; 157 std::unique_ptr<SyncScheduler> scheduler_;
152 158
153 // Contains the SyncRequest that |scheduler_| requests when a device sync 159 // Contains the SyncRequest that |scheduler_| requests when a device sync
154 // attempt is made. 160 // attempt is made.
155 std::unique_ptr<SyncScheduler::SyncRequest> sync_request_; 161 std::unique_ptr<SyncScheduler::SyncRequest> sync_request_;
156 162
157 // The CryptAuthEnroller instance for the current sync attempt. A new 163 // The CryptAuthEnroller instance for the current sync attempt. A new
158 // instance will be created for each individual attempt. 164 // instance will be created for each individual attempt.
159 std::unique_ptr<CryptAuthClient> cryptauth_client_; 165 std::unique_ptr<CryptAuthClient> cryptauth_client_;
160 166
161 // List of observers. 167 // List of observers.
162 base::ObserverList<Observer> observers_; 168 base::ObserverList<Observer> observers_;
163 169
164 base::WeakPtrFactory<CryptAuthDeviceManager> weak_ptr_factory_; 170 base::WeakPtrFactory<CryptAuthDeviceManager> weak_ptr_factory_;
165 171
166 DISALLOW_COPY_AND_ASSIGN(CryptAuthDeviceManager); 172 DISALLOW_COPY_AND_ASSIGN(CryptAuthDeviceManager);
167 }; 173 };
168 174
169 } // namespace cryptauth 175 } // namespace cryptauth
170 176
171 #endif // COMPONENTS_PROXIMITY_CRYPTAUTH_CRYPTAUTH_DEVICE_MANAGER_H 177 #endif // COMPONENTS_PROXIMITY_CRYPTAUTH_CRYPTAUTH_DEVICE_MANAGER_H
OLDNEW
« no previous file with comments | « no previous file | components/cryptauth/cryptauth_device_manager.cc » ('j') | components/cryptauth/cryptauth_device_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698