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

Unified Diff: components/session_manager/core/session_manager.cc

Issue 2868043002: Add CHECK on session start for profile construction (Closed)
Patch Set: CHECK -> LOG_IF(FATAL) 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 | « components/session_manager/core/session_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/session_manager/core/session_manager.cc
diff --git a/components/session_manager/core/session_manager.cc b/components/session_manager/core/session_manager.cc
index d2387452bfe5be57b518b59df1d2d826ba3c6ad0..def0fa659983b8bf62656255787e1f6b3afa773c 100644
--- a/components/session_manager/core/session_manager.cc
+++ b/components/session_manager/core/session_manager.cc
@@ -62,6 +62,14 @@ void SessionManager::SessionStarted() {
session_started_ = true;
}
+bool SessionManager::HasSessionForAccountId(
+ const AccountId& user_account_id) const {
+ return std::find_if(sessions_.begin(), sessions_.end(),
+ [user_account_id](const Session& session) {
+ return session.user_account_id == user_account_id;
+ }) != sessions_.end();
+}
+
bool SessionManager::IsInSecondaryLoginScreen() const {
return session_state_ == SessionState::LOGIN_SECONDARY;
}
@@ -99,11 +107,7 @@ void SessionManager::SetInstance(SessionManager* session_manager) {
void SessionManager::CreateSessionInternal(const AccountId& user_account_id,
const std::string& user_id_hash,
bool browser_restart) {
- DCHECK(std::find_if(sessions_.begin(), sessions_.end(),
- [user_account_id](const Session& session) {
- return session.user_account_id == user_account_id;
- }) == sessions_.end());
-
+ DCHECK(!HasSessionForAccountId(user_account_id));
sessions_.push_back({next_id_++, user_account_id});
NotifyUserLoggedIn(user_account_id, user_id_hash, browser_restart);
}
« no previous file with comments | « components/session_manager/core/session_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698