Chromium Code Reviews| Index: chrome/browser/policy/user_policy_signin_service.cc |
| diff --git a/chrome/browser/policy/user_policy_signin_service.cc b/chrome/browser/policy/user_policy_signin_service.cc |
| index 32137bed32844b32707c8e458b47f3748daa9974..d386c9713e14b325b074edc60fd0ff5cd1166a29 100644 |
| --- a/chrome/browser/policy/user_policy_signin_service.cc |
| +++ b/chrome/browser/policy/user_policy_signin_service.cc |
| @@ -125,13 +125,20 @@ void UserPolicySigninService::ConfigureUserCloudPolicyManager() { |
| DCHECK(manager_->cloud_policy_service()); |
| } |
| - // Register the CloudPolicyService if needed. |
| - if (!manager_->IsClientRegistered()) |
| + // Register the CloudPolicyService if the cloud policy store is complete. |
| + // TODO(atwilson): If there's a problem loading the stored policy, we could |
| + // be left with no policy, so we should move this code to |
| + // UserCloudPolicyManager and have it initiate a DMToken fetch only once |
| + // the policy load is complete (http://crbug.com/143187). |
| + if (!manager_->IsClientRegistered() && |
| + manager_->cloud_policy_service()->store()->is_initialized()) { |
|
Mattias Nissler (ping if slow)
2012/08/20 15:29:30
Isn't this racy? What if the store just hasn't ini
Andrew T Wilson (Slow)
2012/08/20 18:04:37
It is indeed racy. The solution is to move the reg
Mattias Nissler (ping if slow)
2012/08/21 10:45:16
Fair enough. Also mention a) in the comment?
Andrew T Wilson (Slow)
2012/08/21 23:18:19
Done.
|
| RegisterCloudPolicyService(); |
| + } |
| } |
| } |
| void UserPolicySigninService::RegisterCloudPolicyService() { |
| + DVLOG(1) << "Fetching new DM Token"; |
| // TODO(atwilson): Move the code to mint the devicemanagement token into |
| // TokenService. |
| std::string token = TokenServiceFactory::GetForProfile(profile_)-> |
| @@ -170,6 +177,7 @@ void UserPolicySigninService::OnGetTokenSuccess( |
| const std::string& access_token, |
| const base::Time& expiration_time) { |
| // Pass along the new access token to the CloudPolicyClient. |
| + DVLOG(1) << "Fetched new scoped OAuth token:" << access_token; |
| manager_->RegisterClient(access_token); |
| oauth2_access_token_fetcher_.reset(); |
| } |