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

Side by Side Diff: components/proximity_auth/cryptauth/cryptauth_device_manager.cc

Issue 1372283002: Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: Created 5 years, 2 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
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 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h" 5 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h"
6 6
7 #include "base/prefs/pref_registry_simple.h" 7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "components/proximity_auth/cryptauth/base64url.h" 10 #include "components/proximity_auth/cryptauth/base64url.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 CryptAuthDeviceManager::CryptAuthDeviceManager( 88 CryptAuthDeviceManager::CryptAuthDeviceManager(
89 scoped_ptr<base::Clock> clock, 89 scoped_ptr<base::Clock> clock,
90 scoped_ptr<CryptAuthClientFactory> client_factory, 90 scoped_ptr<CryptAuthClientFactory> client_factory,
91 CryptAuthGCMManager* gcm_manager, 91 CryptAuthGCMManager* gcm_manager,
92 PrefService* pref_service) 92 PrefService* pref_service)
93 : clock_(clock.Pass()), 93 : clock_(clock.Pass()),
94 client_factory_(client_factory.Pass()), 94 client_factory_(client_factory.Pass()),
95 gcm_manager_(gcm_manager), 95 gcm_manager_(gcm_manager),
96 pref_service_(pref_service), 96 pref_service_(pref_service),
97 weak_ptr_factory_(this) {} 97 weak_ptr_factory_(this) {
98 UpdateUnlockKeysFromPrefs();
99 }
98 100
99 CryptAuthDeviceManager::~CryptAuthDeviceManager() { 101 CryptAuthDeviceManager::~CryptAuthDeviceManager() {
100 gcm_manager_->RemoveObserver(this); 102 gcm_manager_->RemoveObserver(this);
101 } 103 }
102 104
103 // static 105 // static
104 void CryptAuthDeviceManager::RegisterPrefs(PrefRegistrySimple* registry) { 106 void CryptAuthDeviceManager::RegisterPrefs(PrefRegistrySimple* registry) {
105 registry->RegisterDoublePref(prefs::kCryptAuthDeviceSyncLastSyncTimeSeconds, 107 registry->RegisterDoublePref(prefs::kCryptAuthDeviceSyncLastSyncTimeSeconds,
106 0.0); 108 0.0);
107 registry->RegisterBooleanPref( 109 registry->RegisterBooleanPref(
108 prefs::kCryptAuthDeviceSyncIsRecoveringFromFailure, false); 110 prefs::kCryptAuthDeviceSyncIsRecoveringFromFailure, false);
109 registry->RegisterIntegerPref(prefs::kCryptAuthDeviceSyncReason, 111 registry->RegisterIntegerPref(prefs::kCryptAuthDeviceSyncReason,
110 cryptauth::INVOCATION_REASON_UNKNOWN); 112 cryptauth::INVOCATION_REASON_UNKNOWN);
111 registry->RegisterListPref(prefs::kCryptAuthDeviceSyncUnlockKeys); 113 registry->RegisterListPref(prefs::kCryptAuthDeviceSyncUnlockKeys);
112 } 114 }
113 115
114 void CryptAuthDeviceManager::Start() { 116 void CryptAuthDeviceManager::Start() {
115 UpdateUnlockKeysFromPrefs();
116
117 gcm_manager_->AddObserver(this); 117 gcm_manager_->AddObserver(this);
118 118
119 base::Time last_successful_sync = GetLastSyncTime(); 119 base::Time last_successful_sync = GetLastSyncTime();
120 base::TimeDelta elapsed_time_since_last_sync = 120 base::TimeDelta elapsed_time_since_last_sync =
121 clock_->Now() - last_successful_sync; 121 clock_->Now() - last_successful_sync;
122 122
123 bool is_recovering_from_failure = 123 bool is_recovering_from_failure =
124 pref_service_->GetBoolean( 124 pref_service_->GetBoolean(
125 prefs::kCryptAuthDeviceSyncIsRecoveringFromFailure) || 125 prefs::kCryptAuthDeviceSyncIsRecoveringFromFailure) ||
126 last_successful_sync.is_null(); 126 last_successful_sync.is_null();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 request.set_invocation_reason(invocation_reason); 283 request.set_invocation_reason(invocation_reason);
284 request.set_allow_stale_read(is_sync_speculative); 284 request.set_allow_stale_read(is_sync_speculative);
285 cryptauth_client_->GetMyDevices( 285 cryptauth_client_->GetMyDevices(
286 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, 286 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess,
287 weak_ptr_factory_.GetWeakPtr()), 287 weak_ptr_factory_.GetWeakPtr()),
288 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, 288 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure,
289 weak_ptr_factory_.GetWeakPtr())); 289 weak_ptr_factory_.GetWeakPtr()));
290 } 290 }
291 291
292 } // namespace proximity_auth 292 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698