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

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: 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 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (success && !go_off_the_record) 1097 if (success && !go_off_the_record)
1098 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED); 1098 RunCallbacks(callbacks, profile, Profile::CREATE_STATUS_CREATED);
1099 1099
1100 // Perform initialization. 1100 // Perform initialization.
1101 if (success) { 1101 if (success) {
1102 DoFinalInit(profile, go_off_the_record); 1102 DoFinalInit(profile, go_off_the_record);
1103 if (go_off_the_record) 1103 if (go_off_the_record)
1104 profile = profile->GetOffTheRecordProfile(); 1104 profile = profile->GetOffTheRecordProfile();
1105 info->created = true; 1105 info->created = true;
1106 } else { 1106 } else {
1107 profile = NULL; 1107 profile = nullptr;
1108 failed_profiles_.emplace_back(std::move(iter->second->profile));
Peter Kasting 2016/06/13 04:43:20 Nit: There's no real reason here to use emplace_ba
WC Leung 2016/06/13 08:06:45 Acknowledged.
WC Leung 2016/06/15 13:08:39 Done.
1108 profiles_info_.erase(iter); 1109 profiles_info_.erase(iter);
1109 // TODO(yiyaoliu): This is temporary, remove it after it's not used. 1110 // TODO(yiyaoliu): This is temporary, remove it after it's not used.
1110 UMA_HISTOGRAM_COUNTS_100("UMA.ProfilesCount.AfterErase", 1111 UMA_HISTOGRAM_COUNTS_100("UMA.ProfilesCount.AfterErase",
1111 profiles_info_.size()); 1112 profiles_info_.size());
1112 } 1113 }
1113 1114
1114 if (profile) { 1115 if (profile) {
1115 // If this was the guest or system profile, finish setting its special 1116 // If this was the guest or system profile, finish setting its special
1116 // status. 1117 // status.
1117 if (profile->IsGuestSession() || profile->IsSystemProfile()) 1118 if (profile->IsGuestSession() || profile->IsSystemProfile())
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 } 1517 }
1517 1518
1518 ProfileManager::ProfileInfo::ProfileInfo( 1519 ProfileManager::ProfileInfo::ProfileInfo(
1519 Profile* profile, 1520 Profile* profile,
1520 bool created) 1521 bool created)
1521 : profile(profile), 1522 : profile(profile),
1522 created(created) { 1523 created(created) {
1523 } 1524 }
1524 1525
1525 ProfileManager::ProfileInfo::~ProfileInfo() { 1526 ProfileManager::ProfileInfo::~ProfileInfo() {
1526 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1527 if (profile)
1528 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1527 } 1529 }
1528 1530
1529 #if !defined(OS_ANDROID) 1531 #if !defined(OS_ANDROID)
1530 void ProfileManager::UpdateLastUser(Profile* last_active) { 1532 void ProfileManager::UpdateLastUser(Profile* last_active) {
1531 PrefService* local_state = g_browser_process->local_state(); 1533 PrefService* local_state = g_browser_process->local_state();
1532 DCHECK(local_state); 1534 DCHECK(local_state);
1533 // Only keep track of profiles that we are managing; tests may create others. 1535 // Only keep track of profiles that we are managing; tests may create others.
1534 // Also never consider the SystemProfile as "active". 1536 // Also never consider the SystemProfile as "active".
1535 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() && 1537 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end() &&
1536 !last_active->IsSystemProfile()) { 1538 !last_active->IsSystemProfile()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1641
1640 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1642 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1641 if (!original_callback.is_null()) 1643 if (!original_callback.is_null())
1642 original_callback.Run(loaded_profile, status); 1644 original_callback.Run(loaded_profile, status);
1643 } 1645 }
1644 #endif // !defined(OS_ANDROID) 1646 #endif // !defined(OS_ANDROID)
1645 1647
1646 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1648 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1647 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1649 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1648 } 1650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698