Commit 91ead71d authored by mlerman's avatar mlerman Committed by Commit bot

Optimize writes upon ProfileManager::UpdateLastUser.

BUG=481721

Review URL: https://codereview.chromium.org/1106213003

Cr-Commit-Position: refs/heads/master@{#327498}
parent 3f5393c9
...@@ -471,6 +471,11 @@ size_t ProfileInfoCache::GetAvatarIconIndexOfProfileAtIndex(size_t index) ...@@ -471,6 +471,11 @@ size_t ProfileInfoCache::GetAvatarIconIndexOfProfileAtIndex(size_t index)
} }
void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) { void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) {
if (base::Time::Now() - GetProfileActiveTimeAtIndex(index) <
base::TimeDelta::FromHours(1)) {
return;
}
scoped_ptr<base::DictionaryValue> info( scoped_ptr<base::DictionaryValue> info(
GetInfoForProfileAtIndex(index)->DeepCopy()); GetInfoForProfileAtIndex(index)->DeepCopy());
info->SetDouble(kActiveTimeKey, base::Time::Now().ToDoubleT()); info->SetDouble(kActiveTimeKey, base::Time::Now().ToDoubleT());
......
...@@ -1332,8 +1332,10 @@ void ProfileManager::UpdateLastUser(Profile* last_active) { ...@@ -1332,8 +1332,10 @@ void ProfileManager::UpdateLastUser(Profile* last_active) {
DCHECK(local_state); DCHECK(local_state);
// Only keep track of profiles that we are managing; tests may create others. // Only keep track of profiles that we are managing; tests may create others.
if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) { if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) {
local_state->SetString(prefs::kProfileLastUsed, std::string profile_path_base =
last_active->GetPath().BaseName().MaybeAsASCII()); last_active->GetPath().BaseName().MaybeAsASCII();
if (profile_path_base != local_state->GetString(prefs::kProfileLastUsed))
local_state->SetString(prefs::kProfileLastUsed, profile_path_base);
ProfileInfoCache& cache = GetProfileInfoCache(); ProfileInfoCache& cache = GetProfileInfoCache();
size_t profile_index = size_t profile_index =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment