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

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

Issue 2468483002: session_manager: Tracks user sessions (Closed)
Patch Set: replace func overload with better names Created 4 years, 1 month 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/user_session_manager.h" 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 delegate_ = delegate; 481 delegate_ = delegate;
482 start_session_type_ = start_session_type; 482 start_session_type_ = start_session_type;
483 483
484 VLOG(1) << "Starting user session."; 484 VLOG(1) << "Starting user session.";
485 PreStartSession(); 485 PreStartSession();
486 CreateUserSession(user_context, has_auth_cookies); 486 CreateUserSession(user_context, has_auth_cookies);
487 487
488 if (!has_active_session) 488 if (!has_active_session)
489 StartCrosSession(); 489 StartCrosSession();
490 490
491 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually
492 // ready to be used (http://crbug.com/361528).
493 NotifyUserLoggedIn();
494
495 if (!user_context.GetDeviceId().empty()) { 491 if (!user_context.GetDeviceId().empty()) {
496 user_manager::known_user::SetDeviceId(user_context.GetAccountId(), 492 user_manager::known_user::SetDeviceId(user_context.GetAccountId(),
497 user_context.GetDeviceId()); 493 user_context.GetDeviceId());
498 } 494 }
499 495
500 PrepareProfile(); 496 PrepareProfile();
501 } 497 }
502 498
503 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { 499 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) {
504 if (delegate_ == delegate) 500 if (delegate_ == delegate)
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 877 }
882 waiting_for_child_account_status_ = false; 878 waiting_for_child_account_status_ = false;
883 } 879 }
884 880
885 void UserSessionManager::CreateUserSession(const UserContext& user_context, 881 void UserSessionManager::CreateUserSession(const UserContext& user_context,
886 bool has_auth_cookies) { 882 bool has_auth_cookies) {
887 user_context_ = user_context; 883 user_context_ = user_context;
888 has_auth_cookies_ = has_auth_cookies; 884 has_auth_cookies_ = has_auth_cookies;
889 InitSessionRestoreStrategy(); 885 InitSessionRestoreStrategy();
890 StoreUserContextDataBeforeProfileIsCreated(); 886 StoreUserContextDataBeforeProfileIsCreated();
887 session_manager::SessionManager::Get()->CreateSession(
888 user_context_.GetAccountId(), user_context_.GetUserIDHash());
891 } 889 }
892 890
893 void UserSessionManager::PreStartSession() { 891 void UserSessionManager::PreStartSession() {
894 // Switch log file as soon as possible. 892 // Switch log file as soon as possible.
895 if (base::SysInfo::IsRunningOnChromeOS()) 893 if (base::SysInfo::IsRunningOnChromeOS())
896 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); 894 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess()));
897 } 895 }
898 896
899 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { 897 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() {
900 // Store obfuscated GAIA ID. 898 // Store obfuscated GAIA ID.
901 if (!user_context_.GetGaiaID().empty()) { 899 if (!user_context_.GetGaiaID().empty()) {
902 user_manager::known_user::UpdateGaiaID(user_context_.GetAccountId(), 900 user_manager::known_user::UpdateGaiaID(user_context_.GetAccountId(),
903 user_context_.GetGaiaID()); 901 user_context_.GetGaiaID());
904 } 902 }
905 } 903 }
906 904
907 void UserSessionManager::StartCrosSession() { 905 void UserSessionManager::StartCrosSession() {
908 BootTimesRecorder* btl = BootTimesRecorder::Get(); 906 BootTimesRecorder* btl = BootTimesRecorder::Get();
909 btl->AddLoginTimeMarker("StartSession-Start", false); 907 btl->AddLoginTimeMarker("StartSession-Start", false);
910 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( 908 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
911 cryptohome::Identification(user_context_.GetAccountId())); 909 cryptohome::Identification(user_context_.GetAccountId()));
912 btl->AddLoginTimeMarker("StartSession-End", false); 910 btl->AddLoginTimeMarker("StartSession-End", false);
913 } 911 }
914 912
915 void UserSessionManager::NotifyUserLoggedIn() {
916 BootTimesRecorder* btl = BootTimesRecorder::Get();
917 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
918 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
919 user_manager->UserLoggedIn(user_context_.GetAccountId(),
920 user_context_.GetUserIDHash(), false);
921 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
922 }
923
924 void UserSessionManager::PrepareProfile() { 913 void UserSessionManager::PrepareProfile() {
925 const bool is_demo_session = 914 const bool is_demo_session =
926 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); 915 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId());
927 916
928 // TODO(nkostylev): Figure out whether demo session is using the right profile 917 // TODO(nkostylev): Figure out whether demo session is using the right profile
929 // path or not. See https://codereview.chromium.org/171423009 918 // path or not. See https://codereview.chromium.org/171423009
930 g_browser_process->profile_manager()->CreateProfileAsync( 919 g_browser_process->profile_manager()->CreateProfileAsync(
931 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), 920 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()),
932 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), 921 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(),
933 user_context_, is_demo_session), 922 user_context_, is_demo_session),
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 ->browser_policy_connector_chromeos() 1869 ->browser_policy_connector_chromeos()
1881 ->IsEnterpriseManaged()) { 1870 ->IsEnterpriseManaged()) {
1882 return false; 1871 return false;
1883 } 1872 }
1884 1873
1885 // Do not show end of life notification if this is a guest session 1874 // Do not show end of life notification if this is a guest session
1886 return !profile->IsGuestSession(); 1875 return !profile->IsGuestSession();
1887 } 1876 }
1888 1877
1889 } // namespace chromeos 1878 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698