Commit 259e50fc authored by Jan Krcal's avatar Jan Krcal Committed by Chromium LUCI CQ

[Profile creation] Fix a broken DCHECK

A previous CL introduced a DCHECK on identity_manager_observation_ in
ProfilePickerView::OnProfileNameAvailable(). This CL fixes the DCHECK
by an early return in OnExtendedAccountInfoTimeout(). Without this
early return, OnProfileNameAvailable() got called mostly twice,
violating the DCHECK.

Bug: 1126913
Change-Id: Ie1a5457e16cea57a281c83abf005d4b6def9ea47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592788Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Auto-Submit: Jan Krcal <jkrcal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837065}
parent abd675c9
...@@ -537,10 +537,13 @@ void ProfilePickerView::OnRefreshTokenUpdatedForAccount( ...@@ -537,10 +537,13 @@ void ProfilePickerView::OnRefreshTokenUpdatedForAccount(
ShowScreen(new_profile_contents_.get(), GURL(url::kAboutBlankURL), ShowScreen(new_profile_contents_.get(), GURL(url::kAboutBlankURL),
/*show_toolbar=*/true); /*show_toolbar=*/true);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( // Set up a timeout for extended account info (which cancels any existing
FROM_HERE, // timeout closure).
extended_account_info_timeout_closure_.Reset(
base::BindOnce(&ProfilePickerView::OnExtendedAccountInfoTimeout, base::BindOnce(&ProfilePickerView::OnExtendedAccountInfoTimeout,
weak_ptr_factory_.GetWeakPtr(), account_info.email), weak_ptr_factory_.GetWeakPtr(), account_info.email));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, extended_account_info_timeout_closure_.callback(),
extended_account_info_timeout_); extended_account_info_timeout_);
// DiceTurnSyncOnHelper deletes itself once done. // DiceTurnSyncOnHelper deletes itself once done.
...@@ -565,6 +568,8 @@ void ProfilePickerView::OnExtendedAccountInfoUpdated( ...@@ -565,6 +568,8 @@ void ProfilePickerView::OnExtendedAccountInfoUpdated(
name_for_signed_in_profile_ = name_for_signed_in_profile_ =
profiles::GetDefaultNameForNewSignedInProfile(account_info); profiles::GetDefaultNameForNewSignedInProfile(account_info);
OnProfileNameAvailable(); OnProfileNameAvailable();
// Extended info arrived on time, no need for the timeout callback any more.
extended_account_info_timeout_closure_.Cancel();
} }
void ProfilePickerView::SetExtendedAccountInfoTimeoutForTesting( void ProfilePickerView::SetExtendedAccountInfoTimeoutForTesting(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_VIEW_H_ #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_VIEW_H_
#include "base/cancelable_callback.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/profile_picker.h" #include "chrome/browser/ui/profile_picker.h"
...@@ -173,6 +174,7 @@ class ProfilePickerView : public views::DialogDelegateView, ...@@ -173,6 +174,7 @@ class ProfilePickerView : public views::DialogDelegateView,
base::string16 name_for_signed_in_profile_; base::string16 name_for_signed_in_profile_;
base::OnceClosure on_profile_name_available_; base::OnceClosure on_profile_name_available_;
base::TimeDelta extended_account_info_timeout_; base::TimeDelta extended_account_info_timeout_;
base::CancelableOnceClosure extended_account_info_timeout_closure_;
// Not null iff switching to sign-in is in progress. // Not null iff switching to sign-in is in progress.
base::OnceCallback<void(bool)> switch_finished_callback_; base::OnceCallback<void(bool)> switch_finished_callback_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment