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

Side by Side Diff: chrome/browser/profiles/profile_impl.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 (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_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/policy/profile_policy_connector.h" 50 #include "chrome/browser/policy/profile_policy_connector.h"
51 #include "chrome/browser/policy/profile_policy_connector_factory.h" 51 #include "chrome/browser/policy/profile_policy_connector_factory.h"
52 #include "chrome/browser/prefs/browser_prefs.h" 52 #include "chrome/browser/prefs/browser_prefs.h"
53 #include "chrome/browser/prefs/chrome_pref_service_factory.h" 53 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
54 #include "chrome/browser/prefs/pref_service_syncable.h" 54 #include "chrome/browser/prefs/pref_service_syncable.h"
55 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" 55 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h"
56 #include "chrome/browser/prerender/prerender_manager_factory.h" 56 #include "chrome/browser/prerender/prerender_manager_factory.h"
57 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 57 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
58 #include "chrome/browser/profiles/chrome_version_service.h" 58 #include "chrome/browser/profiles/chrome_version_service.h"
59 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" 59 #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
60 #include "chrome/browser/profiles/profile_attributes_entry.h"
61 #include "chrome/browser/profiles/profile_attributes_storage.h"
60 #include "chrome/browser/profiles/profile_destroyer.h" 62 #include "chrome/browser/profiles/profile_destroyer.h"
61 #include "chrome/browser/profiles/profile_info_cache.h"
62 #include "chrome/browser/profiles/profile_manager.h" 63 #include "chrome/browser/profiles/profile_manager.h"
63 #include "chrome/browser/profiles/profile_metrics.h" 64 #include "chrome/browser/profiles/profile_metrics.h"
64 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 65 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
65 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 66 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
66 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 67 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
67 #include "chrome/browser/services/gcm/gcm_profile_service.h" 68 #include "chrome/browser/services/gcm/gcm_profile_service.h"
68 #include "chrome/browser/sessions/session_service_factory.h" 69 #include "chrome/browser/sessions/session_service_factory.h"
69 #include "chrome/browser/signin/signin_manager_factory.h" 70 #include "chrome/browser/signin/signin_manager_factory.h"
70 #include "chrome/browser/signin/signin_ui_util.h" 71 #include "chrome/browser/signin/signin_ui_util.h"
71 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" 72 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 return GURL(chrome::kChromeUINewTabURL); 1220 return GURL(chrome::kChromeUINewTabURL);
1220 GURL home_page(url_fixer::FixupURL(GetPrefs()->GetString(prefs::kHomePage), 1221 GURL home_page(url_fixer::FixupURL(GetPrefs()->GetString(prefs::kHomePage),
1221 std::string())); 1222 std::string()));
1222 if (!home_page.is_valid()) 1223 if (!home_page.is_valid())
1223 return GURL(chrome::kChromeUINewTabURL); 1224 return GURL(chrome::kChromeUINewTabURL);
1224 return home_page; 1225 return home_page;
1225 } 1226 }
1226 1227
1227 void ProfileImpl::UpdateProfileSupervisedUserIdCache() { 1228 void ProfileImpl::UpdateProfileSupervisedUserIdCache() {
1228 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1229 ProfileManager* profile_manager = g_browser_process->profile_manager();
1229 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1230 ProfileAttributesStorage& storage =
1230 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1231 profile_manager->GetProfileAttributesStorage();
1231 if (index != std::string::npos) { 1232 ProfileAttributesEntry* entry;
1233 if (storage.GetProfileAttributesWithPath(GetPath(), &entry)) {
1232 std::string supervised_user_id = 1234 std::string supervised_user_id =
1233 GetPrefs()->GetString(prefs::kSupervisedUserId); 1235 GetPrefs()->GetString(prefs::kSupervisedUserId);
1234 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); 1236 entry->SetSupervisedUserId(supervised_user_id);
1235 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); 1237 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager);
1236 } 1238 }
1237 } 1239 }
1238 1240
1239 void ProfileImpl::UpdateProfileNameCache() { 1241 void ProfileImpl::UpdateProfileNameCache() {
1240 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1242 ProfileManager* profile_manager = g_browser_process->profile_manager();
1241 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1243 ProfileAttributesStorage& storage =
1242 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1244 profile_manager->GetProfileAttributesStorage();
1243 if (index != std::string::npos) { 1245 ProfileAttributesEntry* entry;
1246 if (storage.GetProfileAttributesWithPath(GetPath(), &entry)) {
1244 std::string profile_name = 1247 std::string profile_name =
1245 GetPrefs()->GetString(prefs::kProfileName); 1248 GetPrefs()->GetString(prefs::kProfileName);
1246 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); 1249 entry->SetName(base::UTF8ToUTF16(profile_name));
1247 bool default_name = 1250 bool default_name =
1248 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName); 1251 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName);
1249 cache.SetProfileIsUsingDefaultNameAtIndex(index, default_name); 1252 entry->SetIsUsingDefaultName(default_name);
1250 } 1253 }
1251 } 1254 }
1252 1255
1253 void ProfileImpl::UpdateProfileAvatarCache() { 1256 void ProfileImpl::UpdateProfileAvatarCache() {
1254 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1257 ProfileManager* profile_manager = g_browser_process->profile_manager();
1255 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1258 ProfileAttributesStorage& storage =
1256 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1259 profile_manager->GetProfileAttributesStorage();
1257 if (index != std::string::npos) { 1260 ProfileAttributesEntry* entry;
1261 if (storage.GetProfileAttributesWithPath(GetPath(), &entry)) {
1258 size_t avatar_index = 1262 size_t avatar_index =
1259 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex); 1263 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
1260 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index); 1264 entry->SetAvatarIconIndex(avatar_index);
1261 bool default_avatar = 1265 bool default_avatar =
1262 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar); 1266 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar);
1263 cache.SetProfileIsUsingDefaultAvatarAtIndex(index, default_avatar); 1267 entry->SetIsUsingDefaultAvatar(default_avatar);
1264 bool gaia_avatar = 1268 bool gaia_avatar =
1265 GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar); 1269 GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar);
1266 cache.SetIsUsingGAIAPictureOfProfileAtIndex(index, gaia_avatar); 1270 entry->SetIsUsingGAIAPicture(gaia_avatar);
1267 } 1271 }
1268 } 1272 }
1269 1273
1270 void ProfileImpl::UpdateProfileIsEphemeralCache() { 1274 void ProfileImpl::UpdateProfileIsEphemeralCache() {
1271 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1275 ProfileManager* profile_manager = g_browser_process->profile_manager();
1272 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1276 ProfileAttributesStorage& storage =
1273 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1277 profile_manager->GetProfileAttributesStorage();
1274 if (index != std::string::npos) { 1278 ProfileAttributesEntry* entry;
1279 if (storage.GetProfileAttributesWithPath(GetPath(), &entry)) {
1275 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles); 1280 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles);
1276 cache.SetProfileIsEphemeralAtIndex(index, is_ephemeral); 1281 entry->SetIsEphemeral(is_ephemeral);
1277 } 1282 }
1278 } 1283 }
1279 1284
1280 // Gets the cache parameters from the command line. If |is_media_context| is 1285 // Gets the cache parameters from the command line. If |is_media_context| is
1281 // set to true then settings for the media context type is what we need, 1286 // set to true then settings for the media context type is what we need,
1282 // |cache_path| will be set to the user provided path, or will not be touched if 1287 // |cache_path| will be set to the user provided path, or will not be touched if
1283 // there is not an argument. |max_size| will be the user provided value or zero 1288 // there is not an argument. |max_size| will be the user provided value or zero
1284 // by default. 1289 // by default.
1285 void ProfileImpl::GetCacheParameters(bool is_media_context, 1290 void ProfileImpl::GetCacheParameters(bool is_media_context,
1286 base::FilePath* cache_path, 1291 base::FilePath* cache_path,
(...skipping 22 matching lines...) Expand all
1309 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { 1314 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) {
1310 domain_reliability::DomainReliabilityService* service = 1315 domain_reliability::DomainReliabilityService* service =
1311 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> 1316 domain_reliability::DomainReliabilityServiceFactory::GetInstance()->
1312 GetForBrowserContext(this); 1317 GetForBrowserContext(this);
1313 if (!service) 1318 if (!service)
1314 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); 1319 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>();
1315 1320
1316 return service->CreateMonitor( 1321 return service->CreateMonitor(
1317 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 1322 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
1318 } 1323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698