Chromium Code Reviews| 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 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" | 5 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 allow_cryptohome_backoff_ ? 0u : kMaxCryptohomeBackoffIntervalMs, | 326 allow_cryptohome_backoff_ ? 0u : kMaxCryptohomeBackoffIntervalMs, |
| 327 base::Bind(&EasyUnlockServiceSignin::OnUserDataLoaded, | 327 base::Bind(&EasyUnlockServiceSignin::OnUserDataLoaded, |
| 328 weak_ptr_factory_.GetWeakPtr(), | 328 weak_ptr_factory_.GetWeakPtr(), |
| 329 user_id_)); | 329 user_id_)); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void EasyUnlockServiceSignin::OnUserDataLoaded( | 332 void EasyUnlockServiceSignin::OnUserDataLoaded( |
| 333 const std::string& user_id, | 333 const std::string& user_id, |
| 334 bool success, | 334 bool success, |
| 335 const chromeos::EasyUnlockDeviceKeyDataList& devices) { | 335 const chromeos::EasyUnlockDeviceKeyDataList& devices) { |
| 336 // Bail out if this is called after service shuts down. | |
| 337 if (!service_active_) | |
|
tbarzic
2015/02/24 19:51:07
Won't invalidating weak ptrs in ShutDownInternal p
xiyuan
2015/02/24 20:25:53
You are right. The callback should not be called a
| |
| 338 return; | |
| 339 | |
| 336 allow_cryptohome_backoff_ = false; | 340 allow_cryptohome_backoff_ = false; |
| 337 | 341 |
| 338 UserData* data = user_data_[user_id_]; | 342 UserData* data = user_data_[user_id_]; |
| 339 data->state = USER_DATA_STATE_LOADED; | 343 data->state = USER_DATA_STATE_LOADED; |
| 340 if (success) { | 344 if (success) { |
| 341 data->devices = devices; | 345 data->devices = devices; |
| 342 chromeos::EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList( | 346 chromeos::EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList( |
| 343 user_id, devices, &data->remote_devices_value); | 347 user_id, devices, &data->remote_devices_value); |
| 344 } | 348 } |
| 345 | 349 |
| 346 // If the fetched data belongs to the currently focused user, notify the app | 350 // If the fetched data belongs to the currently focused user, notify the app |
| 347 // that it has to refresh it's user data. | 351 // that it has to refresh it's user data. |
| 348 if (user_id == user_id_) | 352 if (user_id == user_id_) |
| 349 NotifyUserUpdated(); | 353 NotifyUserUpdated(); |
| 350 } | 354 } |
| 351 | 355 |
| 352 const EasyUnlockServiceSignin::UserData* | 356 const EasyUnlockServiceSignin::UserData* |
| 353 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const { | 357 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const { |
| 354 if (user_id_.empty()) | 358 if (user_id_.empty()) |
| 355 return NULL; | 359 return NULL; |
| 356 | 360 |
| 357 std::map<std::string, UserData*>::const_iterator it = | 361 std::map<std::string, UserData*>::const_iterator it = |
| 358 user_data_.find(user_id_); | 362 user_data_.find(user_id_); |
| 359 if (it == user_data_.end()) | 363 if (it == user_data_.end()) |
| 360 return NULL; | 364 return NULL; |
| 361 if (it->second->state != USER_DATA_STATE_LOADED) | 365 if (it->second->state != USER_DATA_STATE_LOADED) |
| 362 return NULL; | 366 return NULL; |
| 363 return it->second; | 367 return it->second; |
| 364 } | 368 } |
| OLD | NEW |