Chromium Code Reviews| Index: chrome/browser/cryptauth/chrome_cryptauth_service.cc |
| diff --git a/chrome/browser/cryptauth/chrome_cryptauth_service.cc b/chrome/browser/cryptauth/chrome_cryptauth_service.cc |
| index cb91f83f7a8b8bd94c372ba785ffd595f578a532..147e575f26d16cd843ded1fc2874830cc03b222c 100644 |
| --- a/chrome/browser/cryptauth/chrome_cryptauth_service.cc |
| +++ b/chrome/browser/cryptauth/chrome_cryptauth_service.cc |
| @@ -21,7 +21,6 @@ |
| #include "components/cryptauth/cryptauth_device_manager.h" |
| #include "components/cryptauth/cryptauth_enroller.h" |
| #include "components/cryptauth/cryptauth_enroller_impl.h" |
| -#include "components/cryptauth/cryptauth_enrollment_manager.h" |
| #include "components/cryptauth/cryptauth_enrollment_utils.h" |
| #include "components/cryptauth/cryptauth_gcm_manager_impl.h" |
| #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| @@ -226,8 +225,7 @@ ChromeCryptAuthService::ChromeCryptAuthService( |
| << "waiting before starting CryptAuth managers."; |
| token_service_->AddObserver(this); |
| } else { |
| - enrollment_manager_->Start(); |
| - device_manager_->Start(); |
| + PerformEnrollmentAndDeviceSync(); |
| } |
| } |
| @@ -268,11 +266,32 @@ ChromeCryptAuthService::CreateCryptAuthClientFactory() { |
| return CreateCryptAuthClientFactoryImpl(profile_); |
| } |
| +void ChromeCryptAuthService::OnEnrollmentStarted() {} |
| + |
| +void ChromeCryptAuthService::OnEnrollmentFinished(bool success) { |
| + if (!success) |
| + return; |
|
khorimoto
2017/05/31 17:30:06
What do we expect to happen in this case? Should w
Ryan Hansberry
2017/05/31 17:43:50
Looking at EnrollmentManager, it looks like it giv
|
| + |
| + device_manager_->Start(); |
| + enrollment_manager_->RemoveObserver(this); |
| +} |
| + |
| void ChromeCryptAuthService::OnRefreshTokenAvailable( |
| const std::string& account_id) { |
| if (account_id == GetAccountId()) { |
| token_service_->RemoveObserver(this); |
| - enrollment_manager_->Start(); |
| + PerformEnrollmentAndDeviceSync(); |
| + } |
| +} |
| + |
| +void ChromeCryptAuthService::PerformEnrollmentAndDeviceSync() { |
| + if (enrollment_manager_->IsEnrollmentValid()) { |
| device_manager_->Start(); |
| + } else { |
| + // If enrollment is not valid, wait for the new enrollment attempt to finish |
| + // before starting CryptAuthDeviceManager. See OnEnrollmentFinished(), |
| + enrollment_manager_->AddObserver(this); |
| } |
| + |
| + enrollment_manager_->Start(); |
| } |