Skip to content

Commit

Permalink
Revert 286187 "user_manager component: Add UserManagerBase class."
Browse files Browse the repository at this point in the history
Breaks PreferencesTest.MultiProfiles:
http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/builds/2299
[311:311:0729/081921:FATAL:user_manager.cc(69)] Check failed: g_user_manager.

> user_manager component: Add UserManagerBase class.
> 
> UserManagerBase contains common methods extracted from UserManagerImpl.
> UserManagerImpl was renamed to ChromeUserManager and inherits UserManagerBase.
> 
> Misc refactoring:
> * Move HasBrowserStarted() to SessionManager
> * Add generic getter SessionManager::Get() which makes it possible for concrete clients don't depend on instance ownership like g_browser_process->platform_part()->SessionManager().
> * Moved CRLSet code out of UserManager::UserLoggedIn(), to UserSessionManager.
> 
> BUG=387614
> 
> Review URL: https://codereview.chromium.org/417623002

TBR=nkostylev@chromium.org

Review URL: https://codereview.chromium.org/424193002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286263 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
skobes@chromium.org committed Jul 29, 2014
1 parent dd1c2a7 commit d79b6fe
Show file tree
Hide file tree
Showing 27 changed files with 2,148 additions and 2,570 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/login/users/user_manager_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_switches.h"
Expand Down
48 changes: 22 additions & 26 deletions chrome/browser/chromeos/login/session/user_session_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/google/google_brand_chromeos.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/net/crl_set_fetcher.h"
#include "chrome/browser/net/nss_context.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
Expand Down Expand Up @@ -286,6 +284,12 @@ void UserSessionManager::InitRlz(Profile* profile) {
#endif
}

bool UserSessionManager::HasBrowserRestarted() const {
CommandLine* command_line = CommandLine::ForCurrentProcess();
return base::SysInfo::IsRunningOnChromeOS() &&
command_line->HasSwitch(switches::kLoginUser);
}

OAuth2LoginManager::SessionRestoreStrategy
UserSessionManager::GetSigninSessionRestoreStrategy() {
return session_restore_strategy_;
Expand Down Expand Up @@ -670,10 +674,11 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) {
CryptohomeClient* client = DBusThreadManager::Get()->GetCryptohomeClient();
btl->AddLoginTimeMarker("TPMOwn-Start", false);
if (cryptohome_util::TpmIsEnabled() && !cryptohome_util::TpmIsBeingOwned()) {
if (cryptohome_util::TpmIsOwned())
if (cryptohome_util::TpmIsOwned()) {
client->CallTpmClearStoredPasswordAndBlock();
else
} else {
client->TpmCanAttemptOwnership(EmptyVoidDBusMethodCallback());
}
}
btl->AddLoginTimeMarker("TPMOwn-End", false);

Expand All @@ -697,16 +702,15 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) {
content::NotificationService::AllSources(),
content::Details<Profile>(profile));

// Initialize various services only for primary user.
InitializeCertsForPrimaryUser(profile);

// Initialize RLZ only for primary user.
const user_manager::User* user =
ProfileHelper::Get()->GetUserByProfile(profile);
if (user_manager->GetPrimaryUser() == user) {
if (user_manager->GetPrimaryUser() == user)
InitRlz(profile);
InitializeCerts(profile);
InitializeCRLSetFetcher(user);
}

// TODO(nkostylev): This pointer should probably never be NULL, but it looks
// TODO(altimofeev): This pointer should probably never be NULL, but it looks
// like LoginUtilsImpl::OnProfileCreated() may be getting called before
// UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is
// killed during shutdown in tests -- see http://crosbug.com/18269. Replace
Expand Down Expand Up @@ -808,29 +812,21 @@ void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) {
#endif
}

void UserSessionManager::InitializeCerts(Profile* profile) {
void UserSessionManager::InitializeCertsForPrimaryUser(Profile* profile) {
// Now that the user profile has been initialized
// |GetNSSCertDatabaseForProfile| is safe to be used.
if (CertLoader::IsInitialized() && base::SysInfo::IsRunningOnChromeOS()) {
UserManager* user_manager = UserManager::Get();
const user_manager::User* primary_user = user_manager->GetPrimaryUser();
if (user_manager->IsUserLoggedIn() &&
primary_user &&
profile == ProfileHelper::Get()->GetProfileByUser(primary_user) &&
CertLoader::IsInitialized() &&
base::SysInfo::IsRunningOnChromeOS()) {
GetNSSCertDatabaseForProfile(profile,
base::Bind(&OnGetNSSCertDatabaseForUser));
}
}

void UserSessionManager::InitializeCRLSetFetcher(
const user_manager::User* user) {
const std::string username_hash = user->username_hash();
if (!username_hash.empty()) {
base::FilePath path;
path = ProfileHelper::GetProfilePathByUserIdHash(username_hash);
component_updater::ComponentUpdateService* cus =
g_browser_process->component_updater();
CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher();
if (crl_set && cus)
crl_set->StartInitialLoad(cus, path);
}
}

void UserSessionManager::OnRestoreActiveSessions(
const SessionManagerClient::ActiveSessionsMap& sessions,
bool success) {
Expand Down
13 changes: 7 additions & 6 deletions chrome/browser/chromeos/login/session/user_session_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class UserSessionManager
// Initialize RLZ.
void InitRlz(Profile* profile);

// Returns true when the browser has crashed and restarted during the current
// user's session.
bool HasBrowserRestarted() const;

// TODO(nkostylev): Drop these methods once LoginUtilsImpl::AttemptRestart()
// is migrated.
OAuth2LoginManager::SessionRestoreStrategy GetSigninSessionRestoreStrategy();
Expand Down Expand Up @@ -194,12 +198,9 @@ class UserSessionManager
// Initializes RLZ. If |disabled| is true, RLZ pings are disabled.
void InitRlzImpl(Profile* profile, bool disabled);

// Get the NSS cert database for the user represented with |profile|
// and start certificate loader with it.
void InitializeCerts(Profile* profile);

// Starts loading CRL set.
void InitializeCRLSetFetcher(const user_manager::User* user);
// Get the NSS cert database for the primary user and start certificate
// loader with it.
void InitializeCertsForPrimaryUser(Profile* profile);

// Callback to process RetrieveActiveSessions() request results.
void OnRestoreActiveSessions(
Expand Down
Loading

0 comments on commit d79b6fe

Please sign in to comment.