| Index: chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
|
| diff --git a/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc b/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
|
| index d1470da54e110fecf1630afa591945fd34410611..1499d18aea5a0151ed7d85cf180498dc1345d2de 100644
|
| --- a/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
|
| +++ b/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
|
| @@ -52,7 +52,8 @@ struct InitialCacheResource {
|
| // with a symlink in pinned dir referencing it.
|
| { "directory_entry_atom.json", "pinned:existing", "md5_pinned_existing",
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| "md5_pinned_existing", GDataCache::CACHE_TYPE_PERSISTENT },
|
| // Cache resource with a non-existent source file that is pinned, to test that
|
| // a pinned file can reference a non-existent file.
|
| @@ -63,7 +64,8 @@ struct InitialCacheResource {
|
| // with a symlink in outgoing dir referencing it.
|
| { "account_metadata.json", "dirty:existing", "md5_dirty_existing",
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| "local", GDataCache::CACHE_TYPE_PERSISTENT },
|
| // Cache resource that is pinned and dirty, to test a dirty pinned file is in
|
| // persistent dir with symlink in pinned and outgoing dirs referencing it.
|
| @@ -71,7 +73,8 @@ struct InitialCacheResource {
|
| "md5_dirty_and_pinned_existing",
|
| GDataCache::CACHE_STATE_PRESENT |
|
| GDataCache::CACHE_STATE_PINNED |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| "local", GDataCache::CACHE_TYPE_PERSISTENT },
|
| };
|
|
|
| @@ -332,7 +335,8 @@ class GDataCacheTest : public testing::Test {
|
| GetCacheEntryFromOriginThread(resource.resource_id, md5);
|
| ASSERT_TRUE(cache_entry.get());
|
| EXPECT_EQ(resource.cache_state, cache_entry->cache_state);
|
| - EXPECT_EQ(resource.expected_sub_dir_type, cache_entry->sub_dir_type);
|
| + EXPECT_EQ(resource.expected_sub_dir_type,
|
| + cache_entry->GetSubDirectoryType());
|
| }
|
| }
|
|
|
| @@ -688,7 +692,7 @@ class GDataCacheTest : public testing::Test {
|
| GDataCache::IsCachePinned(expected_cache_state_)) {
|
| ASSERT_TRUE(cache_entry.get());
|
| EXPECT_EQ(expected_cache_state_, cache_entry->cache_state);
|
| - EXPECT_EQ(expected_sub_dir_type_, cache_entry->sub_dir_type);
|
| + EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType());
|
| } else {
|
| EXPECT_FALSE(cache_entry.get());
|
| }
|
| @@ -870,7 +874,6 @@ TEST_F(GDataCacheTest, InitializeCache) {
|
|
|
| TEST_F(GDataCacheTest, CacheStateBitmasks) {
|
| GDataCache::CacheEntry cache_entry("md5_cache_state_bitmasks",
|
| - GDataCache::CACHE_TYPE_TMP,
|
| GDataCache::CACHE_STATE_NONE);
|
| EXPECT_FALSE(cache_entry.IsPresent());
|
| EXPECT_FALSE(cache_entry.IsPinned());
|
| @@ -1079,7 +1082,8 @@ TEST_F(GDataCacheTest, PinAndUnpin) {
|
| // Pin the existing file in cache.
|
| num_callback_invocations_ = 0;
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| @@ -1093,7 +1097,8 @@ TEST_F(GDataCacheTest, PinAndUnpin) {
|
| // Pin back the same existing file in cache.
|
| num_callback_invocations_ = 0;
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| @@ -1143,7 +1148,8 @@ TEST_F(GDataCacheTest, StoreToCachePinned) {
|
| TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
|
| base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| @@ -1152,7 +1158,8 @@ TEST_F(GDataCacheTest, StoreToCachePinned) {
|
| TestStoreToCache(resource_id, md5, FilePath("./non_existent.json"),
|
| base::PLATFORM_FILE_ERROR_NOT_FOUND,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
| }
|
| @@ -1177,7 +1184,8 @@ TEST_F(GDataCacheTest, GetFromCachePinned) {
|
| TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
|
| base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Get the previously pinned and stored file from cache.
|
| @@ -1198,7 +1206,8 @@ TEST_F(GDataCacheTest, RemoveFromCachePinned) {
|
| base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
|
| GDataCache::CACHE_TYPE_TMP);
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Remove |resource_id| from cache.
|
| @@ -1215,7 +1224,8 @@ TEST_F(GDataCacheTest, RemoveFromCachePinned) {
|
| base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
|
| GDataCache::CACHE_TYPE_TMP);
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| num_callback_invocations_ = 0;
|
| @@ -1236,16 +1246,19 @@ TEST_F(GDataCacheTest, DirtyCacheSimple) {
|
| // Mark the file dirty.
|
| num_callback_invocations_ = 0;
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Commit the file dirty.
|
| num_callback_invocations_ = 0;
|
| TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| - GDataCache::CACHE_TYPE_PERSISTENT);
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| + GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Clear dirty state of the file.
|
| @@ -1267,7 +1280,8 @@ TEST_F(GDataCacheTest, DirtyCachePinned) {
|
| base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
|
| GDataCache::CACHE_TYPE_TMP);
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Mark the file dirty.
|
| @@ -1275,24 +1289,27 @@ TEST_F(GDataCacheTest, DirtyCachePinned) {
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| GDataCache::CACHE_STATE_DIRTY |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Commit the file dirty.
|
| num_callback_invocations_ = 0;
|
| TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| - GDataCache::CACHE_TYPE_PERSISTENT);
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| + GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Clear dirty state of the file.
|
| num_callback_invocations_ = 0;
|
| TestClearDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
| }
|
| @@ -1312,7 +1329,9 @@ TEST_F(GDataCacheTest, PinAndUnpinDirtyCache) {
|
| base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
|
| GDataCache::CACHE_TYPE_TMP);
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Verifies dirty file exists.
|
| @@ -1326,7 +1345,7 @@ TEST_F(GDataCacheTest, PinAndUnpinDirtyCache) {
|
| // Pin the dirty file.
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY |
|
| - GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PINNED | GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Verify dirty file still exist at the same pathname.
|
| @@ -1334,7 +1353,8 @@ TEST_F(GDataCacheTest, PinAndUnpinDirtyCache) {
|
|
|
| // Unpin the dirty file.
|
| TestUnpin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Verify dirty file still exist at the same pathname.
|
| @@ -1354,31 +1374,37 @@ TEST_F(GDataCacheTest, DirtyCacheRepetitive) {
|
| // Mark the file dirty.
|
| num_callback_invocations_ = 0;
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Again, mark the file dirty. Nothing should change.
|
| num_callback_invocations_ = 0;
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Commit the file dirty. Outgoing symlink should be created.
|
| num_callback_invocations_ = 0;
|
| TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| - GDataCache::CACHE_TYPE_PERSISTENT);
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| + GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Again, commit the file dirty. Nothing should change.
|
| num_callback_invocations_ = 0;
|
| TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| - GDataCache::CACHE_TYPE_PERSISTENT);
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| + GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Mark the file dirty agian after it's being committed. Outgoing symlink
|
| @@ -1386,16 +1412,18 @@ TEST_F(GDataCacheTest, DirtyCacheRepetitive) {
|
| num_callback_invocations_ = 0;
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Commit the file dirty. Outgoing symlink should be created again.
|
| num_callback_invocations_ = 0;
|
| TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| - GDataCache::CACHE_TYPE_PERSISTENT);
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| + GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
|
|
| // Clear dirty state of the file.
|
| @@ -1460,14 +1488,17 @@ TEST_F(GDataCacheTest, DirtyCacheInvalid) {
|
| // Mark an existing file dirty, then store a new file to the same resource id
|
| // but different md5, which should fail.
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| num_callback_invocations_ = 0;
|
| md5 = "new_md5";
|
| TestStoreToCache(resource_id, md5, GetTestFilePath("subdir_feed.json"),
|
| base::PLATFORM_FILE_ERROR_IN_USE,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
| }
|
| @@ -1483,18 +1514,21 @@ TEST_F(GDataCacheTest, RemoveFromDirtyCache) {
|
| base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
|
| GDataCache::CACHE_TYPE_TMP);
|
| TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED,
|
| + GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| GDataCache::CACHE_STATE_PINNED |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
|
| - GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED |
|
| - GDataCache::CACHE_STATE_DIRTY,
|
| - GDataCache::CACHE_TYPE_PERSISTENT);
|
| + GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_DIRTY |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| + GDataCache::CACHE_TYPE_PERSISTENT);
|
|
|
| // Try to remove the file. Since file is dirty, it and the corresponding
|
| // pinned and outgoing symlinks should not be removed.
|
| @@ -1544,8 +1578,9 @@ TEST_F(GDataCacheTest, GetCacheState) {
|
|
|
| // Store a file corresponding to |resource_id| and |md5| to cache, and pin
|
| // it.
|
| - int expected_cache_state = GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_PINNED;
|
| + int expected_cache_state = (GDataCache::CACHE_STATE_PRESENT |
|
| + GDataCache::CACHE_STATE_PINNED |
|
| + GDataCache::CACHE_STATE_PERSISTENT);
|
| TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
|
| base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
|
| GDataCache::CACHE_TYPE_TMP);
|
| @@ -1585,7 +1620,8 @@ TEST_F(GDataCacheTest, MountUnmount) {
|
| TestSetMountedState(resource_id, md5, file_path, true,
|
| base::PLATFORM_FILE_OK,
|
| GDataCache::CACHE_STATE_PRESENT |
|
| - GDataCache::CACHE_STATE_MOUNTED,
|
| + GDataCache::CACHE_STATE_MOUNTED |
|
| + GDataCache::CACHE_STATE_PERSISTENT,
|
| GDataCache::CACHE_TYPE_PERSISTENT);
|
| EXPECT_EQ(1, num_callback_invocations_);
|
| EXPECT_TRUE(CacheEntryExists(resource_id, md5));
|
|
|