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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 2061593002: Fix crash when switching to a profile that cannot be opened (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug-614753-fix
Patch Set: Respond to nits, fix tests Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 if (success && !go_off_the_record) 1096 if (success && !go_off_the_record)
1097 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED); 1097 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED);
1098 1098
1099 // Perform initialization. 1099 // Perform initialization.
1100 if (success) { 1100 if (success) {
1101 DoFinalInit(profile, go_off_the_record); 1101 DoFinalInit(profile, go_off_the_record);
1102 if (go_off_the_record) 1102 if (go_off_the_record)
1103 profile = profile->GetOffTheRecordProfile(); 1103 profile = profile->GetOffTheRecordProfile();
1104 info->created = true; 1104 info->created = true;
1105 } else { 1105 } else {
1106 profile = NULL; 1106 profile = nullptr;
1107 failed_profiles_.push_back(std::move(iter->second->profile));
1107 profiles_info_.erase(iter); 1108 profiles_info_.erase(iter);
1108 // TODO(yiyaoliu): This is temporary, remove it after it's not used. 1109 // TODO(yiyaoliu): This is temporary, remove it after it's not used.
1109 UMA_HISTOGRAM_COUNTS_100("UMA.ProfilesCount.AfterErase", 1110 UMA_HISTOGRAM_COUNTS_100("UMA.ProfilesCount.AfterErase",
1110 profiles_info_.size()); 1111 profiles_info_.size());
1111 } 1112 }
1112 1113
1113 if (profile) { 1114 if (profile) {
1114 // If this was the guest or system profile, finish setting its special 1115 // If this was the guest or system profile, finish setting its special
1115 // status. 1116 // status.
1116 if (profile->IsGuestSession() || profile->IsSystemProfile()) 1117 if (profile->IsGuestSession() || profile->IsSystemProfile())
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 } 1510 }
1510 1511
1511 ProfileManager::ProfileInfo::ProfileInfo( 1512 ProfileManager::ProfileInfo::ProfileInfo(
1512 Profile* profile, 1513 Profile* profile,
1513 bool created) 1514 bool created)
1514 : profile(profile), 1515 : profile(profile),
1515 created(created) { 1516 created(created) {
1516 } 1517 }
1517 1518
1518 ProfileManager::ProfileInfo::~ProfileInfo() { 1519 ProfileManager::ProfileInfo::~ProfileInfo() {
1519 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1520 if (profile)
1521 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1520 } 1522 }
1521 1523
1522 #if !defined(OS_ANDROID) 1524 #if !defined(OS_ANDROID)
1523 void ProfileManager::UpdateLastUser(Profile* last_active) { 1525 void ProfileManager::UpdateLastUser(Profile* last_active) {
1524 PrefService* local_state = g_browser_process->local_state(); 1526 PrefService* local_state = g_browser_process->local_state();
1525 DCHECK(local_state); 1527 DCHECK(local_state);
1526 // Only keep track of profiles that we are managing; tests may create others. 1528 // Only keep track of profiles that we are managing; tests may create others.
1527 // Also never consider the SystemProfile as "active". 1529 // Also never consider the SystemProfile as "active".
1528 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() && 1530 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() &&
1529 !last_active->IsSystemProfile()) { 1531 !last_active->IsSystemProfile()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1634
1633 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1635 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1634 if (!original_callback.is_null()) 1636 if (!original_callback.is_null())
1635 original_callback.Run(loaded_profile, status); 1637 original_callback.Run(loaded_profile, status);
1636 } 1638 }
1637 #endif // !defined(OS_ANDROID) 1639 #endif // !defined(OS_ANDROID)
1638 1640
1639 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1641 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1640 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1642 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1641 } 1643 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698