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

Unified Diff: ios/chrome/browser/browser_state/browser_state_info_cache.cc

Issue 1411573009: [iOS] Remove BrowserState names in BrowserStateInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/browser_state/browser_state_info_cache.cc
diff --git a/ios/chrome/browser/browser_state/browser_state_info_cache.cc b/ios/chrome/browser/browser_state/browser_state_info_cache.cc
index ceac0874a9e7d03c8250f59e565d7657cf098370..e890dfd43c518a3320c0f696e00254def264763c 100644
--- a/ios/chrome/browser/browser_state/browser_state_info_cache.cc
+++ b/ios/chrome/browser/browser_state/browser_state_info_cache.cc
@@ -16,7 +16,6 @@
namespace {
const char kGAIAIdKey[] = "gaia_id";
const char kIsAuthErrorKey[] = "is_auth_error";
-const char kNameKey[] = "name";
const char kUserNameKey[] = "user_name";
}
@@ -31,9 +30,7 @@ BrowserStateInfoCache::BrowserStateInfoCache(
it.Advance()) {
base::DictionaryValue* info = nullptr;
cache->GetDictionaryWithoutPathExpansion(it.key(), &info);
- base::string16 name;
- info->GetString(kNameKey, &name);
- sorted_keys_.insert(FindPositionForBrowserState(it.key(), name), it.key());
+ sorted_keys_.insert(FindPositionForBrowserState(it.key()), it.key());
}
}
@@ -41,7 +38,6 @@ BrowserStateInfoCache::~BrowserStateInfoCache() {}
void BrowserStateInfoCache::AddBrowserState(
const base::FilePath& browser_state_path,
- const base::string16& name,
const std::string& gaia_id,
const base::string16& user_name) {
std::string key = CacheKeyFromBrowserStatePath(browser_state_path);
@@ -49,12 +45,11 @@ void BrowserStateInfoCache::AddBrowserState(
base::DictionaryValue* cache = update.Get();
scoped_ptr<base::DictionaryValue> info(new base::DictionaryValue);
- info->SetString(kNameKey, name);
info->SetString(kGAIAIdKey, gaia_id);
info->SetString(kUserNameKey, user_name);
cache->SetWithoutPathExpansion(key, info.release());
- sorted_keys_.insert(FindPositionForBrowserState(key, name), key);
+ sorted_keys_.insert(FindPositionForBrowserState(key), key);
FOR_EACH_OBSERVER(BrowserStateInfoCacheObserver, observer_list_,
OnBrowserStateAdded(browser_state_path));
@@ -78,8 +73,6 @@ void BrowserStateInfoCache::RemoveBrowserState(
NOTREACHED();
return;
}
- base::string16 name = GetNameOfBrowserStateAtIndex(browser_state_index);
-
DictionaryPrefUpdate update(prefs_, ios::prefs::kBrowserStateInfoCache);
base::DictionaryValue* cache = update.Get();
std::string key = CacheKeyFromBrowserStatePath(browser_state_path);
@@ -87,7 +80,7 @@ void BrowserStateInfoCache::RemoveBrowserState(
sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key));
FOR_EACH_OBSERVER(BrowserStateInfoCacheObserver, observer_list_,
- OnBrowserStateWasRemoved(browser_state_path, name));
+ OnBrowserStateWasRemoved(browser_state_path));
}
size_t BrowserStateInfoCache::GetNumberOfBrowserStates() const {
@@ -106,13 +99,6 @@ size_t BrowserStateInfoCache::GetIndexOfBrowserStateWithPath(
return std::string::npos;
}
-base::string16 BrowserStateInfoCache::GetNameOfBrowserStateAtIndex(
- size_t index) const {
- base::string16 name;
- GetInfoForBrowserStateAtIndex(index)->GetString(kNameKey, &name);
- return name;
-}
-
base::string16 BrowserStateInfoCache::GetUserNameOfBrowserStateAtIndex(
size_t index) const {
base::string16 user_name;
@@ -216,20 +202,11 @@ std::string BrowserStateInfoCache::CacheKeyFromBrowserStatePath(
std::vector<std::string>::iterator
BrowserStateInfoCache::FindPositionForBrowserState(
bzanotti 2015/10/30 10:49:07 This function is now literally doing the same thin
- const std::string& search_key,
- const base::string16& search_name) {
- base::string16 search_name_l = base::i18n::ToLower(search_name);
+ const std::string& search_key) {
for (size_t i = 0; i < GetNumberOfBrowserStates(); ++i) {
- base::string16 name_l =
- base::i18n::ToLower(GetNameOfBrowserStateAtIndex(i));
- int name_compare = search_name_l.compare(name_l);
- if (name_compare < 0)
+ int key_compare = search_key.compare(sorted_keys_[i]);
+ if (key_compare < 0)
return sorted_keys_.begin() + i;
- if (name_compare == 0) {
- int key_compare = search_key.compare(sorted_keys_[i]);
- if (key_compare < 0)
- return sorted_keys_.begin() + i;
- }
}
return sorted_keys_.end();
}

Powered by Google App Engine
This is Rietveld 408576698