cryptohome: use just the obfuscated username in HomeDir

Simplify code by using just the obfuscated username in HomeDir.

BUG=None
TEST=unit tests

Change-Id: I19aa6a57d371e437107cb1d9fa405e0d57d9edcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2202800
Tested-by: Victor-Gabriel Savu <vsavu@google.com>
Commit-Queue: Victor-Gabriel Savu <vsavu@google.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
diff --git a/cryptohome/disk_cleanup.cc b/cryptohome/disk_cleanup.cc
index 06efe77..b491209 100644
--- a/cryptohome/disk_cleanup.cc
+++ b/cryptohome/disk_cleanup.cc
@@ -166,18 +166,19 @@
   if (!timestamp_cache_->initialized()) {
     timestamp_cache_->Initialize();
     for (const auto& dir : homedirs) {
-      homedirs_->AddUserTimestampToCache(dir.shadow);
+      homedirs_->AddUserTimestampToCache(dir.obfuscated);
     }
   }
 
   auto unmounted_homedirs = homedirs;
   FilterMountedHomedirs(&unmounted_homedirs);
 
-  std::sort(unmounted_homedirs.begin(), unmounted_homedirs.end(),
-            [&](const HomeDirs::HomeDir& a, const HomeDirs::HomeDir& b) {
-              return timestamp_cache_->GetLastUserActivityTimestamp(a.shadow) >
-                     timestamp_cache_->GetLastUserActivityTimestamp(b.shadow);
-            });
+  std::sort(
+      unmounted_homedirs.begin(), unmounted_homedirs.end(),
+      [&](const HomeDirs::HomeDir& a, const HomeDirs::HomeDir& b) {
+        return timestamp_cache_->GetLastUserActivityTimestamp(a.obfuscated) >
+               timestamp_cache_->GetLastUserActivityTimestamp(b.obfuscated);
+      });
 
   auto normal_cleanup_homedirs = unmounted_homedirs;
 
@@ -190,7 +191,7 @@
   // the last normal cleanup happened.
   for (auto dir = normal_cleanup_homedirs.rbegin();
        dir != normal_cleanup_homedirs.rend(); dir++) {
-    routines_->DeleteUserCache(dir->shadow.BaseName().value());
+    routines_->DeleteUserCache(dir->obfuscated);
 
     if (HasTargetFreeSpace()) {
       ReportDiskCleanupProgress(
@@ -211,7 +212,7 @@
   // after the last normal cleanup happened.
   for (auto dir = normal_cleanup_homedirs.rbegin();
        dir != normal_cleanup_homedirs.rend(); dir++) {
-    routines_->DeleteUserGCache(dir->shadow.BaseName().value());
+    routines_->DeleteUserGCache(dir->obfuscated);
 
     if (HasTargetFreeSpace()) {
       earlyStop = true;
@@ -268,7 +269,7 @@
   // out after after the last normal cleanup happened.
   for (auto dir = aggressive_cleanup_homedirs.rbegin();
        dir != aggressive_cleanup_homedirs.rend(); dir++) {
-    routines_->DeleteUserAndroidCache(dir->shadow.BaseName().value());
+    routines_->DeleteUserAndroidCache(dir->obfuscated);
 
     if (HasTargetFreeSpace()) {
       earlyStop = true;
@@ -315,8 +316,6 @@
 
   for (auto dir = unmounted_homedirs.rbegin(); dir != unmounted_homedirs.rend();
        dir++) {
-    std::string obfuscated = dir->shadow.BaseName().value();
-
     if (homedirs_->enterprise_owned()) {
       // Leave the most-recent user on the device intact.
       // The most-recent user is the first in unmounted_homedirs.
@@ -325,15 +324,15 @@
         LOG(INFO) << "Skipped deletion of the most recent device user.";
         continue;
       }
-    } else if (obfuscated == owner) {
+    } else if (dir->obfuscated == owner) {
       // We never delete the device owner.
       LOG(INFO) << "Skipped deletion of the device owner.";
       continue;
     }
 
-    LOG(INFO) << "Freeing disk space by deleting user " << obfuscated;
-    routines_->DeleteUserProfile(obfuscated);
-    timestamp_cache_->RemoveUser(dir->shadow);
+    LOG(INFO) << "Freeing disk space by deleting user " << dir->obfuscated;
+    routines_->DeleteUserProfile(dir->obfuscated);
+    timestamp_cache_->RemoveUser(dir->obfuscated);
     ++deleted_users_count;
 
     if (HasTargetFreeSpace())
@@ -371,7 +370,7 @@
       std::remove_if(homedirs->begin(), homedirs->end(),
                      [&](const HomeDirs::HomeDir& dir) {
                        return timestamp_cache_->GetLastUserActivityTimestamp(
-                                  dir.shadow) < cutoff;
+                                  dir.obfuscated) < cutoff;
                      }),
       homedirs->end());
 }
diff --git a/cryptohome/homedirs.cc b/cryptohome/homedirs.cc
index bf020b6..15a41a0 100644
--- a/cryptohome/homedirs.cc
+++ b/cryptohome/homedirs.cc
@@ -781,18 +781,17 @@
       .AddExtension(base::NumberToString(index));
 }
 
-void HomeDirs::RemoveNonOwnerCryptohomesCallback(const FilePath& user_dir) {
+void HomeDirs::RemoveNonOwnerCryptohomesCallback(
+    const std::string& obfuscated) {
   if (!enterprise_owned_) {  // Enterprise owned? Delete it all.
     std::string owner;
-    if (!GetOwner(&owner) ||  // No owner? bail.
-        // Don't delete the owner's cryptohome!
-        // TODO(wad,ellyjones) Add GetUser*Path-helpers
-        user_dir == shadow_root_.Append(owner))
-    return;
+    if (!GetOwner(&owner) || obfuscated == owner)
+      return;
   }
   // Once we're sure this is not the owner's cryptohome, delete it.
-  RemoveLECredentials(user_dir.BaseName().value());
-  platform_->DeleteFile(user_dir, true);
+  RemoveLECredentials(obfuscated);
+  FilePath shadow_dir = shadow_root_.Append(obfuscated);
+  platform_->DeleteFile(shadow_dir, true);
 }
 
 void HomeDirs::RemoveNonOwnerCryptohomes() {
@@ -813,7 +812,7 @@
     return;
 
   for (const auto& dir : homedirs) {
-    HomeDirs::RemoveNonOwnerCryptohomesCallback(dir.shadow);
+    HomeDirs::RemoveNonOwnerCryptohomesCallback(dir.obfuscated);
   }
 
   // TODO(ellyjones): is this valuable? These two directories should just be
@@ -832,26 +831,24 @@
   for (const auto& entry : entries) {
     HomeDirs::HomeDir dir;
 
-    dir.shadow = entry;
+    dir.obfuscated = entry.BaseName().value();
 
-    const std::string obfuscated = entry.BaseName().value();
-
-    if (!brillo::cryptohome::home::IsSanitizedUserName(obfuscated))
+    if (!brillo::cryptohome::home::IsSanitizedUserName(dir.obfuscated))
       continue;
 
-    dir.user = brillo::cryptohome::home::GetHashedUserPath(obfuscated);
-
-    if (!platform_->DirectoryExists(dir.user))
+    if (!platform_->DirectoryExists(
+            brillo::cryptohome::home::GetHashedUserPath(dir.obfuscated)))
       continue;
 
     ret.push_back(dir);
   }
 
   std::vector<FilePath> user_paths;
-  std::transform(ret.begin(), ret.end(), std::back_inserter(user_paths),
-    [] (const HomeDirs::HomeDir& homedir) {
-      return homedir.user;
-    });
+  std::transform(
+      ret.begin(), ret.end(), std::back_inserter(user_paths),
+      [](const HomeDirs::HomeDir& homedir) {
+        return brillo::cryptohome::home::GetHashedUserPath(homedir.obfuscated);
+      });
 
   auto is_mounted = platform_->AreDirectoriesMounted(user_paths);
 
@@ -881,7 +878,7 @@
       std::remove_if(homedirs->begin(), homedirs->end(),
                      [&](const HomeDirs::HomeDir& dir) {
                        return timestamp_cache_->GetLastUserActivityTimestamp(
-                                  dir.shadow) < cutoff;
+                                  dir.obfuscated) < cutoff;
                      }),
       homedirs->end());
 }
@@ -973,12 +970,11 @@
   return true;
 }
 
-void HomeDirs::AddUserTimestampToCache(const FilePath& user_dir) {
-  const std::string obfuscated_username = user_dir.BaseName().value();
+void HomeDirs::AddUserTimestampToCache(const std::string& obfuscated) {
   //  Add a timestamp for every key.
   std::vector<int> key_indices;
   // Failure is okay since the loop falls through.
-  GetVaultKeysets(obfuscated_username, &key_indices);
+  GetVaultKeysets(obfuscated, &key_indices);
   std::unique_ptr<VaultKeyset> keyset(
       vault_keyset_factory()->New(platform_, crypto_));
   // Collect the most recent time for a given user by walking all
@@ -986,7 +982,7 @@
   // TODO(wad,?) Move non-key vault metadata to a standalone file.
   base::Time timestamp = base::Time();
   for (int index : key_indices) {
-    if (LoadVaultKeysetForUser(obfuscated_username, index, keyset.get()) &&
+    if (LoadVaultKeysetForUser(obfuscated, index, keyset.get()) &&
         keyset->serialized().has_last_activity_timestamp()) {
       const base::Time t = base::Time::FromInternalValue(
           keyset->serialized().last_activity_timestamp());
@@ -995,7 +991,7 @@
     }
   }
   if (!timestamp.is_null()) {
-      timestamp_cache_->AddExistingUser(user_dir, timestamp);
+    timestamp_cache_->AddExistingUser(obfuscated, timestamp);
   }
 }
 
@@ -1455,13 +1451,12 @@
         if (dir.is_mounted)
           return false;
 
-        const std::string obfuscated = dir.shadow.BaseName().value();
-
-        if (EcryptfsCryptohomeExists(obfuscated))
+        if (EcryptfsCryptohomeExists(dir.obfuscated))
           return false;
 
+        FilePath shadow_dir = shadow_root_.Append(dir.obfuscated);
         FilePath root_home_dir;
-        return GetTrackedDirectory(dir.shadow, FilePath(kRootHomeSuffix),
+        return GetTrackedDirectory(shadow_dir, FilePath(kRootHomeSuffix),
                                    &root_home_dir) &&
                MayContainAndroidData(root_home_dir);
       });
diff --git a/cryptohome/homedirs.h b/cryptohome/homedirs.h
index 217ce15..154ed45 100644
--- a/cryptohome/homedirs.h
+++ b/cryptohome/homedirs.h
@@ -58,12 +58,9 @@
 
 class HomeDirs {
  public:
-  // HomeDir contains lists properties of users profiles.
+  // HomeDir contains lists the current user profiles.
   struct HomeDir {
-    // Path in /home/.shadow/
-    base::FilePath shadow;
-    // Path in /home/user/
-    base::FilePath user;
+    std::string obfuscated;
     bool is_mounted = false;
   };
 
@@ -277,7 +274,7 @@
 
   // Called during disk cleanup if the timestamp cache is not yet
   // initialized. Loads the last activity timestamp from the vault keyset.
-  virtual void AddUserTimestampToCache(const base::FilePath& user_dir);
+  virtual void AddUserTimestampToCache(const std::string& obfuscated);
 
   // Accessors. Mostly used for unit testing. These do not take ownership of
   // passed-in pointers.
@@ -333,7 +330,7 @@
   // cleanup.
   void RemoveNonOwnerCryptohomesInternal(const std::vector<HomeDir>& homedirs);
   // Callback used during RemoveNonOwnerCryptohomes()
-  void RemoveNonOwnerCryptohomesCallback(const base::FilePath& user_dir);
+  void RemoveNonOwnerCryptohomesCallback(const std::string& obfuscated);
   // Recursively deletes all contents of a directory while leaving the directory
   // itself intact.
   void DeleteDirectoryContents(const base::FilePath& dir);
diff --git a/cryptohome/homedirs_unittest.cc b/cryptohome/homedirs_unittest.cc
index 2de7a9f..4b7f562 100644
--- a/cryptohome/homedirs_unittest.cc
+++ b/cryptohome/homedirs_unittest.cc
@@ -131,6 +131,7 @@
         homedirs_.GetOwner(&user);
       else
         user = hd.name;
+      obfuscated_users_.push_back(user);
       homedir_paths_.push_back(fp.Append(user));
       user_paths_.push_back(brillo::cryptohome::home::GetHashedUserPath(user));
       base::Time t;
@@ -211,6 +212,7 @@
   Crypto crypto_;
   std::vector<FilePath> homedir_paths_;
   std::vector<FilePath> user_paths_;
+  std::vector<std::string> obfuscated_users_;
   MockUserOldestActivityTimestampCache timestamp_cache_;
   std::vector<base::Time> homedir_times_;
   MockVaultKeysetFactory vault_keyset_factory_;
@@ -787,11 +789,12 @@
 
   // Adding the owner
   EXPECT_CALL(timestamp_cache_,
-              AddExistingUser(homedir_paths_[3], homedir_times_[3]))
-    .Times(1);
+              AddExistingUser(obfuscated_users_[3], homedir_times_[3]))
+      .Times(1);
   EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(_))
       .WillRepeatedly(Return(base::Time()));
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[3]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[3]))
       .WillRepeatedly(Return(homedir_times_[3]));
 
   // Now skip the deletion steps by not having a legit owner.
@@ -890,7 +893,8 @@
   homedirs_.disk_cleanup()->FreeDiskSpace();
 
   // Simulate logout
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[2]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[2]))
       .WillRepeatedly(Return(base::Time::Now()));
 
   EXPECT_CALL(platform_, AmountOfFreeDiskSpace(kTestRoot))
@@ -1014,7 +1018,8 @@
   homedirs_.disk_cleanup()->FreeDiskSpace();
 
   // Simulate logout
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[2]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[2]))
       .WillRepeatedly(Return(base::Time::Now()));
 
   EXPECT_CALL(platform_, AmountOfFreeDiskSpace(kTestRoot))
@@ -1472,7 +1477,7 @@
 
   EXPECT_CALL(platform_, DeleteFile(homedir_paths_[0], true))
       .WillOnce(Return(true));
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[0])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[0])).Times(1);
 
   ExpectCacheDirCleanupCalls(4);
   ExpectTimestampCacheInitialization();
@@ -1480,7 +1485,7 @@
 
   for (int i = 0; i < user_paths_.size(); i++) {
     EXPECT_CALL(timestamp_cache_,
-                GetLastUserActivityTimestamp(homedir_paths_[i]))
+                GetLastUserActivityTimestamp(obfuscated_users_[i]))
         .WillRepeatedly(Return(homedir_times_[i]));
   }
 
@@ -1501,8 +1506,8 @@
       .WillOnce(Return(true));
   EXPECT_CALL(platform_, DeleteFile(homedir_paths_[1], true))
       .WillOnce(Return(true));
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[0])).Times(1);
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[1])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[0])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[1])).Times(1);
 
   ExpectCacheDirCleanupCalls(4);
   ExpectTimestampCacheInitialization();
@@ -1511,7 +1516,7 @@
 
   for (int i = 0; i < user_paths_.size(); i++) {
     EXPECT_CALL(timestamp_cache_,
-                GetLastUserActivityTimestamp(homedir_paths_[i]))
+                GetLastUserActivityTimestamp(obfuscated_users_[i]))
         .WillRepeatedly(Return(homedir_times_[i]));
   }
 
@@ -1527,10 +1532,10 @@
   cache.Initialize();
   homedirs_.Init(&platform_, &crypto_, &cache);
 
-  cache.AddExistingUser(homedir_paths_[0], homedir_times_[0]);
-  cache.AddExistingUser(homedir_paths_[1], homedir_times_[1]);
-  cache.AddExistingUser(homedir_paths_[2], homedir_times_[2]);
-  cache.AddExistingUser(homedir_paths_[3], homedir_times_[3]);
+  cache.AddExistingUser(obfuscated_users_[0], homedir_times_[0]);
+  cache.AddExistingUser(obfuscated_users_[1], homedir_times_[1]);
+  cache.AddExistingUser(obfuscated_users_[2], homedir_times_[2]);
+  cache.AddExistingUser(obfuscated_users_[3], homedir_times_[3]);
 
   EXPECT_CALL(platform_, AmountOfFreeDiskSpace(kTestRoot))
     .WillRepeatedly(Return(0));
@@ -1558,10 +1563,10 @@
   cache.Initialize();
   homedirs_.Init(&platform_, &crypto_, &cache);
 
-  cache.AddExistingUser(homedir_paths_[0], homedir_times_[0]);
-  cache.AddExistingUser((homedir_paths_[1]), homedir_times_[1]);
+  cache.AddExistingUser(obfuscated_users_[0], homedir_times_[0]);
+  cache.AddExistingUser(obfuscated_users_[1], homedir_times_[1]);
   // User 2 is logged in, and hence not added to cache during initialization.
-  cache.AddExistingUser((homedir_paths_[3]), homedir_times_[3]);
+  cache.AddExistingUser(obfuscated_users_[3], homedir_times_[3]);
 
   EXPECT_CALL(platform_, AmountOfFreeDiskSpace(kTestRoot))
     .WillRepeatedly(Return(0));
@@ -1616,8 +1621,8 @@
   // Ensure the owner isn't deleted!
   EXPECT_CALL(platform_, DeleteFile(homedir_paths_[3], true))
     .Times(0);
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[0])).Times(1);
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[1])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[0])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[1])).Times(1);
 
   ExpectCacheDirCleanupCalls(4);
   ExpectTimestampCacheInitialization();
@@ -1626,13 +1631,17 @@
 
   // Users ordered by age: 0, 3, 1, 2.
   // Owner is 3.
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[0]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[0]))
       .WillRepeatedly(Return(homedir_times_[0]));
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[1]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[1]))
       .WillRepeatedly(Return(homedir_times_[2]));
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[2]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[2]))
       .WillRepeatedly(Return(homedir_times_[3]));
-  EXPECT_CALL(timestamp_cache_, GetLastUserActivityTimestamp(homedir_paths_[3]))
+  EXPECT_CALL(timestamp_cache_,
+              GetLastUserActivityTimestamp(obfuscated_users_[3]))
       .WillRepeatedly(Return(homedir_times_[1]));
 
   homedirs_.disk_cleanup()->FreeDiskSpace();
@@ -1819,14 +1828,14 @@
   ExpectTimestampCacheInitialization();
 
   // Mounted user and owner not deleted.
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[1])).Times(1);
-  EXPECT_CALL(timestamp_cache_, RemoveUser(homedir_paths_[2])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[1])).Times(1);
+  EXPECT_CALL(timestamp_cache_, RemoveUser(obfuscated_users_[2])).Times(1);
   ExpectDeletedLECredentialEnumeration(homedir_paths_[1]);
   ExpectDeletedLECredentialEnumeration(homedir_paths_[2]);
 
   for (int i = 0; i < user_paths_.size(); i++) {
     EXPECT_CALL(timestamp_cache_,
-                GetLastUserActivityTimestamp(homedir_paths_[i]))
+                GetLastUserActivityTimestamp(obfuscated_users_[i]))
         .WillRepeatedly(Return(homedir_times_[i]));
   }
 
diff --git a/cryptohome/mock_user_oldest_activity_timestamp_cache.h b/cryptohome/mock_user_oldest_activity_timestamp_cache.h
index edcd30a..5537ddb 100644
--- a/cryptohome/mock_user_oldest_activity_timestamp_cache.h
+++ b/cryptohome/mock_user_oldest_activity_timestamp_cache.h
@@ -7,7 +7,8 @@
 
 #include "cryptohome/user_oldest_activity_timestamp_cache.h"
 
-#include <base/files/file_path.h>
+#include <string>
+
 #include <base/time/time.h>
 
 #include <gmock/gmock.h>
@@ -24,16 +25,16 @@
   MOCK_METHOD(bool, initialized, (), (const, override));
   MOCK_METHOD(void,
               AddExistingUser,
-              (const base::FilePath&, base::Time),
+              (const std::string&, base::Time),
               (override));
   MOCK_METHOD(void,
               UpdateExistingUser,
-              (const base::FilePath&, base::Time),
+              (const std::string&, base::Time),
               (override));
-  MOCK_METHOD(void, RemoveUser, (const base::FilePath&), (override));
+  MOCK_METHOD(void, RemoveUser, (const std::string&), (override));
   MOCK_METHOD(base::Time,
               GetLastUserActivityTimestamp,
-              (const base::FilePath&),
+              (const std::string&),
               (const, override));
 };
 }  // namespace cryptohome
diff --git a/cryptohome/mount.cc b/cryptohome/mount.cc
index 7db76e5..1444c38 100644
--- a/cryptohome/mount.cc
+++ b/cryptohome/mount.cc
@@ -836,8 +836,7 @@
       return false;
     }
     if (user_timestamp_cache_->initialized()) {
-      user_timestamp_cache_->UpdateExistingUser(
-          FilePath(GetUserDirectoryForUser(obfuscated_username)), timestamp);
+      user_timestamp_cache_->UpdateExistingUser(obfuscated_username, timestamp);
     }
     return true;
   }
diff --git a/cryptohome/user_oldest_activity_timestamp_cache.cc b/cryptohome/user_oldest_activity_timestamp_cache.cc
index 3f2739d..3b2b011 100644
--- a/cryptohome/user_oldest_activity_timestamp_cache.cc
+++ b/cryptohome/user_oldest_activity_timestamp_cache.cc
@@ -4,14 +4,12 @@
 
 #include "cryptohome/user_oldest_activity_timestamp_cache.h"
 
+#include <string>
 #include <utility>
 
-#include <base/files/file_path.h>
 #include <base/logging.h>
 #include <base/time/time.h>
 
-using base::FilePath;
-
 namespace cryptohome {
 
 void UserOldestActivityTimestampCache::Initialize() {
@@ -19,27 +17,28 @@
   initialized_ = true;
 }
 
-void UserOldestActivityTimestampCache::AddExistingUser(
-    const FilePath& vault, base::Time timestamp) {
+void UserOldestActivityTimestampCache::AddExistingUser(const std::string& user,
+                                                       base::Time timestamp) {
   CHECK(initialized_);
-  users_timestamp_lookup_.insert(std::make_pair(vault, timestamp));
+  users_timestamp_lookup_.insert(std::make_pair(user, timestamp));
 }
 
 void UserOldestActivityTimestampCache::UpdateExistingUser(
-    const FilePath& vault, base::Time timestamp) {
+    const std::string& user,
+    base::Time timestamp) {
   CHECK(initialized_);
-  users_timestamp_lookup_[vault] = timestamp;
+  users_timestamp_lookup_[user] = timestamp;
 }
 
-void UserOldestActivityTimestampCache::RemoveUser(const base::FilePath& vault) {
+void UserOldestActivityTimestampCache::RemoveUser(const std::string& user) {
   CHECK(initialized_);
-  users_timestamp_lookup_.erase(vault);
+  users_timestamp_lookup_.erase(user);
 }
 
 base::Time UserOldestActivityTimestampCache::GetLastUserActivityTimestamp(
-    const base::FilePath& vault) const {
+    const std::string& user) const {
   CHECK(initialized_);
-  auto it = users_timestamp_lookup_.find(vault);
+  auto it = users_timestamp_lookup_.find(user);
 
   if (it == users_timestamp_lookup_.end()) {
     return base::Time();
diff --git a/cryptohome/user_oldest_activity_timestamp_cache.h b/cryptohome/user_oldest_activity_timestamp_cache.h
index 60095b6..8256717 100644
--- a/cryptohome/user_oldest_activity_timestamp_cache.h
+++ b/cryptohome/user_oldest_activity_timestamp_cache.h
@@ -6,8 +6,8 @@
 #define CRYPTOHOME_USER_OLDEST_ACTIVITY_TIMESTAMP_CACHE_H_
 
 #include <map>
+#include <string>
 
-#include <base/files/file_path.h>
 #include <base/macros.h>
 #include <base/time/time.h>
 
@@ -31,23 +31,22 @@
   }
 
   // Adds a user to the cache with specified oldest activity timestamp.
-  virtual void AddExistingUser(const base::FilePath& vault,
-                               base::Time timestamp);
+  virtual void AddExistingUser(const std::string& user, base::Time timestamp);
 
   // Updates a user in the cache with specified oldest activity timestamp.
-  virtual void UpdateExistingUser(const base::FilePath& vault,
+  virtual void UpdateExistingUser(const std::string& user,
                                   base::Time timestamp);
 
   // Remove a user from the cache.
-  virtual void RemoveUser(const base::FilePath& vault);
+  virtual void RemoveUser(const std::string& user);
 
   // Returns the last activity timestamp for a user. For users without a
   // timestamp it returns a NULL time.
   virtual base::Time GetLastUserActivityTimestamp(
-      const base::FilePath& vault) const;
+      const std::string& user) const;
 
  private:
-  std::map<base::FilePath, base::Time> users_timestamp_lookup_;
+  std::map<std::string, base::Time> users_timestamp_lookup_;
   bool initialized_;
 
   DISALLOW_COPY_AND_ASSIGN(UserOldestActivityTimestampCache);
diff --git a/cryptohome/user_oldest_activity_timestamp_cache_unittest.cc b/cryptohome/user_oldest_activity_timestamp_cache_unittest.cc
index 3e64069..43fa639 100644
--- a/cryptohome/user_oldest_activity_timestamp_cache_unittest.cc
+++ b/cryptohome/user_oldest_activity_timestamp_cache_unittest.cc
@@ -6,12 +6,9 @@
 
 #include "cryptohome/user_oldest_activity_timestamp_cache.h"
 
-#include <base/files/file_path.h>
 #include <base/logging.h>
 #include <gtest/gtest.h>
 
-using base::FilePath;
-
 namespace {
 const base::Time::Exploded feb1st2011_exploded = { 2011, 2, 2, 1 };
 const base::Time::Exploded mar1st2011_exploded = { 2011, 3, 2, 1 };
@@ -28,15 +25,15 @@
   UserOldestActivityTimestampCache cache;
   cache.Initialize();
 
-  cache.AddExistingUser(FilePath("b"), time_mar1);
-  EXPECT_EQ(cache.GetLastUserActivityTimestamp(FilePath("b")), time_mar1);
+  cache.AddExistingUser("b", time_mar1);
+  EXPECT_EQ(cache.GetLastUserActivityTimestamp("b"), time_mar1);
 
-  cache.AddExistingUser(FilePath("c"), time_feb1);
-  EXPECT_EQ(cache.GetLastUserActivityTimestamp(FilePath("c")), time_feb1);
-  cache.UpdateExistingUser(FilePath("c"), time_mar1);
-  EXPECT_EQ(cache.GetLastUserActivityTimestamp(FilePath("c")), time_mar1);
-  cache.RemoveUser(FilePath("c"));
-  EXPECT_TRUE(cache.GetLastUserActivityTimestamp(FilePath("c")).is_null());
+  cache.AddExistingUser("c", time_feb1);
+  EXPECT_EQ(cache.GetLastUserActivityTimestamp("c"), time_feb1);
+  cache.UpdateExistingUser("c", time_mar1);
+  EXPECT_EQ(cache.GetLastUserActivityTimestamp("c"), time_mar1);
+  cache.RemoveUser("c");
+  EXPECT_TRUE(cache.GetLastUserActivityTimestamp("c").is_null());
 }
 
 }  // namespace cryptohome