| OLD | NEW |
| 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/chromeos/drive/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 const base::FilePath file_directory = | 931 const base::FilePath file_directory = |
| 932 temp_dir_.path().Append(util::kCacheFileDirectory); | 932 temp_dir_.path().Append(util::kCacheFileDirectory); |
| 933 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( | 933 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( |
| 934 file_directory.AppendASCII("id_foo.md5foo"), "foo")); | 934 file_directory.AppendASCII("id_foo.md5foo"), "foo")); |
| 935 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( | 935 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( |
| 936 file_directory.AppendASCII("id_bar.local"), "bar")); | 936 file_directory.AppendASCII("id_bar.local"), "bar")); |
| 937 | 937 |
| 938 // Remove the existing DB. | 938 // Remove the existing DB. |
| 939 const base::FilePath metadata_directory = | 939 const base::FilePath metadata_directory = |
| 940 temp_dir_.path().Append(util::kMetadataDirectory); | 940 temp_dir_.path().Append(util::kMetadataDirectory); |
| 941 ASSERT_TRUE(file_util::Delete(metadata_directory, true /* recursive */)); | 941 ASSERT_TRUE(base::Delete(metadata_directory, true /* recursive */)); |
| 942 | 942 |
| 943 // Put an empty file with the same name as old DB. | 943 // Put an empty file with the same name as old DB. |
| 944 // This file cannot be opened by ImportOldDB() and will be dismissed. | 944 // This file cannot be opened by ImportOldDB() and will be dismissed. |
| 945 ASSERT_TRUE(file_util::CreateDirectory(metadata_directory)); | 945 ASSERT_TRUE(file_util::CreateDirectory(metadata_directory)); |
| 946 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( | 946 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( |
| 947 metadata_directory.Append(FileCache::kOldCacheMetadataDBName), "")); | 947 metadata_directory.Append(FileCache::kOldCacheMetadataDBName), "")); |
| 948 | 948 |
| 949 // Create a new cache and initialize it. | 949 // Create a new cache and initialize it. |
| 950 metadata_storage_.reset(new ResourceMetadataStorage( | 950 metadata_storage_.reset(new ResourceMetadataStorage( |
| 951 metadata_directory, base::MessageLoopProxy::current())); | 951 metadata_directory, base::MessageLoopProxy::current())); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 // Data is imported correctly. | 1041 // Data is imported correctly. |
| 1042 FileCacheEntry entry; | 1042 FileCacheEntry entry; |
| 1043 EXPECT_TRUE(cache_->GetCacheEntry(key1, std::string(), &entry)); | 1043 EXPECT_TRUE(cache_->GetCacheEntry(key1, std::string(), &entry)); |
| 1044 EXPECT_EQ(md5_1, entry.md5()); | 1044 EXPECT_EQ(md5_1, entry.md5()); |
| 1045 EXPECT_TRUE(cache_->GetCacheEntry(key2, std::string(), &entry)); | 1045 EXPECT_TRUE(cache_->GetCacheEntry(key2, std::string(), &entry)); |
| 1046 EXPECT_EQ(md5_2, entry.md5()); | 1046 EXPECT_EQ(md5_2, entry.md5()); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 } // namespace internal | 1049 } // namespace internal |
| 1050 } // namespace drive | 1050 } // namespace drive |
| OLD | NEW |