Commit fd868af5 authored by marja@chromium.org's avatar marja@chromium.org

ProfileManager: Remove CHECKs.

The cause for the "last profile appears multiple times in the last active profile list"
seems to be that several profiles have the same string representation (GetPath().BaseName()).

crbug.com/120112 addresses that problem and this CL works around it.

BUG=114766
TEST=NONE

Review URL: http://codereview.chromium.org/9853010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129426 0039d316-1c4b-4281-b951-d872f2087c98
parent c94c954a
......@@ -527,8 +527,6 @@ void ProfileManager::Observe(
Profile* profile = browser->profile();
DCHECK(profile);
if (!profile->IsOffTheRecord() && ++browser_counts_[profile] == 1) {
CHECK(std::find(active_profiles_.begin(), active_profiles_.end(),
profile) == active_profiles_.end());
active_profiles_.push_back(profile);
update_active_profiles = true;
}
......@@ -540,14 +538,8 @@ void ProfileManager::Observe(
Profile* profile = browser->profile();
DCHECK(profile);
if (!profile->IsOffTheRecord() && --browser_counts_[profile] == 0) {
CHECK(std::find(active_profiles_.begin(), active_profiles_.end(),
profile) != active_profiles_.end());
active_profiles_.erase(
std::remove(active_profiles_.begin(), active_profiles_.end(),
profile),
active_profiles_.end());
CHECK(std::find(active_profiles_.begin(), active_profiles_.end(),
profile) == active_profiles_.end());
active_profiles_.erase(std::find(active_profiles_.begin(),
active_profiles_.end(), profile));
update_active_profiles = true;
}
break;
......@@ -565,27 +557,18 @@ void ProfileManager::Observe(
profile_list->Clear();
// Check that the same profile doesn't occur twice in last_opened_profiles.
{
std::set<Profile*> active_profiles_set;
for (std::vector<Profile*>::const_iterator it = active_profiles_.begin();
it != active_profiles_.end(); ++it) {
CHECK(active_profiles_set.find(*it) ==
active_profiles_set.end());
active_profiles_set.insert(*it);
}
}
// Used for checking that the string representations of the profiles differ.
// crbug.com/120112 -> several non-incognito profiles might have the same
// GetPath().BaseName(). In that case, we cannot restore both
// profiles. Include each base name only once in the last active profile
// list.
std::set<std::string> profile_paths;
std::vector<Profile*>::const_iterator it;
for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) {
std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII();
CHECK(profile_paths.find(profile_path) ==
profile_paths.end());
profile_paths.insert(profile_path);
profile_list->Append(
new StringValue((*it)->GetPath().BaseName().MaybeAsASCII()));
if (profile_paths.find(profile_path) == profile_paths.end()) {
profile_paths.insert(profile_path);
profile_list->Append(new StringValue(profile_path));
}
}
}
}
......
......@@ -318,6 +318,8 @@ class ProfileManager : public base::NonThreadSafe,
// For keeping track of the last active profiles.
std::map<Profile*, int> browser_counts_;
// On startup we launch the active profiles in the order they became active
// during the last run. This is why they are kept in a list, not in a set.
std::vector<Profile*> active_profiles_;
bool shutdown_started_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment