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

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

Issue 65643006: Make a copy before enumerating profiles because the list might change underneath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 return last_used_profile_dir.AppendASCII(chrome::kInitialProfile); 391 return last_used_profile_dir.AppendASCII(chrome::kInitialProfile);
392 } 392 }
393 393
394 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles( 394 std::vector<Profile*> ProfileManager::GetLastOpenedProfiles(
395 const base::FilePath& user_data_dir) { 395 const base::FilePath& user_data_dir) {
396 PrefService* local_state = g_browser_process->local_state(); 396 PrefService* local_state = g_browser_process->local_state();
397 DCHECK(local_state); 397 DCHECK(local_state);
398 398
399 std::vector<Profile*> to_return; 399 std::vector<Profile*> to_return;
400 if (local_state->HasPrefPath(prefs::kProfilesLastActive)) { 400 if (local_state->HasPrefPath(prefs::kProfilesLastActive) &&
401 const ListValue* profile_list = 401 local_state->GetList(prefs::kProfilesLastActive)) {
402 local_state->GetList(prefs::kProfilesLastActive); 402 // Make a copy because the list might change in the calls to GetProfile.
403 if (profile_list) { 403 scoped_ptr<base::ListValue> profile_list(
404 ListValue::const_iterator it; 404 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy());
405 std::string profile; 405 base::ListValue::const_iterator it;
406 for (it = profile_list->begin(); it != profile_list->end(); ++it) { 406 std::string profile;
407 if (!(*it)->GetAsString(&profile) || profile.empty()) { 407 for (it = profile_list->begin(); it != profile_list->end(); ++it) {
408 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; 408 if (!(*it)->GetAsString(&profile) || profile.empty()) {
409 continue; 409 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive;
410 } 410 continue;
411 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile)));
412 } 411 }
412 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile)));
413 } 413 }
414 } 414 }
415 return to_return; 415 return to_return;
416 } 416 }
417 417
418 Profile* ProfileManager::GetDefaultProfile( 418 Profile* ProfileManager::GetDefaultProfile(
419 const base::FilePath& user_data_dir) { 419 const base::FilePath& user_data_dir) {
420 #if defined(OS_CHROMEOS) 420 #if defined(OS_CHROMEOS)
421 base::FilePath default_profile_dir(user_data_dir); 421 base::FilePath default_profile_dir(user_data_dir);
422 if (logged_in_) { 422 if (logged_in_) {
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 ProfileManager::ProfileInfo::ProfileInfo( 1250 ProfileManager::ProfileInfo::ProfileInfo(
1251 Profile* profile, 1251 Profile* profile,
1252 bool created) 1252 bool created)
1253 : profile(profile), 1253 : profile(profile),
1254 created(created) { 1254 created(created) {
1255 } 1255 }
1256 1256
1257 ProfileManager::ProfileInfo::~ProfileInfo() { 1257 ProfileManager::ProfileInfo::~ProfileInfo() {
1258 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1258 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1259 } 1259 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698