| Index: chrome/browser/background/background_mode_manager.cc
|
| diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
|
| index 65a593b1bc2428f4678b60980595ff26661af50e..c10e7aa03370ae478c110f9f758650794b6d0184 100644
|
| --- a/chrome/browser/background/background_mode_manager.cc
|
| +++ b/chrome/browser/background/background_mode_manager.cc
|
| @@ -236,10 +236,10 @@ void BackgroundModeManager::RegisterProfile(Profile* profile) {
|
| background_mode_data_[profile] = bmd;
|
|
|
| // Initially set the name for this background mode data.
|
| - size_t index = profile_cache_->GetIndexOfProfileWithPath(profile->GetPath());
|
| string16 name = l10n_util::GetStringUTF16(IDS_PROFILES_DEFAULT_NAME);
|
| - if (index != std::string::npos)
|
| - name = profile_cache_->GetNameOfProfileAtIndex(index);
|
| + ProfileInfoEntry entry;
|
| + if (profile_cache_->GetInfoForProfile(profile->GetPath(), &entry))
|
| + name = entry.GetDisplayName();
|
| bmd->SetName(name);
|
|
|
| // Listen for when extensions are loaded or add the background permission so
|
| @@ -366,11 +366,11 @@ void BackgroundModeManager::OnApplicationListChanged(Profile* profile) {
|
|
|
| // Update the profile cache with the fact whether background apps are running
|
| // for this profile.
|
| - size_t profile_index = profile_cache_->GetIndexOfProfileWithPath(
|
| - profile->GetPath());
|
| - if (profile_index != std::string::npos) {
|
| - profile_cache_->SetBackgroundStatusOfProfileAtIndex(
|
| - profile_index, GetBackgroundAppCountForProfile(profile) != 0);
|
| + ProfileInfoEntry entry;
|
| + if (profile_cache_->GetInfoForProfile(profile->GetPath(), &entry)) {
|
| + entry.set_is_running_background_apps(
|
| + GetBackgroundAppCountForProfile(profile) != 0);
|
| + profile_cache_->SetInfoForProfile(entry);
|
| }
|
|
|
| if (!ShouldBeInBackgroundMode()) {
|
| @@ -400,8 +400,12 @@ void BackgroundModeManager::OnApplicationListChanged(Profile* profile) {
|
| void BackgroundModeManager::OnProfileAdded(const base::FilePath& profile_path) {
|
| ProfileInfoCache& cache =
|
| g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - string16 profile_name = cache.GetNameOfProfileAtIndex(
|
| - cache.GetIndexOfProfileWithPath(profile_path));
|
| +
|
| + ProfileInfoEntry entry;
|
| + if (!cache.GetInfoForProfile(profile_path, &entry))
|
| + return;
|
| +
|
| + string16 profile_name = entry.GetDisplayName();
|
| // At this point, the profile should be registered with the background mode
|
| // manager, but when it's actually added to the cache is when its name is
|
| // set so we need up to update that with the background_mode_data.
|
| @@ -421,8 +425,12 @@ void BackgroundModeManager::OnProfileWillBeRemoved(
|
| const base::FilePath& profile_path) {
|
| ProfileInfoCache& cache =
|
| g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - string16 profile_name = cache.GetNameOfProfileAtIndex(
|
| - cache.GetIndexOfProfileWithPath(profile_path));
|
| +
|
| + ProfileInfoEntry entry;
|
| + if (!cache.GetInfoForProfile(profile_path, &entry))
|
| + return;
|
| +
|
| + string16 profile_name = entry.GetDisplayName();
|
| // Remove the profile from our map of profiles.
|
| BackgroundModeInfoMap::iterator it =
|
| GetBackgroundModeIterator(profile_name);
|
| @@ -438,8 +446,11 @@ void BackgroundModeManager::OnProfileNameChanged(
|
| const string16& old_profile_name) {
|
| ProfileInfoCache& cache =
|
| g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - string16 new_profile_name = cache.GetNameOfProfileAtIndex(
|
| - cache.GetIndexOfProfileWithPath(profile_path));
|
| + ProfileInfoEntry entry;
|
| + if (!cache.GetInfoForProfile(profile_path, &entry))
|
| + return;
|
| +
|
| + string16 new_profile_name = entry.GetDisplayName();
|
| BackgroundModeInfoMap::const_iterator it =
|
| GetBackgroundModeIterator(old_profile_name);
|
| // We check that the returned iterator is valid due to unittests, but really
|
|
|