drive: Make FileCache::RenameCacheFilesToNewFormat responsible to canonicalize file name

Move file name canonicalization responsibility from CanonicalizeIDs to RenameCacheFilesToNewFormat

CanonicalizeIDs will be deleted soon when cache entry ID canonicalization code moves to ResourceMetadataStorage.

BUG=309597
TEST=unit_tests
[email protected]

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230029 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chromeos/drive/file_cache_unittest.cc b/chrome/browser/chromeos/drive/file_cache_unittest.cc
index e4d98b5d..d2c8810 100644
--- a/chrome/browser/chromeos/drive/file_cache_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_cache_unittest.cc
@@ -738,8 +738,8 @@
     ASSERT_TRUE(cache_->Initialize());
   }
 
-  static void RenameCacheFilesToNewFormat(FileCache* cache) {
-    cache->RenameCacheFilesToNewFormat();
+  static bool RenameCacheFilesToNewFormat(FileCache* cache) {
+    return cache->RenameCacheFilesToNewFormat();
   }
 
   content::TestBrowserThreadBundle thread_bundle_;
@@ -909,7 +909,6 @@
   EXPECT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file));
   EXPECT_EQ(FILE_ERROR_OK,
             cache_->Store(id, md5, file, FileCache::FILE_OPERATION_COPY));
-  EXPECT_TRUE(base::PathExists(file_directory.AppendASCII(id)));
 
   // Canonicalize IDs.
   EXPECT_TRUE(cache_->CanonicalizeIDs(id_canonicalizer));
@@ -918,16 +917,15 @@
   FileCacheEntry entry;
   EXPECT_FALSE(cache_->GetCacheEntry(id, &entry));
   EXPECT_TRUE(cache_->GetCacheEntry(canonicalized_id, &entry));
-  EXPECT_TRUE(base::PathExists(file_directory.AppendASCII(canonicalized_id)));
 }
 
 TEST_F(FileCacheTest, RenameCacheFilesToNewFormat) {
   const base::FilePath file_directory =
       temp_dir_.path().AppendASCII(kCacheFileDirectory);
 
-  // File with an old style "<ID>.<MD5>" name.
+  // File with an old style "<prefix>:<ID>.<MD5>" name.
   ASSERT_TRUE(google_apis::test_util::WriteStringToFile(
-      file_directory.AppendASCII("id_koo.md5"), "koo"));
+      file_directory.AppendASCII("file:id_koo.md5"), "koo"));
 
   // File with multiple extensions should be removed.
   ASSERT_TRUE(google_apis::test_util::WriteStringToFile(
@@ -936,27 +934,27 @@
       file_directory.AppendASCII("id_kyu.md5"), "kyu"));
 
   // Rename and verify the result.
-  RenameCacheFilesToNewFormat(cache_.get());
+  EXPECT_TRUE(RenameCacheFilesToNewFormat(cache_.get()));
   std::string contents;
   EXPECT_TRUE(base::ReadFileToString(file_directory.AppendASCII("id_koo"),
-                                          &contents));
+                                     &contents));
   EXPECT_EQ("koo", contents);
   contents.clear();
   EXPECT_TRUE(base::ReadFileToString(file_directory.AppendASCII("id_kyu"),
-                                          &contents));
+                                     &contents));
   EXPECT_EQ("kyu", contents);
 
   // Rename again.
-  RenameCacheFilesToNewFormat(cache_.get());
+  EXPECT_TRUE(RenameCacheFilesToNewFormat(cache_.get()));
 
   // Files with new style names are not affected.
   contents.clear();
   EXPECT_TRUE(base::ReadFileToString(file_directory.AppendASCII("id_koo"),
-                                          &contents));
+                                     &contents));
   EXPECT_EQ("koo", contents);
   contents.clear();
   EXPECT_TRUE(base::ReadFileToString(file_directory.AppendASCII("id_kyu"),
-                                          &contents));
+                                     &contents));
   EXPECT_EQ("kyu", contents);
 }