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

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

Issue 1242793005: Refactor most c/b/profiles calls to ProfileInfoCache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows unit test and ChromeOS build Created 5 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/i18n/case_conversion.h"
5 #include "chrome/browser/profiles/profile_attributes_entry.h" 6 #include "chrome/browser/profiles/profile_attributes_entry.h"
6 #include "chrome/browser/profiles/profile_info_cache.h" 7 #include "chrome/browser/profiles/profile_info_cache.h"
7 8
8 ProfileAttributesEntry::ProfileAttributesEntry() 9 ProfileAttributesEntry::ProfileAttributesEntry()
9 : profile_info_cache_(nullptr), 10 : profile_info_cache_(nullptr),
10 profile_path_(base::FilePath()) {} 11 profile_path_(base::FilePath()) {}
11 12
12 void ProfileAttributesEntry::Initialize( 13 void ProfileAttributesEntry::Initialize(
13 ProfileInfoCache* cache, const base::FilePath& path) { 14 ProfileInfoCache* cache, const base::FilePath& path) {
14 DCHECK(!profile_info_cache_); 15 DCHECK(!profile_info_cache_);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 132 }
132 133
133 void ProfileAttributesEntry::SetName(const base::string16& name) { 134 void ProfileAttributesEntry::SetName(const base::string16& name) {
134 profile_info_cache_->SetNameOfProfileAtIndex(profile_index(), name); 135 profile_info_cache_->SetNameOfProfileAtIndex(profile_index(), name);
135 } 136 }
136 137
137 void ProfileAttributesEntry::SetShortcutName(const base::string16& name) { 138 void ProfileAttributesEntry::SetShortcutName(const base::string16& name) {
138 profile_info_cache_->SetShortcutNameOfProfileAtIndex(profile_index(), name); 139 profile_info_cache_->SetShortcutNameOfProfileAtIndex(profile_index(), name);
139 } 140 }
140 141
142 void ProfileAttributesEntry::SetActiveTime() {
143 profile_info_cache_->SetProfileActiveTimeAtIndex(profile_index());
144 }
145
141 void ProfileAttributesEntry::SetIsOmitted(bool is_omitted) { 146 void ProfileAttributesEntry::SetIsOmitted(bool is_omitted) {
142 profile_info_cache_->SetIsOmittedProfileAtIndex(profile_index(), is_omitted); 147 profile_info_cache_->SetIsOmittedProfileAtIndex(profile_index(), is_omitted);
143 } 148 }
144 149
145 void ProfileAttributesEntry::SetSupervisedUserId(const std::string& id) { 150 void ProfileAttributesEntry::SetSupervisedUserId(const std::string& id) {
146 profile_info_cache_->SetSupervisedUserIdOfProfileAtIndex(profile_index(), id); 151 profile_info_cache_->SetSupervisedUserIdOfProfileAtIndex(profile_index(), id);
147 } 152 }
148 153
149 void ProfileAttributesEntry::SetLocalAuthCredentials(const std::string& auth) { 154 void ProfileAttributesEntry::SetLocalAuthCredentials(const std::string& auth) {
150 profile_info_cache_->SetLocalAuthCredentialsOfProfileAtIndex( 155 profile_info_cache_->SetLocalAuthCredentialsOfProfileAtIndex(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 const std::string& gaia_id, const base::string16& user_name) { 215 const std::string& gaia_id, const base::string16& user_name) {
211 profile_info_cache_->SetAuthInfoOfProfileAtIndex( 216 profile_info_cache_->SetAuthInfoOfProfileAtIndex(
212 profile_index(), gaia_id, user_name); 217 profile_index(), gaia_id, user_name);
213 } 218 }
214 219
215 size_t ProfileAttributesEntry::profile_index() const { 220 size_t ProfileAttributesEntry::profile_index() const {
216 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_); 221 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_);
217 DCHECK(index < profile_info_cache_->GetNumberOfProfiles()); 222 DCHECK(index < profile_info_cache_->GetNumberOfProfiles());
218 return index; 223 return index;
219 } 224 }
225
226 bool ProfileAttributesEntry::LessThan(const ProfileAttributesEntry& other)
227 const {
228 base::string16 lower_name = base::i18n::ToLower(GetName());
229 base::string16 other_lower_name = base::i18n::ToLower(other.GetName());
230
231 int name_compare = lower_name.compare(other_lower_name);
232
233 if (name_compare == 0) {
234 return profile_info_cache_->CacheKeyFromProfilePath(GetPath()).compare(
Mike Lerman 2015/08/06 16:06:19 Why not just run compare on GetPath() (or some der
235 profile_info_cache_->CacheKeyFromProfilePath(other.GetPath())) < 0;
236 }
237 return name_compare < 0;
238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698