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

Side by Side Diff: chrome/browser/chromeos/login/session/chrome_session_manager.cc

Issue 2577903002: cros: Fix inconsistent SessionController state for tests (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
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/chromeos/login/session/chrome_session_manager.h" 5 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 PrefService* local_state = g_browser_process->local_state(); 78 PrefService* local_state = g_browser_process->local_state();
79 local_state->ClearPref(prefs::kRebootAfterUpdate); 79 local_state->ClearPref(prefs::kRebootAfterUpdate);
80 } 80 }
81 } 81 }
82 82
83 // Restores user sessions for a crash-and-restarted chrome. 83 // Restores user sessions for a crash-and-restarted chrome.
84 void StartRestoreAfterCrashSession(Profile* user_profile, 84 void StartRestoreAfterCrashSession(Profile* user_profile,
85 const std::string& login_user_id) { 85 const std::string& login_user_id) {
86 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 86 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
87 87
88 session_manager::SessionManager::Get()->SetSessionState(
89 session_manager::SessionState::ACTIVE);
90
91 // TODO(xiyuan): Identify tests that do not set this kLoginUser flag but 88 // TODO(xiyuan): Identify tests that do not set this kLoginUser flag but
92 // still rely on "stub user" session. Keeping existing behavior to avoid 89 // still rely on "stub user" session. Keeping existing behavior to avoid
93 // breaking tests. 90 // breaking tests.
94 if (command_line->HasSwitch(chromeos::switches::kLoginUser)) { 91 if (command_line->HasSwitch(chromeos::switches::kLoginUser)) {
95 // This is done in SessionManager::OnProfileCreated during normal login. 92 // This is done in SessionManager::OnProfileCreated during normal login.
96 UserSessionManager* user_session_mgr = UserSessionManager::GetInstance(); 93 UserSessionManager* user_session_mgr = UserSessionManager::GetInstance();
97 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 94 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
98 const user_manager::User* user = user_manager->GetActiveUser(); 95 const user_manager::User* user = user_manager->GetActiveUser();
99 if (!user) { 96 if (!user) {
100 // This is possible if crash occured after profile removal 97 // This is possible if crash occured after profile removal
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // We did not log in (we crashed or are debugging), so we need to 137 // We did not log in (we crashed or are debugging), so we need to
141 // restore Sync. 138 // restore Sync.
142 UserSessionManager::GetInstance()->RestoreAuthenticationSession( 139 UserSessionManager::GetInstance()->RestoreAuthenticationSession(
143 user_profile); 140 user_profile);
144 } 141 }
145 } 142 }
146 143
147 // Starts a user session with stub user. 144 // Starts a user session with stub user.
148 void StartStubLoginSession(Profile* user_profile, 145 void StartStubLoginSession(Profile* user_profile,
149 const std::string& login_user_id) { 146 const std::string& login_user_id) {
150 session_manager::SessionManager::Get()->SetSessionState(
151 session_manager::SessionState::ACTIVE);
152
153 // For dev machines and stub user emulate as if sync has been initialized. 147 // For dev machines and stub user emulate as if sync has been initialized.
154 SigninManagerFactory::GetForProfile(user_profile) 148 SigninManagerFactory::GetForProfile(user_profile)
155 ->SetAuthenticatedAccountInfo(login_user_id, login_user_id); 149 ->SetAuthenticatedAccountInfo(login_user_id, login_user_id);
156 StartRestoreAfterCrashSession(user_profile, login_user_id); 150 StartRestoreAfterCrashSession(user_profile, login_user_id);
157 } 151 }
158 152
159 } // namespace 153 } // namespace
160 154
161 ChromeSessionManager::ChromeSessionManager() {} 155 ChromeSessionManager::ChromeSessionManager() {}
162 ChromeSessionManager::~ChromeSessionManager() {} 156 ChromeSessionManager::~ChromeSessionManager() {}
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 const std::string& user_id_hash, 232 const std::string& user_id_hash,
239 bool browser_restart) { 233 bool browser_restart) {
240 BootTimesRecorder* btl = BootTimesRecorder::Get(); 234 BootTimesRecorder* btl = BootTimesRecorder::Get();
241 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); 235 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
242 session_manager::SessionManager::NotifyUserLoggedIn( 236 session_manager::SessionManager::NotifyUserLoggedIn(
243 user_account_id, user_id_hash, browser_restart); 237 user_account_id, user_id_hash, browser_restart);
244 btl->AddLoginTimeMarker("UserLoggedIn-End", false); 238 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
245 } 239 }
246 240
247 } // namespace chromeos 241 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/crash_restore_browsertest.cc ('k') | components/user_manager/user_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698