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

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

Issue 10521018: Merge 139419 - fix crash when double-deleting a profile (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/options2/browser_options.js » ('j') | 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_info_cache.h" 5 #include "chrome/browser/profiles/profile_info_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 void ProfileInfoCache::AddObserver(ProfileInfoCacheObserver* obs) { 219 void ProfileInfoCache::AddObserver(ProfileInfoCacheObserver* obs) {
220 observer_list_.AddObserver(obs); 220 observer_list_.AddObserver(obs);
221 } 221 }
222 222
223 void ProfileInfoCache::RemoveObserver(ProfileInfoCacheObserver* obs) { 223 void ProfileInfoCache::RemoveObserver(ProfileInfoCacheObserver* obs) {
224 observer_list_.RemoveObserver(obs); 224 observer_list_.RemoveObserver(obs);
225 } 225 }
226 226
227 void ProfileInfoCache::DeleteProfileFromCache(const FilePath& profile_path) { 227 void ProfileInfoCache::DeleteProfileFromCache(const FilePath& profile_path) {
228 string16 name = GetNameOfProfileAtIndex( 228 size_t profile_index = GetIndexOfProfileWithPath(profile_path);
229 GetIndexOfProfileWithPath(profile_path)); 229 if (profile_index == std::string::npos) {
230 NOTREACHED();
231 return;
232 }
233 string16 name = GetNameOfProfileAtIndex(profile_index);
230 234
231 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, 235 FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
232 observer_list_, 236 observer_list_,
233 OnProfileWillBeRemoved(profile_path)); 237 OnProfileWillBeRemoved(profile_path));
234 238
235 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); 239 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
236 DictionaryValue* cache = update.Get(); 240 DictionaryValue* cache = update.Get();
237 std::string key = CacheKeyFromProfilePath(profile_path); 241 std::string key = CacheKeyFromProfilePath(profile_path);
238 cache->Remove(key, NULL); 242 cache->Remove(key, NULL);
239 sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key)); 243 sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key));
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 info->GetString(kNameKey, &name); 787 info->GetString(kNameKey, &name);
784 names.push_back(name); 788 names.push_back(name);
785 } 789 }
786 return names; 790 return names;
787 } 791 }
788 792
789 // static 793 // static
790 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { 794 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) {
791 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); 795 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache);
792 } 796 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options2/browser_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698