Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 std::unique_ptr<base::ListValue> profile_list( | 615 std::unique_ptr<base::ListValue> profile_list( |
| 616 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); | 616 local_state->GetList(prefs::kProfilesLastActive)->DeepCopy()); |
| 617 base::ListValue::const_iterator it; | 617 base::ListValue::const_iterator it; |
| 618 std::string profile; | 618 std::string profile; |
| 619 for (it = profile_list->begin(); it != profile_list->end(); ++it) { | 619 for (it = profile_list->begin(); it != profile_list->end(); ++it) { |
| 620 if (!(*it)->GetAsString(&profile) || profile.empty() || | 620 if (!(*it)->GetAsString(&profile) || profile.empty() || |
| 621 profile == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { | 621 profile == base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe()) { |
| 622 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; | 622 LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive; |
| 623 continue; | 623 continue; |
| 624 } | 624 } |
| 625 to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile))); | 625 Profile* profile = GetProfile(user_data_dir.AppendASCII(profile)); |
| 626 if (profile) | |
| 627 to_return.push_back(profile); | |
| 626 } | 628 } |
| 627 } | 629 } |
| 628 return to_return; | 630 return to_return; |
| 629 } | 631 } |
| 630 | 632 |
| 631 std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { | 633 std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { |
| 632 std::vector<Profile*> profiles; | 634 std::vector<Profile*> profiles; |
| 633 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); | 635 for (ProfilesInfoMap::const_iterator iter = profiles_info_.begin(); |
| 634 iter != profiles_info_.end(); ++iter) { | 636 iter != profiles_info_.end(); ++iter) { |
| 635 if (iter->second->created) | 637 if (iter->second->created) |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1332 "Startup", "ProfileManager::CreateAndInitializeProfile"); | 1334 "Startup", "ProfileManager::CreateAndInitializeProfile"); |
| 1333 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.CreateAndInitializeProfile"); | 1335 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.CreateAndInitializeProfile"); |
| 1334 | 1336 |
| 1335 // CHECK that we are not trying to load the same profile twice, to prevent | 1337 // CHECK that we are not trying to load the same profile twice, to prevent |
| 1336 // profile corruption. Note that this check also covers the case when we have | 1338 // profile corruption. Note that this check also covers the case when we have |
| 1337 // already started loading the profile but it is not fully initialized yet, | 1339 // already started loading the profile but it is not fully initialized yet, |
| 1338 // which would make Bad Things happen if we returned it. | 1340 // which would make Bad Things happen if we returned it. |
| 1339 CHECK(!GetProfileByPathInternal(profile_dir)); | 1341 CHECK(!GetProfileByPathInternal(profile_dir)); |
| 1340 Profile* profile = CreateProfileHelper(profile_dir); | 1342 Profile* profile = CreateProfileHelper(profile_dir); |
| 1341 DCHECK(profile); | 1343 DCHECK(profile); |
| 1342 if (profile) { | 1344 if (profile) { |
|
Peter Kasting
2016/05/31 11:41:09
This code violates the prohibition on handling DCH
WC Leung
2016/05/31 17:41:07
Done.
| |
| 1343 bool result = AddProfile(profile); | 1345 bool result = AddProfile(profile); |
| 1344 DCHECK(result); | 1346 DCHECK(result); |
| 1345 } | 1347 } |
| 1346 return profile; | 1348 return profile; |
| 1347 } | 1349 } |
| 1348 | 1350 |
| 1349 #if !defined(OS_ANDROID) | 1351 #if !defined(OS_ANDROID) |
| 1350 void ProfileManager::FinishDeletingProfile( | 1352 void ProfileManager::FinishDeletingProfile( |
| 1351 const base::FilePath& profile_dir, | 1353 const base::FilePath& profile_dir, |
| 1352 const base::FilePath& new_active_profile_dir) { | 1354 const base::FilePath& new_active_profile_dir) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1640 | 1642 |
| 1641 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1643 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
| 1642 if (!original_callback.is_null()) | 1644 if (!original_callback.is_null()) |
| 1643 original_callback.Run(loaded_profile, status); | 1645 original_callback.Run(loaded_profile, status); |
| 1644 } | 1646 } |
| 1645 #endif // !defined(OS_ANDROID) | 1647 #endif // !defined(OS_ANDROID) |
| 1646 | 1648 |
| 1647 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1649 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1648 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1650 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1649 } | 1651 } |
| OLD | NEW |