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

Unified Diff: chrome/browser/ui/ash/session_controller_client.cc

Issue 2863993002: cros: Defer primary user meta update until active (Closed)
Patch Set: fix nits Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/ash/session_controller_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/session_controller_client.cc
diff --git a/chrome/browser/ui/ash/session_controller_client.cc b/chrome/browser/ui/ash/session_controller_client.cc
index 905fb906afdde41c96d460e67ec2af1c98604a01..6d15a762aa9f7a48b0bfe57ccdcb3f0207930ba6 100644
--- a/chrome/browser/ui/ash/session_controller_client.cc
+++ b/chrome/browser/ui/ash/session_controller_client.cc
@@ -38,6 +38,7 @@
using session_manager::Session;
using session_manager::SessionManager;
+using session_manager::SessionState;
using user_manager::UserManager;
using user_manager::User;
using user_manager::UserList;
@@ -188,12 +189,18 @@ void SessionControllerClient::CycleActiveUser(
void SessionControllerClient::ActiveUserChanged(const User* active_user) {
SendSessionInfoIfChanged();
- // UserAddedToSession is not called for the primary user session so send its
- // meta data here once.
+ // UserAddedToSession is not called for the primary user session so its meta
+ // data here needs to be sent to ash before setting user session order.
+ // However, ActiveUserChanged happens at different timing for primary user
+ // and secondary users. For primary user, it happens before user profile load.
+ // For secondary users, it happens after user profile load. This caused
+ // confusing down the path. Bail out here to defer the primary user session
+ // metadata sent until it becomes active so that ash side could expect a
+ // consistent state.
+ // TODO(xiyuan): Get rid of this after http://crbug.com/657149 refactoring.
if (!primary_user_session_sent_ &&
UserManager::Get()->GetPrimaryUser() == active_user) {
- primary_user_session_sent_ = true;
- SendUserSession(*active_user);
+ return;
}
SendUserSessionOrder();
@@ -315,6 +322,17 @@ void SessionControllerClient::FlushForTesting() {
}
void SessionControllerClient::OnSessionStateChanged() {
+ // Sent the primary user metadata and user session order that are deferred
+ // from ActiveUserChanged before update session state.
+ if (!primary_user_session_sent_ &&
+ SessionManager::Get()->session_state() == SessionState::ACTIVE) {
+ DCHECK_EQ(UserManager::Get()->GetPrimaryUser(),
+ UserManager::Get()->GetActiveUser());
+ primary_user_session_sent_ = true;
+ SendUserSession(*UserManager::Get()->GetPrimaryUser());
+ SendUserSessionOrder();
+ }
+
SendSessionInfoIfChanged();
}
« no previous file with comments | « no previous file | chrome/browser/ui/ash/session_controller_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698